I spend a lot of my time building things as a member of Dell Cloud Manager on the backend systems team.
1. Get out of my comfort zone and in front of people (the scariest place).
2. Talk about PyCharm because I think it's cool (and I wanna know some more about it).
3. Be a part of a great community.
This assumes you have PyCharm Professional Edition and Vagrant installed
- Go into the project directory
cd ~/pynash-pycharm/
- Copy pycharm-debug.egg into the project directory
cp /Applications/PyCharm.app/pycharm-debug.egg .
- Start up VM with provided Vagrantfile
-
The project root will be mapped to /vagrant directory in the VM once started.
-
vagrant up
-
vagrant ssh
-
sudo -i
-
apt-get update
-
apt-get install python-virtualenv
-
cd /vagrant
-
Create and activate virtualenv and install deps
-
virtualenv --no-site-packages /opt/pynashenv
-
source /opt/pynashenv/bin/activate
-
pip install -r requirements.txt
-
Install unzip then cp and unzip pycharm-debug.egg into virtualenv site-packages
-
apt-get install unzip
-
cd /opt/pynash-pycharm/lib/python2.7/site-packages/
-
cp /vagrant/pycharm-debug.egg .
-
unzip pycharm-debug.egg
- Setup PyCharm
- Make sure you have Vagrant plugin installed (Pycharm -> Preferences -> plugins -> vagrant)
- Set up remote interpreter (point to the one we have just created) (File -> Default Settings -> Default Project -> interpreter)
- Edit configuration to set up remote debugger (Edit config-> + -> Python Remote Debug)
- Fill in name, hostname, port, and path mapping (remember the port)
- You can now start the debug server
- Go back to your VM and kick off a script or test suite:
- Copy the following snippet into the script that you want to debug
import pydevd
pydevd.settrace(<local ip of host machine>, port=4567, stdoutToServer=True, stderrToServer=True)
- Now you can kick off your script/test-suite and you will see the process connect to the PyCharm debugger
- Here is where we do
nosetests
orpython -m unittest <module>
- It will pause on the first executable statement that it comes to if you pass
suspend=True
to settrace - Otherwise you can now set breakpoints and step through/step out. Even just going step by step to get a nice visual of how your program executes.
- We have a computer so we should automate the setup some