I might as well provide a proper answer to this on how we got DevPi
working quite nicely in our environment:
- Install DevPi
DevPi
requires Python 3! So make sure you have the Python 3 version of pip
installed. Using that:
pip install -U devpi
(likely as root) should do the trick.
- Make sure your server firewall is open
DevPi
uses port 3141 by default. If you have firewall-cmd
installed something like
firewall-cmd --zone=public --add-port=3141/tcp --permanent
firewall-cmd --reload
or equivalent command on your system.
- Configure
DevPi
DevPi
will use PyPi
out of the box. We also wanted the ability to "overlay" our own packages that are only provided organisation internally. For local nabCERT packages requires an internal index. The nice thing as this one can itself use PyPi as fallback!
Select the devpi server to work on - which is the server you're on, probably
devpi use http://localhost:3141
Now create a user that can add and manage the internal packages and login with them
devpi user -c myuser password=mypassword
devpi login myuser --password mypassword
Now create our internal index to hold local packages, while ensuring it will use PyPi as a "fallback"
devpi index -c myindex bases=/root/pypi volatile=True
Start it up
devpi-server --host=0.0.0.0 --port=3141 --serverdir=/var/www/pypi
Try and install a package
pip install -i http://localhost:3141/root/pypi/ simplejson
If something goes wrong check the logs, in our case they were in /var/www/pypi/.xproc/devpi-server/xprocess.log
At this point, if all settings above have been successfully followed, you should be able to open a web browser and point it at the devpi
server with
http://localhost:3141/myuser/myindex
- Make DevPi start automatically
That varies. We use systemd
so I created a file /usr/lib/systemd/system/devpi.service
[Unit]
Requires=network-online.target
After=network-online.target
[Service]
EnvironmentFile=-/etc/sysconfig/devpi
Type=forking
PIDFile=/var/www/pypi/.xproc/devpi-server/xprocess.PID
Restart=always
ExecStart=/bin/devpi-server --host=0.0.0.0 --port 3141 --serverdir /var/www/pypi --start
ExecStop=/bin/devpi-server --host=0.0.0.0 --port 3141 --serverdir /var/www/pypi --stop
User=root
[Install]
WantedBy=multi-user.target
Save the file and notify systemd.
systemctl daemon-reload
systemctl enable devpi
- Configure a client
To point your clients' pip
to use the new DevPi
repository create a /etc/pip.conf
file with something like this
[global]
trusted-host = <server IP or FQDN>
[install]
index-url = http://<server IP or FQDN>:3141/myuser/myindex/+simple/
[search]
index = http://<server IP or FQDN>:3141/myuser/myindex/