I am migrating a library of mine to use uv to manage the package. My package, however, includes a C extension that is wrapped and compiled through CFFI (there's a build script for this).
Below is the current version of pyproject.toml
that fails to run the build script and, If I build the extension manually, uv build --wheel
does not include the _readdbc.so
file in the wheel.
[project]
authors = [
{name = "Flavio Codeco Coelho", email = "fccoelho@gmail.com"},
{name = "Sandro Loch", email = "es.loch@gmail.com"},
]
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"
What am I missing?
After a few days, bumping my head against the lack of specific documentation about this, here is the final form of a pyproject.toml
that works :
[project]
authors = [
{ name = "Flavio Codeco Coelho", email = "fccoelho@gmail.com" },
{ name = "Sandro Loch", email = "es.loch@gmail.com" },
]
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"
I hope this will help other people needing to automate CFFI extension build using uv.