I have a package with a setup.py file and want to use pip-tools to pin my dependencies for production.
Let's say my setup.py looks as follows:
#!/usr/bin/env python
import pathlib
from setuptools import setup, find_packages
setup(
author="Foo",
description="My package",
install_requires=["package1==1.0", "package2==2.0"],
extras_require={
"top_level": ["package1", "package2"],
},
version="0.1.0",
)
How could I here track my top level requirements within a setup.py and write them back to the same file within the section install_requires? Would I just pip-compile from setup.py into a requirements.txt and read the contents from this file into install_requires?
You can track top-level deps in
requirements.inand usepip-compileto lock deps inrequirements.txt. Then you can make asetup.pyand use both requirements files accordingly. For example:See an example of Sentry's setup.py.