Skip to content

Building and distributing python packages

Brian Wheeler edited this page Apr 8, 2026 · 1 revision

Build package

Python packages are built in the repo directory by running:

python -mbuild

It will output a bunch of stuff and should end up looking like this:

((.venv) ) $ python -mbuild
* Creating isolated environment: venv+pip...
* Installing packages in isolated environment:
  - setuptools
* Getting build dependencies for sdist...
running egg_info
creating ampav_whisper.egg-info
writing ampav_whisper.egg-info/PKG-INFO
...
adding 'ampav_whisper-0.0.1.dist-info/METADATA'
adding 'ampav_whisper-0.0.1.dist-info/WHEEL'
adding 'ampav_whisper-0.0.1.dist-info/top_level.txt'
adding 'ampav_whisper-0.0.1.dist-info/RECORD'
removing build/bdist.linux-x86_64/wheel
Successfully built ampav_whisper-0.0.1.tar.gz and ampav_whisper-0.0.1-py3-none-any.whl

Setting up the local repository access (one time only)

We're currently using a local repository rather than publishing to PyPI – so we have to do some minor setup.

First, developers will need to have a username/password in the htpasswd file in the service directory. It just uses the standard htpasswd tool to manage the database.

Second, we have to tell the publishing tools about our repository. Add these lines to ~/.pypirc :

[distutils]
index-servers =
  local

[local]
repository: https://pypi.dlib.indiana.edu
username: your_username
password: your_password

Publish package

The package can be pushed to our pypi repository by using twine . This is the push for ampav-core version 0.0.4:

twine upload -r local dist/ampav_core-0.0.4*

If you try to push the same version more than once it will fail. The version number is managed in pyproject.toml

You can verify the package upload by checking the repository index at https://pypi.dlib.indiana.edu