问题描述
我正在尝试创建一个 Python 包。我有一个包含此部分的 setup.cfg
:
install_requires =
pyo>=1.0.4
pywebview>=3.4
strictyaml>=1.4.4
当我在项目目录中运行 python3 -m build
时,我得到了预期的 dist/mypackage.whl
。当我切换到另一个虚拟环境以测试使用 pip install mypackage.whl
安装它时,这也有效;但是,它不会安装依赖项。实际上,.whl 文件中根本没有提到依赖项,因为我使用
unzip -c mypackage.whl 'mypackage.dist-info/*' | grep pyo
没有提出任何问题。
依赖信息是否应该包含在轮子中? This SO post 会这么建议。如果不是,这就是 requirements.txt
的用途吗?
编辑:这是我的完整 setup.cfg 和软件包版本信息:
[Metadata]
name = mypackage
version = 0.1
author = David Husz
long_description = file: README.md
long_description_content_type = text/markdown
install_requires =
pyo>=1.0.4
pywebview>=3.4
strictyaml>=1.4.4
classifiers =
Programming Language :: Python :: 3
Operating System :: OS Independent
[options]
package_dir =
= src
packages = find:
include_package_data = True
python_requires = >=3.6
[options.packages.find]
where = src
我的 setuptools 版本是 57.4.0,我的构建版本是 0.5.1。
解决方法
install_requires
不是 [metadata]
设置而是 [options]
设置
将其移至 [options]
部分,您应该可以开始使用了!
这是我的一个项目的示例:https://github.com/asottile/setup-cfg-fmt/blob/f7d50142cec2174daeee4a67cebf2d161c0cca46/setup.cfg#L25-L26