Project: Package-Ready Mini App
Project: Package-Ready Mini App
In this capstone project, we will apply the software packaging and environment concepts covered across this chapter—Virtual Environments, Pip Management, Dependency Manifests, and PEP 621 Standard Packaging—to structure, package, and install a professional, distributable Command-Line Currency Converter Tool.
1. Professional Project Directory Layout
A production-ready Python project follows a standardized folder hierarchy that separates application source code, tests, documentation, and configuration files:
2. Defining Dependencies: requirements.txt & .gitignore
.gitignore
requirements.txt
requirements-dev.txt
3. Application Source Code
currency_converter/__init__.py
currency_converter/api_client.py
currency_converter/cli.py
4. Modern Packaging Manifest: pyproject.toml
The pyproject.toml file is the unified standard configuration for Python packaging, replacing legacy setup.py scripts:
5. Installing in Editable Mode (pip install -e .)
During development, install your package into your active virtual environment in Editable Mode (-e). This registers the package and its console scripts while linking directly to your source files, meaning edits to code take effect immediately without re-installing:
Output:
Multiple Choice Questions
1. What does the -e flag stand for in pip install -e .?
A. Encrypted B. Editable (development mode) C. External D. Execution Answer: B Explanation: -e installs a project in editable mode, allowing code changes to take effect immediately without reinstalling the package.
2. Which modern configuration file has become the standardized replacement for setup.py under PEP 518/621?
A. config.json B. package.json C. pyproject.toml D. python.ini Answer: C Explanation: pyproject.toml is the standardized declarative configuration file for Python builds, tooling, and package metadata.
3. In pyproject.toml, what does [project.scripts] define?
A. Scheduled cron jobs B. Terminal CLI commands and entry points that map to specific Python functions C. HTML web templates D. Unit tests Answer: B Explanation: [project.scripts] maps terminal command names (e.g. currency-convert) directly to callable functions (e.g. currency_converter.cli:main).
4. Why is having an __init__.py file inside the currency_converter folder important?
A. It compiles the code to assembly B. It marks the directory as a Python package, allowing its internal modules to be imported C. It generates database tables D. It opens an HTTP server Answer: B Explanation: An __init__.py file designates a directory as an importable Python package.
5. What file should always be included in version control to inform team members of the exact dependency versions required?
A. app.exe B. .venv/ C. requirements.txt D. python.dll Answer: C Explanation: requirements.txt specifies the list of package dependencies and version constraints for reproducing the environment.
Introduction to Matplotlib
Continue learning with hands-on practice, examples, and exercises in the upcoming topic.
Related Lessons
| Previous Lesson | Next Lesson |
|---|---|
| Requirements.txt | Introduction to Matplotlib |
Practice Quiz
Test your understanding of this lesson with 5 questions. Each question has one correct answer.