Improve dependency management with MANIFEST.in
Problem
Currently, the package dependencies are hardcoded in setup.py, which creates several issues:
- Dependencies are duplicated between
setup.py and requirements.txt
- Version updates need to be synchronized in multiple files
- Dependabot can only manage versions in
requirements.txt, not setup.py
Solution
Implement the same approach as used in datadog-monitor-deployer:
- Add a
MANIFEST.in file to ensure requirements.txt is included in source distribution
- Modify
setup.py to read dependencies from requirements.txt
- Keep
requirements.txt as the single source of truth for dependencies
Implementation Steps
- Create
MANIFEST.in with the following content:
include LICENSE
include README.md
include requirements.txt
include requirements-dev.txt
recursive-include src *.py
recursive-include tests *.py
recursive-include config *.yaml
- Update
setup.py to read from requirements.txt:
# Read requirements
with open("requirements.txt", "r", encoding="utf-8") as f:
requirements = [line.strip() for line in f if line.strip() and not line.startswith("#")]
setup(
# ... other setup parameters ...
install_requires=requirements,
# ... rest of setup ...
)
Benefits
- Single source of truth for dependencies
- Better integration with Dependabot
- Cleaner dependency management
- Consistent with Python packaging best practices
- Matches the approach used in datadog-monitor-deployer
Testing
- Delete existing tag
- Create new tag
- Verify package builds and publishes correctly
- Verify all dependencies are correctly included
References
Improve dependency management with MANIFEST.in
Problem
Currently, the package dependencies are hardcoded in
setup.py, which creates several issues:setup.pyandrequirements.txtrequirements.txt, notsetup.pySolution
Implement the same approach as used in datadog-monitor-deployer:
MANIFEST.infile to ensurerequirements.txtis included in source distributionsetup.pyto read dependencies fromrequirements.txtrequirements.txtas the single source of truth for dependenciesImplementation Steps
MANIFEST.inwith the following content:setup.pyto read fromrequirements.txt:Benefits
Testing
References