Setuptools 和 pyproject.toml 无法识别包的位置

问题描述 投票:0回答:0

我正在尝试使用 PEP 推荐的 Setuptools 包来打包我的代码(希望将来能够发布)。推荐根据包的具体结构使用pyproject.toml文件,如下所示

project_root
├── LICENSE.md
├── README.md
├── VulcanSportsCLIenv
│   └── pyvenv.cfg
├── pyproject.toml
├── requirements.txt
├── src
│   └── VulcanSports
│       ├── VulcanSports_CLI.py
│       ├── __init__.py
│       └── __main__.py
└── tests
    └── __init__.py

#pyproject.toml

[build-system]
requires = ["setuptools>=67.0", "setuptools-scm"]
build-backend = "setuptools.build_meta"

[project]
name = "VulcanSports"
version = "0.0.1"
authors = [
    {name = "Abe Mankavil", email = "[email protected]"},
]
description = "Command line interface for quick access to sports scores and odds"
readme = "README.md"
requires-python = ">=3.8"
classifiers = [
    "Development Status :: 1 - Planning",
    "Programming Language :: Python :: 3",
    "License :: OSI Approved :: GNU General Public License v3 (GPLv3)"
]
dependencies = [
    "requests"
]
keywords = ['Vulcan','Sports']

[tool.setuptools.packages.find]
#include = ["VulcanSports/*.py"]  
exclude = ["/VulcanSportsCLIenv"]
namespaces = false


我唯一要打包分发的就是src文件的内容。在 pyproject.toml 文件所在的

python -m pip install .
目录中运行命令
 project_root
后,构建工作正常,但是在目录外运行
python VulcanSports
时,它找不到包并返回错误:

/Users/abemankavil/Desktop/VulcanSportsProject/VulcanSports-CLI/VulcanSportsCLIenv/bin/python: can't open file '/Users/abemankavil/Desktop/VulcanSportsProject/VulcanSports-CLI/VulcanSports': [Errno 2] No such file or directory

我似乎无法弄清楚为什么即使出现在

pip list
下也找不到包裹。这是我的目录结构有问题还是 pyproject.toml 文件有问题?

python package setuptools pypi pyproject.toml
© www.soinside.com 2019 - 2024. All rights reserved.