Knowledge Base

Preserving for the future: Shell scripts, AoC, and more

Self-host a pip repo

tl;dr

Use apache httpd with autoindex on. In the module project, make file pyproject.toml. Run python3 -m build and take the dist/*.tar.gz files and place in the apache web directories underneath a normalized directory name.

  • /var/www/
    • python/
      • tkstackrpms/
        • tkstackrpms-0.0.1.tar.gz
        • tkstackrpms-0.0.2.tar.gz

Using your self-hosted repo

pip install --extra-index-url http://server3/internal/repo/python/ --trusted-host server3 tkstackrpms

Or load into ~/.config/pip/pip.conf the following.

[global]
trusted-host = server3
extra-index-url = http://server3/internal/repo/python
                  https://www.example.com/internal/repo/python

Narrative

I have a small python module I wrote, and I want it to be available to me inside a python virtual environment (venv). Since I don't really want to go through whatever rigamarole would be required for a public package, and not sure I want to burden the world with my creation, I wanted to self-host a repository.

Inside a venv one can't just install my dpkg, so I needed a proper pip web repository.

Thankfully, the process is well documented and works with some basic httpd configuration I already was using!

References

See all links in-line.

Comments