我喜欢用
pip install ...
安装我的软件包并使用 pyproject.toml
标准。
我可以指定从 git 安装的依赖项,使用:
dependencies = [
'numpy>=1.21',
'psychopy @ git+https://github.com/psychopy/psychopy',
]
但是我如何指定从不同索引器安装的依赖项,相当于:
python -m pip install --pre --only-binary :all: -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple numpy scipy
有或没有预发布标志?
如何指定从 URL 安装的依赖项,例如https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-22.04/wxPython-4.2.1-cp310-cp310-linux_x86_64.whl 我尝试过但没有运气:
dependencies = [
'wxPython @ https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-22.04/wxPython-4.2.1-cp310-cp310-linux_x86_64.whl; python_version == "3.10"; sys_platform == "linux"'
]
使用Python 3.8.10
点23.3.1
我正在使用 venv。
首先安装或更新您的依赖项。
$ python -m pip install --pre --only-binary :all: -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple numpy scipy
>> Looking in indexes: https://pypi.anaconda.org/scientific-python-nightly-wheels/simple
...
Successfully installed numpy-2.0.0.dev0 scipy-1.12.0.dev0
git 示例:
$ pip install git+https://github.com/psychopy/psychopy
>> Collecting git+https://github.com/psychopy/psychopy
...
Successfully built psychopy esprima future
Installing collected packages: pywin32, pytz, ...
冻结所有依赖项:
$ pip freeze > requirements.txt
现在您项目的所有库和依赖项都列在requirements.txt文件中。
假设您正在使用SetupTools,我将执行 pyproject.toml:
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
[project]
name = "project"
version = "0.0.1"
dynamic = ["dependencies"]
[tool.setuptools.dynamic]
dependencies = {file = "requirements.txt"}
这就是您所需要的,我所做的测试与您订购的产品完美配合。我希望我能够帮助你。