devpi

Note

Refer to your company Checklist and replace devpi.yourbiz.co.uk with the name of your devpi server. Do the same for the username and password.

Salt

Salt requires two separate bits of information in your pillar. The first is the server configuration. Here is an example file:

devpi:
  domain: devpi.yourbiz.co.uk
  port: 4040
  ssl: False
  # letsencrypt: True

The domain name is the server where your devpi service is running.

The port number is the one on which the local devpi service is running. The port is used when the service is started by supervisor. For details, see: https://github.com/pkimber/salt/blob/master/supervisor/devpi.conf

The ssl is set to False and the letsencrypt key is commented out so we can generate the LetsEncrypt certificate. They will both be set back to True after the certificate is generated.

The second piece of information required in your pillar is the configuration of pip. Here is an example file:

pip:
  index_url: http://devpi.yourbiz.co.uk/bz/dev/+simple/

Prerequisites

To create a Let’s Encrypt certificate, see the devpi section in Obtain and configure ssl certificate on nginx with letsencrypt.

Tip

Don’t forget to add the - /usr/share/nginx/html parameter to the init-letsencrypt command.

If you are creating your own SSL certificate (devpi (in detail)):

To restrict access to your devpi server by IP address using a firewall, see Web - Configuration.

Initial Configuration

To configure http://doc.devpi.net/ after Salt has installed it on your server, run the following commands on your workstation:

# virtual environment
virtualenv --python=python3.6 venv-devpi-client
source venv-devpi-client/bin/activate
pip install --upgrade pip

pip install devpi-client

Important

Use python 3 for devpi or you might get SSL certificate errors.

Security

Create a password for the root user (change 123 to a password of your choice before adding to the Checklist):

devpi use --set-cfg https://devpi.yourbiz.co.uk/root/pypi/
devpi login root --password ""
devpi user -m root password=789
devpi logoff

To log in later:

devpi login root --password "789"

Development Index

Note

The user you create is used in the devpi URL e.g. for user bz the devpi URL will be https://devpi.yourbiz.co.uk/bz/dev

We need to create a user and an index for the user so we can upload our own packages (in this example, the user is bz):

devpi login root --password "789"

devpi user -c bz password=789
devpi login bz --password "789"
devpi index -c dev volatile=False

Note

To delete the index: devpi index --delete dev

Client

To configure your workstation to use devpi as it’s default index:

devpi use https://devpi.yourbiz.co.uk/bz/dev/ --set-cfg

Note

I don’t know how to set the username or password

To remove the index (not sure if this works):

devpi use https://devpi.yourbiz.co.uk/bz/dev/ --delete

Upgrade

To upgrade the index to a new version:

sudo -i -u web
cd /home/web/repo/devpi
source venv_devpi/bin/activate
devpi-server --export /home/web/repo/backup/devpi/ --serverdir=/home/web/repo/devpi/data
mv /home/web/repo/devpi/data /home/web/repo/temp/
devpi-import --serverdir /home/web/repo/devpi/data /home/web/repo/backup/devpi/

Note

The data folder needs to be removed before running the import command.

Issues

To solve any server side issues, start by using the --debug parameter in the /etc/supervisor/conf.d/devpi.conf file e.g:

/home/web/repo/devpi/venv_devpi/bin/devpi-server --serverdir=/home/web/repo/devpi/data --refresh=60 --port=4040 --host=127.0.0.1 --debug

Re-start the service using supervisorctl and check the logs in:

/var/log/supervisor/

Bad Request

I kept getting a Bad request (400) error with no more information when running:

python setup.py clean sdist upload -r dev

For the first release of a module, use the devpi upload command. Subsequent releases will work using setup.py upload.

Weird

If the release procedure (python setup.py clean sdist upload -r dev) starts to throw some weird errors e.g:

running upload
Submitting dist/pkimber-my-app-0.0.03.tar.gz to http://your.server/bz/dev/
error: None

… then check the nginx error logs on the server:

tail /var/log/nginx/error.log