Linux command
build 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Build a Python package
python -m build
Build only source distribution
python -m build --sdist
Build only wheel
python -m build --wheel
Build with specific output directory
python -m build --outdir [dist/]
Build with verbose output
python -m build -v
Build without isolation
python -m build --no-isolation
说明
build is the standard Python package builder that creates source distributions (sdist) and wheels from Python projects. It is the recommended way to build packages for distribution on PyPI, replacing direct calls to setup.py sdist bdist_wheel. By default, build creates an isolated virtual environment with only build dependencies installed, ensuring reproducible builds. It reads configuration from pyproject.toml and delegates to the configured build backend (setuptools, flit, hatch, etc.). The output is placed in a dist/ directory containing a .tar.gz source distribution and a .whl wheel file. These can be uploaded to PyPI with twine or installed directly with pip.
参数
- --sdist
- Build a source distribution only.
- --wheel
- Build a wheel only.
- --outdir _directory_
- Output directory for built packages (default: dist/).
- --no-isolation
- Build without creating isolated environment.
- --skip-dependency-check
- Skip dependency verification.
- --config-setting _key=value_
- Pass settings to the build backend.
- -v, --verbose
- Increase output verbosity.
- -C _setting_
- Short form of --config-setting.
FAQ
What is the build command used for?
build is the standard Python package builder that creates source distributions (sdist) and wheels from Python projects. It is the recommended way to build packages for distribution on PyPI, replacing direct calls to setup.py sdist bdist_wheel. By default, build creates an isolated virtual environment with only build dependencies installed, ensuring reproducible builds. It reads configuration from pyproject.toml and delegates to the configured build backend (setuptools, flit, hatch, etc.). The output is placed in a dist/ directory containing a .tar.gz source distribution and a .whl wheel file. These can be uploaded to PyPI with twine or installed directly with pip.
How do I run a basic build example?
Run `python -m build` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --sdist do in build?
Build a source distribution only.