>[!quote] In a Nutshell
>**Package format** that contains the files necessary for installing a [[- Python Programming Language -|Python package]]. Successor of the old `.egg` format.
---
A Python wheel is a `.whl` file, essentially a zip archive with specific structure for Python tools like [[Conda and Pip for Python|Pip]] to understand. It contains:
- **Python code** (modules, packages, etc.)
- **Compiled extensions** (e.g., `.so`, `.pyd`, `.dll` files)
- Metadata such as version info, dependencies, and required Python versions.
Example of a wheel file structure:
```bash
mymodule-1.0.0-cp39-cp39-win_amd64.whl
├── mymodule/
├── mymodule/__init__.py
├── mymodule/extension.cpython-39-x86_64-linux-gnu.so
├── METADATA
├── WHEEL
├── INSTALLER
├── RECORD
└── INFO/
```
When you run:
```bash
pip install <some-package>
```
- **If a wheel is available** for your platform and Python version, `pip` will download the `.whl` file and install the package directly.
- **If no wheel is available**, `pip` will fall back to downloading the source code and compiling it (which can be slower and require additional build tools).
---
#### Naming Convention
The name of a wheel file follows a standard pattern:
```php
<package-name>-<version>-<python-tag>-<abi-tag>-<platform-tag>.whl
```
- **Python tag**: Indicates the version(s) of Python the wheel is compatible with (e.g., `cp39` for CPython 3.9).
- **ABI tag**: Refers to the Application Binary Interface (e.g., `cp39` for CPython 3.9, or `none` for no ABI requirements).
- **Platform tag**: Refers to the platform (e.g., `win_amd64` for 64-bit Windows).
For example:
- `numpy-1.21.2-cp39-cp39-win_amd64.whl`: This is the `numpy` package for Python 3.9 on 64-bit Windows.
---
#### Creating a Wheel
To create a wheel for a package you are developing, you would typically use a tool like `setuptools` in combination with `wheel`. For example:
1. Ensure you have `wheel` installed:
```bash
pip install wheel
```
2. Create a wheel from your package source:
```bash
python setup.py bdist_wheel
```
This generates a `.whl` file that can be uploaded to PyPI (the Python Package Index) or shared directly with others for easy installation.