Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Building Distributions | Building and Managing Packages
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Python Packaging and Distribution

bookBuilding Distributions

When you create a Python package that you want to distribute, you need to build a distribution artifact. There are two primary distribution types: source distributions (sdist) and wheel distributions (wheel). Each serves a distinct purpose during installation.

A source distribution is an archive (usually a .tar.gz file) containing your raw source code and metadata. When someone installs your package from an sdist, the installer must build the package on the target system. This means running setup scripts and potentially compiling code, which can take time and may require extra dependencies or compilers.

A wheel distribution is a pre-built, binary package with the .whl extension. Wheels are the modern standard for Python packaging. Because wheels are already built, installation is much faster and does not require building or compiling code during installation. This is especially helpful for packages with compiled extensions or complex build steps.

Both sdists and wheels are important. Wheels provide speed and convenience for users, while sdists offer a fallback for systems or environments where a pre-built wheel is not available or compatible.

# To build both a source distribution (sdist) and a wheel, use the following commands in your project directory:

# First, ensure you have the build tool:
pip install build

# Then, build both distributions:
python -m build

# This will create .tar.gz (sdist) and .whl (wheel) files in the 'dist/' directory.
question mark

What is the main advantage of a wheel (.whl) distribution over a source (sdist) distribution?

Select the correct answer

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 2. Capítulo 5

Pergunte à IA

expand

Pergunte à IA

ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

Suggested prompts:

Can you explain the main differences between source distributions and wheel distributions?

When should I use a source distribution instead of a wheel?

Are there any situations where only one distribution type is available?

bookBuilding Distributions

Deslize para mostrar o menu

When you create a Python package that you want to distribute, you need to build a distribution artifact. There are two primary distribution types: source distributions (sdist) and wheel distributions (wheel). Each serves a distinct purpose during installation.

A source distribution is an archive (usually a .tar.gz file) containing your raw source code and metadata. When someone installs your package from an sdist, the installer must build the package on the target system. This means running setup scripts and potentially compiling code, which can take time and may require extra dependencies or compilers.

A wheel distribution is a pre-built, binary package with the .whl extension. Wheels are the modern standard for Python packaging. Because wheels are already built, installation is much faster and does not require building or compiling code during installation. This is especially helpful for packages with compiled extensions or complex build steps.

Both sdists and wheels are important. Wheels provide speed and convenience for users, while sdists offer a fallback for systems or environments where a pre-built wheel is not available or compatible.

# To build both a source distribution (sdist) and a wheel, use the following commands in your project directory:

# First, ensure you have the build tool:
pip install build

# Then, build both distributions:
python -m build

# This will create .tar.gz (sdist) and .whl (wheel) files in the 'dist/' directory.
question mark

What is the main advantage of a wheel (.whl) distribution over a source (sdist) distribution?

Select the correct answer

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 2. Capítulo 5
some-alt