Build Package Metadata
Beginner · Write the code · 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 lessonWrite a function called create_metadata(name, version, description) that returns a dictionary with three keys: 'name', 'version', and 'description', mapped to the corresponding arguments. Also include a key 'requires-python' with value '>=3.8' and a key 'license' with value 'MIT'.
def create_metadata(name, version, description):
# Return the metadata dictionary
pass
What Check runs
Your code runs first, then each of these lines. The output must match exactly.
| Runs | Expected output |
|---|---|
| meta = create_metadata('my-tool', '1.0.0', 'A cool tool') for key in sorted(meta): print(f'{key}: {meta[key]}') | description: A cool tool license: MIT name: my-tool requires-python: >=3.8 version: 1.0.0 |
| meta = create_metadata('data-utils', '0.1.0', 'Data utilities') print(meta['name']) print(meta['version']) print(len(meta)) | data-utils 0.1.0 5 |
More PyPI Packaging exercises
- Fix the Version ComparatorIntermediate
- Predict the Build OutputIntermediate
- Refactor the Version BumperIntermediate
- Build a Release ManagerAdvanced
All Python exercises · 50 practice problems · Modules & Packaging quiz