Set up a private package index
Overview
At this writing our current practise is to generate versioned tarballs and to 'pip install' from those.
This describes setting up a private package index as a more convenient alternative to using tarballs directly.
Our python software needs to be kept compatible with the standard python package index for when we desire to offer it to the general public.
To ensure we are staying compatible with pypi, we need to run it through the process, but with a conforming private packaging index.
devpi to the rescue ('https://www.devpi.net/') .
It is a conforming package index system we can use to serve our private packages whithout releasing them to the public.
Configuring the SW for devpi
This information is derived from the following tutorial:
<https://devpi.net/docs/devpi/devpi/stable/+doc/quickstart-releaseprocess.html>_
We start by creating a virtual environment called "venv_devpi" by following the steps described in the document virtualenv.
Then we activate that environment and continue with the steps below.
Set up devpi server on our laptop
Install a devpi client and web server
pip install -U devpi-web devpi-clientNote:
The non-web server - devpi-server - is also installed as a side effect.We must avoid needing sudo to access the index, so instead we change ownership from root to the logged in user. We also need to make sure supervisor runs our server as that user.
First manually do this:
sudo mkdir -p /var/devpi-server sudo chown -R $(logname):$(logname) /var/devpi-server ls -ld /var/devpi-serverInitialize an empty index (at /var/devpi-server by default)
devpi-initMake a place to put our configuration data files:
mkdir -p ${HOME}/devpi_setupThe following will generate a bunch of config files, one of which we will need, under the current directory. Putting that stuff in ${HOME}/devpi_setup.
pushd . >/dev/null cd ${HOME}/devpi_setup devpi-gen-config popd >/dev/nullNote:
This gave us the file ${HOME}/devpi_setup/gen-config/supervisor-devpi.conf as a config file to start up our pypi server. Start by editing it manually to say autostart=False so that it will need to be started up manually.Append a line like "user = username" to the configuration so it launches as that user, the same user as above.
echo user = $(logname) >>${HOME}/devpi_setup/gen-config/supervisor-devpi.confCopy the config where where it needs to be, then start our server.
sudo cp ${HOME}/devpi_setup/gen-config/supervisor-devpi.conf /etc/supervisor/conf.d/supervisor-devpi.conf sudo supervisorctl update sudo supervisorctl start devpi-serverCreate a user (within the server), login as that user and create the 'bzdev' index
devpi use http://localhost:3141 devpi user -c pbernatchez password=dummy devpi login pbernatchez --password=dummy devpi index -c bzdev bases=root/pypiUse our bzdev index
devpi use pbernatchez/bzdevNow we can make use of our private index.
We are using flit to publish to our index and it relies on the file : ~/.pypirc.
For pip I named it 'bzdevpi'. So we make an entry there for our index:
[distutils] index-servers = bzdevpi testpypi [bzdevpi] repository = http://localhost:3141/pbernatchez/bzdev username = pbernatchez [testpypi] repository = https://test.pypi.org/legacy/ username = pbernatchezFrom here on, using flit,
To publish,flit publish --repository bzdevpiTo install,pip install -i http://localhost:3141/pbernatchez/bzdev foobarExample:
deactivate cd /home/ubuntu/allrepos/wait_ssh source ${HOME}/venv_generic/bin/activate flit build flit publish --repository bzdevpi pip uninstall wait_ssh pip install -i http://localhost:3141/pbernatchez/bzdev wait_ssh