Packagr CLI


Packagr now has a new CLI (beta). See here to get started

We have just launched a new, open source, command line interface for Packagr. This project is still in beta but our intention is that it will eventually become the primary tool for publishing packages to your Packagr repository. twine will always be a supported option, but our hope is that our users will find the new Packagr-CLI easier to work with

The problem with twine

twine is an excellent tool for the job it is intended to fulfil - uploading Python packages to the public Python repository,

The problem with twine for Packagr's purposes is that its error handling isn't brilliant. For PyPI, it doesn't need to be - package uploads only ever tend to fail due to two reasons - either the request hasn't been authenticated properly (403 error), or you are trying to upload a package/version that already exists (409 error).

The problem of using twine with Packagr is that Packagr has more complex constraints in terms of who can upoad a package and when, and to which repository. In some circumstances, Packagr will refuse to allow the upload of a package - however, as twine can only support 403 or 409 error statuses, any bad request to Packagr will result in a 409 error - and twine doesn't display the content of this error, meaning that you can never be completely sure why it is happening.

For example, a package may fail to upload to Packagr because you have run out of your allocated disk space - however, the response you get from twine would simply suggest its a URL conflict, which makes debugging difficult

Packagr-CLI aims to resolve this issue by completely replacing twine as a publishing mechanism, and implementing its own method, designed specifically around the Packagr API, that does provide more feedback to the end user when things go wrong

What other advantages does Packagr-CLI have?

Packagr-CLI also aims to simplify your configuration. Once you've first installed it, you'll need to run the following command:

packagr configure <packagr-hash-id> <email> <password>

Once you've done that, your credentials are set and you don't need to add repository URLs to your pip/twine calls, specify your credentials every time you want to install/publish packages or mess around with pip.conf files (and worry about escaping special characters in your credentials)

This means that you have to do a lot less typing. For example, the ƒollowing legacy command:

pip install my-package --extra-index-url --disable-pip-version-check     User for
Password: ********

Becomes simply this:

packagr add my-package

Similarly, publishing packages is now way easier. This command:

python sdist bdist_wheel
twine upload dist/*
User for
Password: ********

Becomes simply this:

packagr package && packagr upload

Other functionality

For convenience, the Packagr CLI will soon add the ability to perform Packagr adminstrative functions programatically - for example, in future releases it will be possible to create and manage access tokens via the CLI, instead of having to login to the app.

To see the full list of commands that is available to use now, you can refer to the docs