Skip to content

Commit 7ca391f

Browse files
committed
fix the pyproject and build system
1 parent 9e66bba commit 7ca391f

File tree

5 files changed

+63
-54
lines changed

5 files changed

+63
-54
lines changed

.github/workflows/pypi-build-artifacts.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ jobs:
5252
- name: Set version with RC
5353
env:
5454
VERSION: ${{ inputs.VERSION }}
55-
run: python -m uv version "${{ env.VERSION }}"
55+
run: uv version "${{ env.VERSION }}"
5656

5757
# Publish the source distribution with the version that's in
5858
# the repository, otherwise the tests will fail
5959
- name: Compile source distribution
60-
run: uv build --sdist --wheel
60+
run: uv build --sdist
6161
if: startsWith(matrix.os, 'ubuntu')
6262

6363
- name: Build wheels

.github/workflows/svn-build-artifacts.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
# Publish the source distribution with the version that's in
5353
# the repository, otherwise the tests will fail
5454
- name: Compile source distribution
55-
run: uv build --sdist --wheel
55+
run: uv build --sdist
5656
if: startsWith(matrix.os, 'ubuntu')
5757

5858
- name: Build wheels

build-module.py

Lines changed: 43 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -18,54 +18,58 @@
1818
import os
1919
import shutil
2020
from pathlib import Path
21+
from typing import Any
2122

22-
allowed_to_fail = os.environ.get("CIBUILDWHEEL", "0") != "1"
23+
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
2324

25+
allowed_to_fail = os.environ.get("CIBUILDWHEEL", "0") != "1"
2426

25-
def build_cython_extensions() -> None:
26-
import Cython.Compiler.Options
27-
from Cython.Build import build_ext, cythonize
28-
from setuptools import Extension
29-
from setuptools.dist import Distribution
3027

31-
Cython.Compiler.Options.annotate = True
28+
class CythonBuildHook(BuildHookInterface):
29+
def build_cython_extensions(self) -> None:
30+
import Cython.Compiler.Options
31+
from Cython.Build import build_ext, cythonize
32+
from setuptools import Extension
33+
from setuptools.dist import Distribution
3234

33-
if os.name == "nt": # Windows
34-
extra_compile_args = [
35-
"/O2",
36-
]
37-
else: # UNIX-based systems
38-
extra_compile_args = [
39-
"-O3",
40-
]
35+
Cython.Compiler.Options.annotate = True
4136

42-
package_path = "pyiceberg"
37+
if os.name == "nt": # Windows
38+
extra_compile_args = [
39+
"/O2",
40+
]
41+
else: # UNIX-based systems
42+
extra_compile_args = [
43+
"-O3",
44+
]
4345

44-
extension = Extension(
45-
# Your .pyx file will be available to cpython at this location.
46-
name="pyiceberg.avro.decoder_fast",
47-
sources=[
48-
os.path.join(package_path, "avro", "decoder_fast.pyx"),
49-
],
50-
extra_compile_args=extra_compile_args,
51-
language="c",
52-
)
46+
package_path = "pyiceberg"
5347

54-
ext_modules = cythonize([extension], include_path=list(package_path), language_level=3, annotate=True)
55-
dist = Distribution({"ext_modules": ext_modules})
56-
cmd = build_ext(dist)
57-
cmd.ensure_finalized()
48+
extension = Extension(
49+
# Your .pyx file will be available to cpython at this location.
50+
name="pyiceberg.avro.decoder_fast",
51+
sources=[
52+
os.path.join(package_path, "avro", "decoder_fast.pyx"),
53+
],
54+
extra_compile_args=extra_compile_args,
55+
language="c",
56+
)
5857

59-
cmd.run()
58+
ext_modules = cythonize([extension], include_path=list(package_path), language_level=3, annotate=True)
59+
dist = Distribution({"ext_modules": ext_modules})
60+
cmd = build_ext(dist)
61+
cmd.ensure_finalized()
6062

61-
for output in cmd.get_outputs():
62-
output = Path(output)
63-
relative_extension = output.relative_to(cmd.build_lib)
64-
shutil.copyfile(output, relative_extension)
63+
cmd.run()
6564

65+
for output in cmd.get_outputs():
66+
output = Path(output)
67+
relative_extension = output.relative_to(cmd.build_lib)
68+
shutil.copyfile(output, relative_extension)
6669

67-
try:
68-
build_cython_extensions()
69-
except Exception:
70-
if not allowed_to_fail:
71-
raise
70+
def initialize(self, version: str, build_data: dict[str, Any]) -> None:
71+
try:
72+
self.build_cython_extensions()
73+
except Exception:
74+
if not allowed_to_fail:
75+
raise

pyproject.toml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,14 @@ dependencies = [
3636
"click>=7.1.1,<9.0.0",
3737
"rich>=10.11.0,<15.0.0",
3838
"strictyaml>=1.7.0,<2.0.0", # CVE-2020-14343 was fixed in 5.4.
39-
"pydantic>=2.0,<3.0,!=2.4.0,!=2.4.1,<2.12.0", # 2.4.0, 2.4.1, 2.12.0 has a critical bug
39+
"pydantic>=2.0,!=2.4.0,!=2.4.1,<2.12.0", # 2.4.0, 2.4.1, 2.12.0 has a critical bug
4040
"sortedcontainers==2.4.0",
4141
"fsspec>=2023.1.0",
4242
"pyparsing>=3.1.0,<4.0.0",
4343
"tenacity>=8.2.3,<10.0.0",
4444
"pyroaring>=1.0.0,<2.0.0",
4545
"cachetools>=5.5,<7.0",
46+
"zstandard>=0.13.0,<1.0.0"
4647
]
4748

4849
[project.optional-dependencies]
@@ -78,7 +79,6 @@ glue = ["boto3>=1.24.59"]
7879
adlfs = ["adlfs>=2024.7.0"]
7980
dynamodb = ["boto3>=1.24.59"]
8081
bigquery = ["google-cloud-bigquery>=3.33.0,<4"]
81-
zstandard = ["zstandard>=0.13.0,<1.0.0"]
8282
sql-postgres = [
8383
"sqlalchemy>=2.0.18,<3",
8484
"psycopg2-binary>=2.9.6",
@@ -148,7 +148,7 @@ include = [
148148
"Makefile",
149149
"NOTICE",
150150
"dev",
151-
"uv.lock",
151+
"build-module.py"
152152
]
153153

154154
[tool.hatch.build.targets.wheel]
@@ -165,8 +165,11 @@ include = [
165165
"vendor/fb303" = "fb303"
166166
"vendor/hive_metastore" = "hive_metastore"
167167

168+
[tool.hatch.build.hooks.custom]
169+
path = "build-module.py"
170+
168171
[build-system]
169-
requires = ["hatchling"]
172+
requires = ["hatchling", "Cython>=3.0.0", "setuptools", "wheel"]
170173
build-backend = "hatchling.build"
171174

172175
[[tool.mypy.overrides]]
@@ -329,6 +332,10 @@ ignore_missing_imports = true
329332
module = "setuptools.*"
330333
ignore_missing_imports = true
331334

335+
[[tool.mypy.overrides]]
336+
module = "hatchling.*"
337+
ignore_missing_imports = true
338+
332339
[[tool.mypy.overrides]]
333340
module = "tenacity.*"
334341
ignore_missing_imports = true

uv.lock

Lines changed: 6 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)