Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Publishing to PyPI | Distribution & Publishing
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Python Packaging and Distribution

bookPublishing to PyPI

Before you upload your distribution, ensure your package files are ready. You should have built distribution archives such as a source distribution (.tar.gz) and a wheel (.whl) using tools like build. These files are typically found in the dist/ directory of your project.

Security is crucial when publishing to PyPI.

  • Always use a strong, unique password for your PyPI account;
  • Enable two-factor authentication (2FA) for additional protection;
  • Never share your credentials or store them in your project repository;
  • Consider using a password manager to keep your login details secure.

To upload your package, you will use twine, which is a secure utility for publishing Python packages. Make sure you have twine installed in your environment.

# Upload your package to PyPI using twine
twine upload dist/*

After running this command, you will be prompted for your PyPI username and password. If you have enabled two-factor authentication (2FA), you will also need to provide your authentication code. Check the output for any errors, and verify your package is available on https://pypi.org/project/your-package-name/.

Note
Note

Review your package for sensitive files or credentials before uploading. Once a version is published to PyPI, it cannot be overwritten or deleted for security reasons, so double-check everything before you proceed.

question mark

What is a recommended security practice when publishing to PyPI?

Select the correct answer

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 3. Kapittel 3

Spør AI

expand

Spør AI

ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

bookPublishing to PyPI

Sveip for å vise menyen

Before you upload your distribution, ensure your package files are ready. You should have built distribution archives such as a source distribution (.tar.gz) and a wheel (.whl) using tools like build. These files are typically found in the dist/ directory of your project.

Security is crucial when publishing to PyPI.

  • Always use a strong, unique password for your PyPI account;
  • Enable two-factor authentication (2FA) for additional protection;
  • Never share your credentials or store them in your project repository;
  • Consider using a password manager to keep your login details secure.

To upload your package, you will use twine, which is a secure utility for publishing Python packages. Make sure you have twine installed in your environment.

# Upload your package to PyPI using twine
twine upload dist/*

After running this command, you will be prompted for your PyPI username and password. If you have enabled two-factor authentication (2FA), you will also need to provide your authentication code. Check the output for any errors, and verify your package is available on https://pypi.org/project/your-package-name/.

Note
Note

Review your package for sensitive files or credentials before uploading. Once a version is published to PyPI, it cannot be overwritten or deleted for security reasons, so double-check everything before you proceed.

question mark

What is a recommended security practice when publishing to PyPI?

Select the correct answer

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 3. Kapittel 3
some-alt