Tags: #python3 #pip #repository #pypi
Note: summarized from this post.
The simplest way to have pip install foo
run successfully against your own Pip repository (instead of using the official PyPi) is to:
/etc/pip.conf
file locally that is configured to your web server.For step 2, the directory structure might look something like:
.
├── airports
│ └── airports-0.2.tar.gz
└── paho-mqtt
└── paho-mqtt-1.5.0.tar.gz
For step 3, the /etc/pip.conf
file could look something like:
[global]
index = http://10.53.1.1/pip/
index-url = http://10.53.1.1/pip/
trusted-host = 10.53.1.1
Note:
10.53.1.1
should be replaced with your own web server IP.
It’s worth noting that you don’t need a /etc/pip.conf
file, as those options can be provided on the command line (e.g. pip install --index-url=<your_webserver_address> <package(s)>
).
Now you should be able to install from your own Python repository:
$ python3.7 -m venv test_custom_pip
$ source test_custom_pip/bin/activate
$ pip install airports
In order to backup the packages your project depends on (e.g. have them installed on your web server in a format that pip install
will recognize) is to use a tool such as pip2pi.
The pip2pi
package can be installed via pip
. It can also use (although optional) a requirements.txt
file for specifying the packages you want it to download.