Package Maintenance#

The following describes procedures for basic package maintenance.

Unit Tests#

In order to run unit tests, install MBIRJAX using the provided install scripts, and from the root directory of the repository, activate the conda environment, and then run the following:

pytest

This should be repeated for each supported platform.

Uploading to PyPI#

This is only available for registered maintainers.

  1. Update the version number in prerelease and accept the PR to main.

  2. Run the script clean_install_all.sh and activate mbirjax

  3. First, make sure you have installed the newest versions of setuptools, wheel, build, twine, and pkginfo. Then from the main mbirjax directory, delete any previous build and then build the project:

    pip install --upgrade setuptools build wheel twine pkginfo
    rm -rf dist/ build/ *.egg-info
    python -m build
    
  4. Check the distribution:

    python -m twine check dist/*
    
  5. Upload to PyPI. You will need an API token from PyPI. NOTE: You cannot upload the same version more than once:

    python -m twine upload dist/*
    

    View the package upload here: https://pypi.org/project/mbirjax

  1. Test the uploaded package (NOTE: to test on the GPU, use ‘pip install mbirjax[cuda12]’):

    pip install mbirjax    # OR, "mbirjax==0.1.1" e.g. for a specific version number
    python -c "import mbirjax"     # spin the wheel
    pip install pytest
    pytest tests
    
  2. Run one of the demos in mbirjax/demo.

  3. Verify that the corresponding build of the MBIRJAX documentation has built correctly.

Uploading to Test PyPI#

This is only available for registered maintainers. Typically, you would perform these steps on the prerelease branch before the final commit to main.

Follow steps 0-3 as above. Then upload to testpypi:

  1. Upload to Test PyPI. You will need to get an API token from TestPyPI. You will be prompted for this token from the command line. NOTE: You cannot upload the same version more than once:

    python -m twine upload --repository testpypi dist/*
    

    View the package upload here: https://test.pypi.org/project/mbirjax

  2. Test the uploaded package (NOTE: to test on the GPU, use ‘pip install -i https://test.pypi.org/simple/ –extra-index-url https://pypi.org/simple mbirjax[cuda12]’):

    pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple mbirjax
    python -c "import mbirjax"     # spin the wheel
    pip install pytest
    pytest tests
    
  3. Run one of the demos in mbirjax/demo.

    NOTE: If the install fails and you need to re-test, temporarily set the version number in pyproject.toml from X.X.X to X.X.X.1 (then 2, 3, etc.), for further testing. After the test is successful, reset the version number in pyproject.toml, then merge any required changes into the master branch, then delete and re-create the git tag, and proceed to PyPI upload.

  4. Verify that the corresponding build of the MBIRJAX documentation has built correctly.

Reference#

More details can be found in the sources below.

[1] Packaging Python projects: [link]
[2] Using TestPyPI: [link]