Roll Your Own Python IDE
I’ve found myself using Python significantly more in the past week and quickly grew tired of working in a shell in Terminal, so I started looking around for a good IDE that supported Python. I first tried Xcode, surprised to discover that you can specify whatever build tool you’d like for a project, as I already use it for iOS development, however wrestling with auto-indentation appearing in all of the wrong places became frustrating to say the least. Going back to the drawing board, I started scouring python.org’s wiki of various IDEs, trying just about every macOS-supported IDE, extension, and plugin listed. My wishlist of requirements and features might be a little long, but hey, almost all of my time spent when coding in Python will be within this integrated development environment (Hence the name), so I think I’m allowed to be a bit picky. Here it is:
- Source code editor
- Syntax-highlighting
- Linter
- Autocomplete
- Compiler
- Debugger
- Autosave
- Version control (Preferably through Git)
- Free and open-source
- Native application
Ok, so those last two aren’t deal-breakers, but they’d be greatly appreciated, especially that last one, given how atrocious Java app UIs tend to be (Looking at you, CrashPlan).
I had all but given up hope of finding an IDE, and started looking into text-editors that could hopefully fulfill at least part of my wishlist, which is when I found Atom, “A hackable text editor for the 21st century.” Now I had heard of Atom before as one of the contenders in the modern incarnation of the “vim vs emacs” war, facing off against Sublime. As a result, I had always just written it off as another glorified iteration of TextEdit, until I found this post about configuring it for Python. Configuring Atom with just the packages mentioned in the post alone crossed off quite a few of my wishlist requirements, even the optional points regarding a native, open source application. Seeing the plethora of other packages available for Atom, I tried taking things a step further, rolling my own Python IDE in Atom.
Installing Packages
There are two ways to install packages in atom, you can either search for packages published on atom.io from the Install tab in Preferences, or use apm
in Terminal. For example, to install Linter for Atom from Terminal, just enter:
Atom needs to be restarted after packages are installed for changes to take effect.
Configuring Atom
If you haven’t already, install Linter for Atom, mentioned above. Additionally, we’re going to need a Python source code checker, flake8, which we can get through pip:
We’ll also need an interface between linter and flake8, linter-flake8. Again, you can use the Install tab in Preferences, or:
For autocomplete, you can install the autocomplete-python package. The packages script and python-debugger provide compiling and debugging functionality, respectively. There are a few dependency packages that Atom might ask you to install after restarting, such as intentions and busy-signal. Finally, autosave is a pre-installed package in Atom but is disabled by default. To enable, go to the Packages tab in Preferences, and search for “autosave,” which will appear under Core Packages. In its settings, select “Enabled.” But what about version control? I almost forgot! Atom comes with Git support and core APIs already baked in.
Atom is incredibly customizable thanks to the wealth of packages available, and this process could easily be applied to other languages. I look forward to seeing how far this text editor can go, as I explore and tinker with everything Atom has to offer.