If you are working on OpenStack you'll need to work in Linux. Hypothetically, OpenStack code is written in Python and Python code can be written to be platform independent. In practice, much of the Python code in OpenStack's components is written in the most expedient way and that way is often platform specific.
If you are using a virtual machine to run Linux, you might want your native host to run the IDE portion of your development cycle. I've managed to get a hybrid development environment where I use PyCharm as my IDE for development and unit testing along side a standard Linux environment hosted in a Linux machine (using vi for editing and) using devstack for setup and manual functional testing of my code.
- On OS X, first prime your development environment.
checkout Nova (or your particular OpenStack project) - $ git clone https://github.com/openstack/nova.git
- prime the OpenStack components' virtual environment
- Start PyCharm and tell it to open the directory where your new OpenStack project lives.
- Once PyCharm has setup the project and has it open for you, modify the project settings
- The configuration menu has a large number of settings, we're interested in the settings for a project interpreter:
- Once you've selected the Project Interpreter panel, you will see the Python Interpreters that PyCharm knows about. Typically it will only have auto-detected the system-wide Python interpreter. You could just use this one if you wanted, but that would require carefully setting up all the OpenStack dependencies for the interpreter and keeping them up to date with what OpenStack needs. Instead, we'll set up the .venv based interpreter ./run_tests.sh just built for you as a PyCharm interpreter.
- You'll next be prompted on how you want to add the Virtualenv, and we'll probably want to not only make this interpreter available for this PyCharm project, but also any PyCharm project we work on. You really only need to select the top check-box, but the bottom box won't hurt the current project any.
- You will also have to manually install some packages such as Nose by selecting "Install" for the selected interpreter and choosing Nose related packages.
Close the package install dialog with the red "x" button in the upper left hand corner. - You are now ready to run tests locally. Many unit tests lean on environment variables. You may be forced to edit your Python test runner configurations. You modify the default test runner by accessing the "Edit Configurations..." dialog here:
You may have to use menu File -> Invalidate Caches and restart PyCharm for it to fully accept the new Python interpreter.
You'll have a new problem... how do you move changes between your Host OS and your Guest OS? You could always check in WIP patches and pull them down to the different environments, but that's a lot of extra noise on the review system. Why not just pull the patches between your two OSes by sharing the file system of the Guest with the Host?
For that you'll need some extra setup and some osascript hacking. I'll cover that in a different post.