Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@nealtodd
Last active July 6, 2016 10:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nealtodd/3449678b36b57c2db42c973fc14dfcd0 to your computer and use it in GitHub Desktop.
Save nealtodd/3449678b36b57c2db42c973fc14dfcd0 to your computer and use it in GitHub Desktop.
Debugging / testing a third party package without hacking the pip installed version
cd somewhere
git clone https://github.com/[OWNER]/[REPO].git --branch [SPECIFIC BRANCH] --single-branch
cd [REPO]
python setup.py develop
# Usually, restart dev server to prevent it using already loaded site-packages modules.
# Hack away on code in [REPO], python will use this one rather than the one in site-packages.
# When done, to switch back:
python setup.py develop --uninstall
cd ..
rm -rf [REPO]
@nealtodd
Copy link
Author

Kudos to http://controlfd.com/2016/05/03/how-to-debug-3rd-party-libraries.html

Avoids having to hack and unhack the site-packages version and/or uninstall via pip and pip install a branch using the -e syntax (and the reverse).
Debugging a specific pip installed version requires that it has its own branch to clone. The default branch may well be different.

Useful for testing a new release before it hits PyPI, or testing a PR in a real use prior to submitting it to the upstream repo.

@nealtodd
Copy link
Author

nealtodd commented Jun 9, 2016

In a Vagrant setup where your editor and repo are on the host, with the repo dir mounted within Vagrant, it's convenient to be able to edit the third party package in your editor. To avoid it showing up as an untracked directory in git you can add test_package (or any name you want) to .gitignore and clone the package using that name as the destination:

cd [MYREPO]
git clone https://github.com/[OWNER]/[REPO].git --branch [SPECIFIC BRANCH] --single-branch test_package

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment