pythonrequirements.txt

Install local wheel file with requirements.txt


I have a local package ABC-0.0.2-py3-none-any.whl. I want to install it in the different project through a "requirements.txt" file.

For example, I would like something like:

ABC==0.0.2  # to update for installing from my local whl
Flask==1.1.2
flask-restplus==0.13.0
gunicorn==20.0.4

Is it possible to install the ABC package this way, knowing that ABC-0.0.2-py3-none-any.whl is included in the source code.

Currently, I have to pip install ABC-0.0.2-py3-none-any.whl separately.


Solution

  • This is called a direct reference. Since version 19.3, pip support this in both command line and requirement files. Check out an example from the official documentation.

    As to OP's question, simply put the local wheel's relative path, i.e., ./<my_wheel_dir>/<my_wheel.whl>, in requirement.txt, e.g.,

    ./local_wheels/ABC-0.0.2-py3-none-any.whl
    Flask==1.1.2
    flask-restplus==0.13.0
    gunicorn==20.0.4