GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing packaging.python.org — The Packaging Flow - Python Packaging User Guide The Packaging Flow¶The document aims to outline the flow involved in publishing/distributing a distribution package, usually to the Python Package Index (PyPI). It is written for package publishers, who are assumed to be the package author. While the tutorial walks through the process of preparing a simple package for release, it does not fully enumerate what steps and files are required, and for what purpose. Publishing a package requires a flow from the author’s source code to an end user’s Python environment. The steps to achieve this are:
At that point, the package is present on the package distribution service. To use the package, end users must:
These last 2 steps are typically performed by pip when an end user runs
The steps above are described in more detail below. The source tree¶The source tree contains the package source code, usually a checkout from a VCS. The particular version of the code used to create the build artifacts will typically be a checkout based on a tag associated with the version. The configuration file¶The configuration file depends on the tool used to create the build artifacts.
The standard practice is to use a At a minimum, the For example, here is a table for using hatch: [build-system] requires = ["hatchling"] build-backend = "hatchling.build" With such a table in the The particular build tool you choose dictates what additional information is
required in the
Refer to the pyproject.toml guide for a
complete guide to Build artifacts¶The source distribution (sdist)¶A source distribution contains enough to install the package from source in an end user’s Python environment. As such, it needs the package source, and may also include tests and documentation. These are useful for end users wanting to develop your sources, and for end user systems where some local compilation step is required (such as a C extension). The build package knows how to invoke your build tool to create one of these: python3 -m build --sdist source-tree-directory Or, your build tool may provide its own interface for creating an sdist. The built distributions (wheels)¶A built distribution contains only the files needed for an end user’s Python
environment. No compilation steps are required during the install, and the
wheel file can simply be unpacked into the A pure Python package typically needs only one “generic” wheel. A package with compiled binary extensions needs a wheel for each supported combination of Python interpreter, operating system, and CPU architecture that it supports. If a suitable wheel file is not available, tools like pip will fall back to installing the source distribution. The build package knows how to invoke your build tool to create one of these: python3 -m build --wheel source-tree-directory Or, your build tool may provide its own interface for creating a wheel. Note The default behaviour of build is to make both an sdist and a wheel from the source in the current directory; the above examples are deliberately specific. Upload to the package distribution service¶The twine tool can upload build artifacts to PyPI for distribution, using a command like: twine upload dist/package-name-version.tar.gz dist/package-name-version-py3-none-any.whl Or, your build tool may provide its own interface for uploading. Download and install¶Now that the package is published, end users can download and install the package into their Python environment. Typically this is done with pip, using a command like: python3 -m pip install package-name End users may also use other tools like Pipenv, poetry, or pdm. |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |