简体   繁体   中英

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM