Publishing Python Packages to PyPI Using Build and Twine
Learn how to securely publish Python packages to PyPI using pyproject.toml, the build module, and Twine with API tokens to avoid common distribution errors.
ReadMeFeed / Community knowledge
Real questions. Useful conversations. Find the people who know your stack.
Learn how to securely publish Python packages to PyPI using pyproject.toml, the build module, and Twine with API tokens to avoid common distribution errors.
Python projects still use fragile setup.py files. Switching to pyproject.toml centralizes metadata, separates packaging from runtime, and unlocks modern build backends like Poetry. This blog walks through the why, how, and trade‑offs with a concrete example and actionable next steps.
Decide between setuptools, Poetry, or Flit for your PyPI package by comparing legacy support, lock‑file availability, and binary extension handling. Follow a step‑by‑step validation to build, upload, and install a test wheel, ensuring your chosen backend works with your CI and deployment workflow.
Python 3.12 removed the long-deprecated distutils package from the standard library, shifting any deployment or build script that imports distutils directly onto a replacement. Setuptools provides a vendored distutils through its _distutils_hack, but that shim activates only when setuptools is imported first. The result is an unresolved compatibility boundar
When a project is specified only via pyproject.toml (i.e. no setup.{py,cfg} files), how can it be installed in editable mode via pip (i.e. python -m pip install -e . )? I tried both setuptools and poetry for the build system, but neither worked: [build-system] requires = ["setuptools", "wheel"] build-backend = "setuptools.build_meta" [build-system] requires
I'm trying to migrate a setuptools -based project from the legacy setup.py towards modern pyproject.toml configuration. At the same time I want to keep well established workflows based on pip-compile , i.e., a requirements.in that gets compiled to a requirements.txt (for end-user / non-library projects of course). This has important benefits as a result of t
version pip 21.2.4 python 3.6 The command: pip install -r requirements.txt The content of my requirements.txt : mongoengine==0.19.1 numpy==1.16.2 pylint pandas==1.1.5 fawkes The command is failing with this error ERROR: Command errored out with exit status 1: command: /Users/*/Desktop/ml/*/venv/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.arg