Design a small package with explicit dependencies
In this article (3 sections)
Imports hidden in one laptop’s global environment make a project irreproducible. Declare what the application needs and keep test/tool dependencies separate.
Inspect two groups
The engineering foundations lab uses constrained fixture requirements.
from engineering_cases import dependency_case
result = dependency_case()
assert result["separated"] is True
assert result["unbounded"] == []
assert result["runtime"] == ["httpx>=0.27,<1", "pydantic>=2,<3"]
assert result["installed"] is FalseNo package installation occurs; compatibility still needs a real clean-environment test.
Put import-time requirements in [project.dependencies]. Put test, lint and docs tools in dependency groups or documented extras suitable for the chosen toolchain. Set requires-python, use defensible version ranges and produce a lock or fully resolved deployment artifact for applications.
Avoid listing standard-library modules. Remove unused dependencies and inspect transitive licenses/security updates. CI should create a clean environment from declarations, install the package and run tests. A successful local import after undeclared global installation proves little.
The FDE for Freshers course connects package design to CI and container builds.
Exercise
Move a three-file script into a package, remove one undeclared dependency from the global environment and prove the clean CI install either fails clearly or succeeds from metadata.
Continue learning
This article is part of the FDE engineering foundations sequence. Use the neighbouring tasks when you need the prerequisite or the next application.
- Review the prerequisite or neighbouring task in Build a Python CLI that another person can install.
- Continue with Use type hints to document an integration boundary.
Reference: PyPA `pyproject.toml` specification.
Pankit Kumar has 10 years in Data Science & AI, building and shipping production systems in regulated pharma and clinical environments. He is a freelance trainer at Boston Institute of Analytics, AnalytixLabs and Scaler, and has taught this material to thousands of working professionals.
This article is part of our FDE for Freshers programme — 6–7 months. Build your engineering foundations, then take AI from discovery to delivery.
Explore FDE for Freshers