Search code examples
pythondjangogithubpip

How can I maintain a modified version of a Python library and ensure that my application installs this version automatically using requirements.txt?


I want to avoid manually editing the library code each time I install dependencies and is there a way to get future updates to the library while still preserving my changes?

I am currently clueless on how can I achieve this.


Solution

  • Fork the library > make your changes on your fork > add the fork's repository URL to your requirements.txt.

    requirements.txt:

    git+https://github.com/<your_username>/<forked-library-repo>.git@<your-branch>#egg=<original_library_name>
    

    replace everything with a <>


    To get future updates to the library while still preserving your chages. You will probably need to add the original repository as a remote in your local clone > fetch and merge changes from the original repository > resolve merge conflicts manualy > push the updated code to your fork.

    take these steps with a grain of salt... I have not testes this but in theory this should work.