pypiserver

Reading Time: < 1 minute

Last Updated: 4/2/2025

To make it easier to re-create in the future it might not be a bad idea to leave myself a note.

The goal here is to discuss how to create a pypi server to create a place to host python wheels and make it easier to install. You might ask why would you need to do this. Well #1 Python pips ability to use a proxy can be a bit suspect at times. #2 You might be in a non-permissive environment that does not have outside access.

General Theory:

The theory would be to create a folder under /opt named /packages. Inside of packages you might create a directory named simple

.
└── packages
    └── simple
        ├── aiohttp
        │   ├── aiohttp-3.8.4-cp310-cp310-win32.whl
        │   ├── aiohttp-3.8.4-cp310-cp310-win_amd64.whl

INSTALLING PYPISERVER

To install the pypiserver

pip install pypiserver

To install as a service

cat <<EOF | sudo tee /etc/systemd/system/pypiserver.service
[Unit]
    After=network.target

 [Service]
    Type=simple
    ExecStart=/usr/local/bin/pypi-server run -p 8080 /opt/packages
    WorkingDirectory=/opt/packages
    TimeoutStartSec=3

[Install]
    WantedBy=multi-user.target
EOF

Common commands to check on.

systemctl restart pyserver

Hint:

To use this a secure service, you might want to install NGINX and use it as a proxy that receives traffic on port 8080 and then redirects the request internally over to port 8090 Please see additional post on how to use NGINX as HTTPS redirect.

This entry was posted in Python. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *