I have a Python-based application. There are a couple of different configuration options that it could have, and its pyproject.toml
includes these as pip extras.
[project]
dependencies = [...]
[project.optional-dependencies]
dev = ["pytest"]
feature = [...]
[project.scripts]
my_app = "my_app.main:main"
For production deployments, I'd like to have a lock file listing exact versions of the packages I directly and indirectly depend on, and I'd like to have the versions be the same regardless of what combination of dependencies are there. I can do this easily enough with pip-tools
pip-compile -o constraints.txt --generate-hashes --all-extras --strip-extras
How do I use this constraints file? It seems like I should be able to tell pip to install the current directory using constraints for all dependencies, as selected by the application's extras
pip install -c constraints.txt '.[feature]'
except that there's a rule that hash mode implies hashes for all dependencies, even things named explicitly on the command line. For this application-oriented workflow I'd prefer to not push a wheel file to a repository if that's avoidable.