我正在迁移我的库以使用uv来管理包。然而,我的包包含一个通过 CFFI 包装和编译的 C 扩展(有一个用于此的构建脚本)。
下面是
pyproject.toml
的当前版本,无法运行构建脚本,并且,如果我手动构建扩展,uv build --wheel
不会在轮子中包含 _readdbc.so
文件。
[project]
authors = [
{name = "Flavio Codeco Coelho", email = "[email protected]"},
{name = "Sandro Loch", email = "[email protected]"},
]
license = {text = "AGPL-3.0"}
requires-python = "<4,>=3.9"
dependencies = [
"dbfread<3,>=2.0.7",
"tqdm<5,>=4.64.0",
"cffi<2,>=1.15.1",
"pyyaml>=6",
"setuptools>=75.6.0",
]
name = "pyreaddbc"
version = "1.1.0"
description = "pyreaddbc package"
readme = "README.md"
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"Topic :: Software Development :: Libraries :: Python Modules",
"License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
]
[tool.setuptools]
packages = ["pyreaddbc"]
[build-system]
requires = ["setuptools>=61"]
build-backend = "setuptools.build_meta"
[build]
default = ["python", "-m", "./pyreaddbc/_build_readdbc.py"] # this script never runs
[tool.black]
line-length = 79
skip-string-normalization = true
target-version = ["py39", "py310", "py311", "py312"]
exclude = "docs/"
[project.optional-dependencies]
dev = [
"pytest<9.0.0,>=8.1.1",
"pandas<3.0.0,>=2.1.0",
]
[project.urls]
Repository = "https://github.com/AlertaDengue/pyreaddbc"
我错过了什么?
几天后,由于缺乏关于此问题的具体文档,我感到很头疼,这是有效的
pyproject.toml
的最终形式:
[project]
authors = [
{ name = "Flavio Codeco Coelho", email = "[email protected]" },
{ name = "Sandro Loch", email = "[email protected]" },
]
license = { text = "AGPL-3.0" }
requires-python = "<4,>=3.9"
dependencies = [
"dbfread<3,>=2.0.7",
"tqdm<5,>=4.64.0",
"cffi<2,>=1.15.1",
"pyyaml>=6",
"setuptools>=75.6.0",
]
name = "pyreaddbc"
version = "1.2.0"
description = "pyreaddbc package"
readme = "README.md"
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"Topic :: Software Development :: Libraries :: Python Modules",
"License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
]
[tool.setuptools]
py-modules = ["pyreaddbc"]
ext-modules = [
{name = "pyreaddbc._readdbc", sources = ["pyreaddbc/_readdbc.c", "pyreaddbc/c-src/blast.c"], include-dirs = ["pyreaddbc", "pyreaddbc/c-src"]}#, libraries = ["readdbc"], library-dirs = ["pyreaddbc"]},
]
[build-system]
requires = ["setuptools>=61", "cffi"]
build-backend = "setuptools.build_meta"
[build]
default = ["python", "-m", "./pyreaddbc/_build_readdbc.py"]
[tool.black]
line-length = 79
skip-string-normalization = true
target-version = ["py39", "py310", "py311", "py312"]
exclude = "docs/"
[project.optional-dependencies]
dev = [
"pytest<9.0.0,>=8.1.1",
"pandas<3.0.0,>=2.1.0",
]
[project.urls]
Repository = "https://github.com/AlertaDengue/pyreaddbc"
我希望这能帮助其他需要使用 uv 自动化 CFFI 扩展构建的人。