问题描述
我正在打包一个具有以下目录结构的 python 项目:
toingpkg/
src/
subtoingpkg1/
subsubtoingpkg1/
...
__init__.py
__init__.py
subtoingpkg2/
...
subtoingpkg2.py
__init__.py
toingpkg.py
__init__.py
setup.cfg
pyproject.toml
我的 setup.cfg 如下:
[Metadata]
name = toingpkg
...
classifiers =
Programming Language :: Python :: 3
...
[options]
package_dir =
= src
packages = find_namespace:
python_requires = >=3.6
install_requires =
requests
pytz
[options.packages.find]
where=src
而我的 pyproject.toml 如下:
[build-system]
requires = [
"setuptools>=42","wheel"
]
build-backend = "setuptools.build_Meta"
当我使用 docs 中提到的 python3 -m build
构建我的包时,我的 dist 文件夹中有一个 whl 文件,但它不包含 src
根目录中的文件目录。
因此,当我执行 pip3 install dist/toingpackage-xxx-.whl
时,该软件包已安装(显示在 pip3 列表中)但我无法执行:
>>> import toingpkg
我明白了:
回溯(最近一次调用最后一次):文件“”,第 1 行,在 ModuleNotFoundError: 没有名为“toingpkg”的模块
我也尝试手动指定所有子包,但得到了相同的结果。我的python环境是3.8.5,setuptools 45.2.0。
我做错了什么?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)