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 — Package Formats - Python Packaging User Guide Package Formats¶This page discusses the file formats that are used to distribute Python packages and the differences between them. You will find files in two formats on package indices such as PyPI: source
distributions, or sdists for short, and built distributions, commonly
called wheels. For example, the PyPI page for pip 23.3.1
lets you download two files, What is a source distribution?¶Conceptually, a source distribution is an archive of the source code in raw
form. Concretely, an sdist is a You can thus inspect the contents of an sdist by unpacking it using standard
tools to work with tar archives, such as Sdists serve several purposes in the packaging ecosystem. When pip, the standard Python package installer, cannot find a wheel to install, it will fall back on downloading a source distribution, compiling a wheel from it, and installing the wheel. Furthermore, sdists are often used as the package source by downstream packagers (such as Linux distributions, Conda, Homebrew and MacPorts on macOS, …), who, for various reasons, may prefer them over, e.g., pulling from a Git repository. A source distribution is recognized by its file name, which has the form
If you want technical details on the sdist format, read the sdist specification. What is a wheel?¶Conceptually, a wheel contains exactly the files that need to be copied when installing the package. There is a big difference between sdists and wheels for packages with
extension modules, written in compiled languages like
C, C++ and Rust, which need to be compiled into platform-dependent machine code.
With these packages, wheels do not contain source code (like C source files) but
compiled, executable code (like Furthermore, while there is only one sdist per version of a project, there may be many wheels. Again, this is most relevant in the context of extension modules. The compiled code of an extension module is tied to an operating system and processor architecture, and often also to the version of the Python interpreter (unless the Python stable ABI is used). For pure-Python packages, the difference between sdists and wheels is less
marked. There is normally one single wheel, for all platforms and Python
versions. Python is an interpreted language, which does not need ahead-of-time
compilation, so wheels contain If you are wondering about With that being said, there are still important differences between sdists and
wheels, even for pure Python projects. Wheels are meant to contain exactly what
is to be installed, and nothing more. In particular, wheels should never include
tests and documentation, while sdists commonly do. Also, the wheel format is
more complex than sdist. For example, it includes a special file – called
At a glance, you might wonder if wheels are really needed for “plain and basic” pure Python projects. Keep in mind that due to the flexibility of sdists, installers like pip cannot install from sdists directly – they need to first build a wheel, by invoking the build backend that the sdist specifies (the build backend may do all sorts of transformations while building the wheel, such as compiling C extensions). For this reason, even for a pure Python project, you should always upload both an sdist and a wheel to PyPI or other package indices. This makes installation much faster for your users, since a wheel is directly installable. By only including files that must be installed, wheels also make for smaller downloads. On the technical level, a wheel is a ZIP archive (unlike sdists which are TAR
archives). You can inspect its contents by unpacking it as a normal ZIP archive,
e.g., using Inside a wheel, you will find the package’s files, plus an additional directory
called The file name of a wheel (ignoring some rarely used features) looks like this:
The pattern All technical details on the wheel format can be found in the wheel specification. What about eggs?¶“Egg” is an old package format that has been replaced with the wheel format. It should not be used anymore. Since August 2023, PyPI rejects egg uploads. Here’s a breakdown of the important differences between wheel and egg.
|
| 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. |