When you need to fix a bug, add feature or change existing functionality in a library that you are using there are several ways to do this. Here I will show you how to do this properly:
- Fork repository.
- Clone into your local dir.
- Create new branch and add your code (do not forget to add tests!).
- Commit & push, create PR on your forked repo, merge.
- Create PR to the base project so this change can go upstream (and then the whole community benefits from it).
- Release your updated version of this lib.
Step 3 can be a bit tricky to do because often you need to test this new code in your existing project. My favourite way to test if your new code works is to install this lib (package) in “develop mode”:
pip install -e /src/my_modified_lib
Step 6 is needed if you have continuous integration like TravisCI. For this you also need your own private pypi server or have an account on official python pypi server. To create a release package that you can upload on pypi server just type:
python setup.py sdist --formats=zip
When releasing package, MANIFEST.in file is very important so if your files are missing in the .zip package, the problem is with MANIFEST.in file.
Then just upload this package (located in `dist` folder) to pypi server. Next thing you will need to do is to tell your buildout process where this new package is located. This is unfortunately very different based on which buildout tool you use (e.g. if you are using buildout tool you need to add link to this package to the “find-links” list).