Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best practice for hacking on a 3rd-party python module

Tags:

python

I often find myself wanting to use a 3rd party python module in my own project, but I know that I will also need to make changes to the 3rd party module that I want to push upstream. What is the best practice of file layout/installation to achieve this?

Most python modules are laid out with root dir containing a "setup.py" to compile/install the module. The problem is, every time I make changes to the module source I need to re-run the full install step in order to use those changes in my project. For large modules, like scipy this can take some time.

Alternatively, I can hack on the installed version of the python module, but then I have to manually move those changes back to the source version of the module in order to generate patches etc.

I know about virtualenv and PYTHONPATH but they are ways of installing a module to a different location.

So far, I have manually created symlinks, but that is messy.

like image 807
jjh Avatar asked Sep 02 '25 18:09

jjh


1 Answers

If the 3rd party project is using setuptools or distribute, you can do python setup.py develop instead of install. This will create the appropriate sym-links in the site-packages dir for you.

like image 152
Adam Wagner Avatar answered Sep 04 '25 06:09

Adam Wagner