pythonpython-3.xpip

pip install | How to install private project from the local file system when using requirements.txt?


I'm trying to figure out how to properly use python3.8 -m pip install to install the requirements from requirements.txt AND simultaneously install certain packages from the local file system instead of from the repo. We have a few different private repos that we may need to work on simultaneously for larger changes.

I have found that I could do this as two separate commands. First python3.8 -m pip install -r requirements.txt --index-url https://private/repo/dependency/simple and then python3.8 -m pip install path/to/dependency. But I would like to combine these into one command if possible. This would avoid the need to generate and manage access tokens as part of the index url for each developer.


Solution

  • pip allows you to specify multiple packages just fine.

    pip install path/to/local/package1 \
        path/to/another/package2 \
        -r requirements.txt
    

    If path/to/local/package1 overrides a package which is also mentioned in requirements.txt, Pip will prefer the one earlier on the command line, and then just conclude that the requirement is already met once it finds it again in requirements.txt