以下是pip-tools
文档中的without setup.py
示例https://github.com/jazzband/pip-tools#without-setuppy
我所做的是把这个作为我的requirements.in
# To update requirements.txt, run:
#
# pip-compile requirements.in
#
# To install in localhost, run:
#
# pip-sync requirements.txt
#
django==3.2.5 # https://www.djangoproject.com/
psycopg2-binary==2.8.6 # https://github.com/psycopg/psycopg2
然后我将此作为产品要求。在中
# To update prod-requirements.txt, run:
#
# pip-compile prod-requirements.in
#
# To install in prod, run:
#
# pip-sync requirements.txt prod-requirements.txt
#
-c requirements.txt
gunicorn==20.1.0 # https://github.com/benoitc/gunicorn
在生产中,我运行
$ pip-sync requirements.txt prod-requirements.txt
我的问题是如何强制执行最低版本的python?我只想设置到次要的python版本。这意味着我想要一种固定到python 3.8的方法。
我可以用pip工具做到这一点吗?我需要选择setup.py方法吗?
我更喜欢只根据要求来做。方法是我最熟悉的
据我所知,您不能通过requirements.txt
文件指定Python解释器版本的约束。
其他工具允许在Python解释器上指定版本说明符。
例如,通过Requires-Python
封装核心元数据字段,我所知道的所有Python封装构建后端都支持该字段,包括通过其python_requires
参数的setuptools,以及flit、hatch和pdm以及诗歌等等。其中一些依赖于(新的(PEP621标准及其requires-python
字段。
您还可以查看pipenv,如果您对真正的";包装";您的应用程序(即,您不打算构建轮子并将其上传到像PyPI这样的包索引服务器(。