Self hosting and installing from pip repos

I have an application that I want to share with my team. Fortunately, we have a shared server, so it is pretty easy to do so: if I put a file in /usr/local/bin it can A) be executed by anyone on the server and B) will not interfere with RPM packages. But, I do potentially want to put this code on other machines as well, so I am going to buld it as a pip package, upload it to a team repo (apache HTTPD instance on this machine) and then install it from pip as root.

Building the package from the git repo that holds the python code:

python -m build

This, of course, assumes I have a properly set up pyproject.toml file.

One key entry is the scripts part at the end:

[project.scripts]
ampup = "ampup:main"

Running this command puts the package in dist. To upload it I run:

pip2pi  /var/www/html/pypi/   -r requirements.txt -r  dist/*.whl

Since this is a default Apache install, I cheated a little bit with permissions: my whole team is in the kernelos group, and I made the directory executable and group writiable, and set its group to kernelos. That lets me publish to it.

Also, I have to upload something that is built in a gitlab repo, and posted to a pip repo hosted on gitlab. So

export PIP_INDEX_URL=https://gitlab.com/api/v4/projects/abignumber/packages/pypi/simple

Once it is uploaded, I sudo su to root and

export PIP_INDEX_URL=http://localhost/pypi/simple
pip install ampup

And now

# which ampup
/usr/local/bin/ampup

There is still something wrong with the script generation, which I have fixed by hand. I will update when I figure it out.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.