It was straightforward once I found the right advice.
If you're like me and have a build that creates a virtualenv with everything installed already by pip and a requirements.txt file. Here's how to get the environment and eclipse changed so that you can debug any dependency.
#Step 1. Remove the dependencies files from the virtualenv
This works for mac and uninstalls files that might have spaces in them too
python setup.py install --record files.txt
# inspect files.txt to make sure it looks ok. Then:
tr '\n' '\0' < files.txt | xargs -0 sudo rm -f --
I figured that out after a few different attempts and the best way to do it came from StackOverflow here: https://stackoverflow.com/a/25209129
#Step 2. Add the source folder as an external build dependency on the Python Interpreter Path

Credit for this step goes to a small sentence buried here: https://lukeplant.me.uk/blog/posts/eclipse-pydev-and-virtualenv/
That's it. Restart your django server and set a breakpoint inside that internal dependency.
This will save you a ton of time vs. all those import pdb; pdb.set_trace() statements
Drawbacks
This will break the virtualenv from the command line so for things like python manage.py commands. For those items, I went ahead and set up a second virtualenv.
No comments:
Post a Comment