Create a project on PyPI¶
This guide summarizes the process of creating a project on PyPI, which is necessary in order to install a Python package via pip install PROJECT_NAME.
Token for creating projects¶
- Create an account with PyPI at pypi.org
- Login to the account, go to the Account settings page
- Scroll down to the API token section and click "Create API token"
- Give token a name, e.g., "create-projects", and set scope to entire account
- Click create. Copy the token that appears.
- Add the token to a
$HOME/.pypircfile as described in the instructions.
Creating a project¶
Hatch
These instructions are specific to the use of the Hatch project manager hatch.pypa.io.
- Setup the Hatch project for your Python package repository.
- Edit the project metadata to your liking.
- Run
hatch build --cleanto build the distribution files. - Review the contents of the files to ensure they are what you intended.
- When ready, run
hatch publish. This should automatically detect and publish the package. - If successful, should print a link to your new PyPI page!
Failure
If the hatch publish command fails, it may be that the desired project name is not available.
Limit scope¶
With the project published, it's a good idea to generate a separate token specifically for publishing to that repository.
- Repeat the steps to reach the Create API token page.
- Give a name to the token and select the project name as the scope, instead of entire account.
- Create token and add it to the
.pypircfile as described in the instructions.