Is it possible to install packages using pip from the local filesystem?
I have run python setup.py sdist
for my package, which has created the appropriate tar.gz file. This file is stored on my system at /srv/pkg/mypackage/mypackage-0.1.0.tar.gz
.
Now in a virtual environment I would like to install packages either coming from pypi or from the specific local location /srv/pkg
.
Is this possible?
PS
I know that I can specify pip install /srv/pkg/mypackage/mypackage-0.1.0.tar.gz
. That will work, but I am talking about using the /srv/pkg
location as another place for pip to search if I typed pip install mypackage
.
Assuming you have virtualenv and a
requirements.txt
file, then you can define inside this file where to get the packages:This is the solution that I ended up using:
I pieced this together from pip install examples as well as from Rikard's answer on another question. The "--pre" argument lets you install non-production versions. The "--no-index" argument avoids searching the PyPI indexes. The "--find-links=." argument searches in the local folder (this can be relative or absolute). I used the "--log-file", "log.txt", and "-vv" arguments for debugging. The "--upgrade" argument lets you install newer versions over older ones.
I also found a good way to uninstall them. This is useful when you have several different Python environments. It's the same basic format, just using "uninstall" instead of "install", with a safety measure to prevent unintended uninstalls:
The local folder contains these files: install.py, uninstall.py, mypackagename-1.0.zip