最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - pip install an application with both extras and constraints - Stack Overflow

programmeradmin0浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论