Citing Why you shouldn't invoke setup.py directly by Paul Ganssle.

  • The setuptools project has stopped maintaining all direct invocations of setup.py years ago, and distutils is deprecated.
  • There are undoubtedly many ways that your setup.py-based system is broken today, even if it's not failing loudly or obviously.
  • Direct invocations of setup.py cannot bootstrap their own dependencies, and so some CLI is necessary for dependency management.
  • The setuptools project no longer wants to provide any public CLI, and will be actively removing the existing interface (though the time scale for this is long).
  • PEP 517, 518 and other standards-based packaging are the future of the Python ecosystem and a lot of progress has been made on making this upgrade seamless.

Here's a summary table of the setup.py way and the newer recommended method:

setup.py New command
setup.py sdist python -m build (with build)
setup.py bdist_wheel python -m build (with build)
setup.py test pytest (usually via tox or nox)
setup.py install pip install
setup.py develop pip install -e
setup.py upload twine upload (with twine)
setup.py check twine check (this doesn't do all the same checks but it's a start)
Custom commands tox and nox environments.
Answer from Nicholas Obert on Stack Overflow
🌐
Python Developer's Guide
devguide.python.org › getting-started › setup-building
Setup and building - Python Developer's Guide
1 week ago - You can also do each configuration and build step separately; the command above is a convenience wrapper around the following commands: ... $ python Platforms/WASI configure-build-python --quiet -- --config-cache --with-pydebug $ python Platforms/WASI make-build-python --quiet $ python Platforms/WASI configure-host --quiet -- --config-cache $ python Platforms/WASI make-host --quiet Python 3.14
🌐
Python
docs.python.org › 2.0 › inst › how-build-works.html
2.3 How building works
As implied above, the build command is responsible for putting the files to install into a build directory. By default, this is build under the distribution root; if you're excessively concerned with speed, or want to keep the source tree pristine, you can change the build directory with the ...
🌐
Python Packaging
packaging.python.org › tutorials › packaging-projects
Packaging Python Projects - Python Packaging User Guide
The build-backend key is the name of the Python object that frontends will use to perform the build. Both of these values will be provided by the documentation for your build backend, or generated by its command line interface.
🌐
GitHub
github.com › pypa › build
GitHub - pypa/build: A simple, correct Python build frontend · GitHub
A simple, correct Python build frontend. See the documentation for more information. build can be installed via pip or an equivalent via: ... This will build the package in an isolated environment, generating a source-distribution and wheel in the directory dist/. See the documentation for full information. Build is also available via the command line as pyproject-build once installed.
Author: pypa
🌐
Medium
medium.com › @ebimsv › building-python-packages-07fbfbb959a9
Building Python Packages. A Comprehensive Guide to setup.py and… | by Ebrahim Mousavi | Medium
October 13, 2024 - python -m build · This will create a dist/ folder containing the .tar.gz and .whl files. After running the above command, check that the dist/ directory contains your package files (.tar.gz and .whl): You should see something like: ...
🌐
Reddit
reddit.com › r/python › question: best ways to build python command line utilities
r/Python on Reddit: Question: best ways to build Python command line utilities
March 28, 2022 -

I have two medium size (less than 1000 lines each) code bases that I would like to make into two command line utilities. Two obvious approaches are:

  1. Add a __main__.py file and a setup.py to a module, and do a python setup.ps install

  2. Copy all source files into a single Python source file that starts with #!/usr/bin/env python, and put script in PATH.

To complicate matters, I use several different condo environments that I switch between. Is there an accepted best practice for this?

Find elsewhere
🌐
PyPI
pypi.org › project › build
build · PyPI
A simple, correct Python build frontend. See the documentation for more information. build can be installed via pip or an equivalent via: ... This will build the package in an isolated environment, generating a source-distribution and wheel in the directory dist/. See the documentation for full information. Build is also available via the command line as pyproject-build once installed.
🌐
GitHub
github.com › pypa › setuptools › discussions › 3762
Recommended way to add custom build steps · pypa/setuptools · Discussion #3762
January 11, 2023 - Also note that for Python, any ... pathlib import Path from setuptools import Command, setup from setuptools.command.build import build ......
Author: pypa
🌐
pytz
pythonhosted.org › an_example_pypi_project › setuptools.html
Getting Started With setuptools and setup.py — an_example_pypi_project v0.0.5 documentation
Standard commands: build build everything needed to install build_py "build" pure Python modules (copy to build directory) build_ext build C/C++ extensions (compile/link to build directory) build_clib build C/C++ libraries used by Python extensions build_scripts "build" scripts (copy and fixup ...
🌐
PyDevTools
pydevtools.com › home › python developer tooling handbook › reference › build
build: Python Package Build Frontend | pydevtools
September 7, 2026 - build is PyPA's PEP 517-compliant frontend tool for building Python packages using any standards-compliant build backend.
🌐
CodeRivers
coderivers.org › blog › python-build
Python Build: A Comprehensive Guide - CodeRivers
August 8, 2026 - To build your project, use the python -m build command (from the build package) in your project's root directory:
🌐
Medium
manningbooks.medium.com › parts-of-the-python-build-system-a30e6f7c5a8d
Parts of the Python Build System. From Publishing Python Packages by Dane… | by Manning Publications | Medium
January 5, 2022 - At a high level, the build command consumes your source code and the metadata you supply, along with some files it generates, to create: A source distribution package. A Python source distribution, or sdist, is a compressed archive file of the source code with a .tgz extension.
🌐
GitHub
github.com › pyenv › pyenv › blob › master › plugins › python-build › README.md
pyenv/plugins/python-build/README.md at master · pyenv/pyenv
Installing python-build as a standalone program will give you access to the python-build command for precise control over Python version installation.
Author: pyenv
🌐
Pypa
build.pypa.io › en › latest
build - 1.6.1
uv build is essentially equivalent to python -m build --installer=uv. Both follow packaging standards. build offers features like --config-json for passing complex nested configuration to backends, and the pip installer works on systems that don’t have pre-compiled uv wheels. build is the modern equivalent of setup.py sdist bdist_wheel, supporting any backend — not just setuptools. hatch build is the build command from the Hatch project management tool.
🌐
Pybites
pybit.es › articles › how-to-package-and-deploy-cli-apps
How to package and deploy CLI applications with Python PyPA setuptools build – Pybites
August 30, 2021 - build, aka PyPA build, is the more ... $ pip install build · Now, in the root of your project directory, you can run: $ python -m build ·...
🌐
Python Packaging
packaging.python.org › en › latest › guides › creating-command-line-tools
Creating and packaging command-line tools - Python Packaging User Guide
This guide will walk you through creating and packaging a standalone command-line application that can be installed with pipx, a tool for creating and managing Python Virtual Environments and exposing the executable scripts of packages (and available manual pages) for use on the command-line. First of all, create a source tree for the project. For the sake of an example, we’ll build a simple tool outputting a greeting (a string) for a person based on arguments given on the command-line.
🌐
Python Packaging
packaging.python.org › en › latest › guides › section-build-and-publish
Building and Publishing - Python Packaging User Guide
Toggle navigation of Building and Publishing · Writing your pyproject.toml · Packaging and distributing projects · Dropping support for older Python versions · Packaging binary extensions · Packaging namespace packages · Creating and packaging command-line tools ·
🌐
Earthly
earthly.dev › blog › create-python-package
Create a Python Package using Setup.py - Earthly Blog
November 7, 2023 - Or the newer version of the command · python -m build --wheel · * Creating virtualenv isolated environment... * Installing packages in isolated environment... (setuptools >= 40.8.0, wheel) * Getting build dependencies for wheel...
🌐
Arm Community
community.arm.com › support-forums › f › armds-forum › 55234 › running-python-script-as-build-command
Running Python Script as Build Command - Arm Development Studio forum - Support forums - Arm Community
I am trying to run a Python script as my build command: python ${ProjDirPath}/make_wrapper.py From within my Python script, I call the make with the two arguments