Editor

Predict the Build Output

Intermediate · Predict the output · from How to Package and Publish Your Python Code to PyPI

From the lesson: How to Package and Publish Your Python Code to PyPI

Imagine you've written a fantastic recipe. Right now it only lives in your kitchen notebook. To share it with the world, you'd need to format it nicely, package it into a cookbook, and get it onto bookstore shelves.

Read the lesson

Read the code below that simulates building distribution files for a package. What will it print?

def build_package(name, version):
safe_name = name.replace('-', '_')
sdist = f'{safe_name}-{version}.tar.gz'
wheel = f'{safe_name}-{version}-py3-none-any.whl'
return sdist, wheel
packages = [
('my-tool', '1.0.0'),
('data_utils', '0.2.1'),
]
for name, ver in packages:
sdist, wheel = build_package(name, ver)
print(f'dist/{sdist}')
print(f'dist/{wheel}')

More PyPI Packaging exercises

All Python exercises · 50 practice problems · Modules & Packaging quiz