use a relative path in requirements.txt to install a tar.gz file with pip
For me only the file:
directive worked. This even works with AWS SAM, i.e. sam build
. Here is my requirements.txt
and the englishapps is my own custom Python package that I need in AWS Lambda
requests
file:englishapps-0.0.1-py3-none-any.whl
Its based off the current working directory (find with os.getcwd() if needed) and the relative path you provide in the requirements file.
Your requirements file should look like this:
fabric==1.13.1
./some_fir/some_package.whl
packaging==16.8
Note this will only work for .whl files not .exe
Remember to keep an eye on the pip install output for errors.
In the current version of pip (1.2.1) the way relative paths in a requirements file are interpreted is ambiguous and semi-broken. There is an open issue on the pip repository which explains the various problems and ambiguities in greater detail:
https://github.com/pypa/pip/issues/328
Long story short the current implementation does not match the description in the pip documentation, so as of this writing there is no consistent and reliable way to use relative paths in requirements.txt
.
THAT SAID, placing the following in my requirements.txt
:
./foo/bar/mymodule
works when there is a setup.py
at the top level of the mymodule
directory. Note the lack of the file::
protocol designation and the inclusion of the leading ./
. This path is not relative to the requirements.txt
file, but rather to the current working directory. Therefore it is necessary to navigate into the same directory as the requirements.txt
and then run the command:
pip install -r requirements.txt