Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Package Release

This chapter is intended for collaborators who are responsible for releasing and maintaining Molass packages. It provides concise instructions for managing the package release process.

About PyPI

The Python Package Index (PyPI) is the official repository for Python packages. It allows developers to publish and distribute their Python libraries to a global audience. Users can install these packages using tools like pip. For Molass, PyPI serves as the platform for releasing and maintaining its packages, ensuring they are easily accessible to the community.

PyPI Account

To publish packages to PyPI, you need a PyPI account. This account is required to authenticate yourself as a trusted maintainer and to manage the packages you release.

How to Create a PyPI Account

  1. Go to the PyPI website.

  2. Click on the “Register” button in the top-right corner.

  3. Fill in the required details, including:

    • Username: Choose a unique username.

    • Email Address: Provide a valid email address for verification and notifications.

    • Password: Create a strong password.

  4. Complete the CAPTCHA and click “Register”.

  5. Verify your email address by clicking the link sent to your inbox.

Once your account is created and verified, you can use it to upload and manage Molass packages on PyPI.

PyPI API Token

A PyPI API token is a secure way to authenticate yourself when uploading packages to PyPI. Instead of using your username and password, which can be less secure, the API token allows you to perform package uploads while keeping your credentials safe.

How to Create a PyPI API Token

  1. Log in to your PyPI account.

  2. Click on your username in the top-right corner and select “Account settings”.

  3. Scroll down to the “API tokens” section and click “Add API token”.

  4. Provide a name for the token (e.g., “Molass Package Upload”).

  5. Under “Scope”, select the appropriate option:

    • Entire account: Allows the token to manage all your packages.

    • Specific project: Restricts the token to a specific package (recommended for security).

  6. Click “Add token”.

  7. Copy the generated token and store it securely. You won’t be able to view it again.

Important Notes

PyPI Upload

Default Procedure: Using GitHub Actions [1]

The default and recommended procedure for uploading Molass packages to PyPI is through a GitHub Actions workflow. This method ensures consistency, security, and ease of use for all collaborators.

Steps:

  1. Go to the "Actions" tab in the Molass Library repository.

  2. Select the "Manual Upload Python Package to PyPI" workflow.

  3. Click the "Run workflow" button.

Notes for Collaborators:

If the GitHub Actions workflow cannot be used, you can manually upload the package using Twine, as described below.

Alternative Procedure: Using Twine

To build required files, do as follows in the repository root folder.

python -m build

This will generate the distribution files in the dist subfolder.

To upload them to PyPI, you will need to provide your API token[2] to authenticate the upload when running the following twine command:

twine upload dist/*

By following the steps outlined in this chapter, collaborators can securely and efficiently manage the release of Molass packages to PyPI. The default GitHub Actions workflow ensures consistency and ease of use, while the Twine procedure provides a reliable fallback option when needed.

See also:

Footnotes
  1. This workflow is kept in .github/workflows/upload_to_pypi.yml in the repository.

  2. This API token should be kept safely somewhere.