@@ -37,32 +37,39 @@ index 625e474..e3ad221 100644
37
37
dbg_macro = "warn"
38
38
diff --git a/build_backend.py b/build_backend.py
39
39
new file mode 100644
40
- index 0000000..4576d33
40
+ index 0000000..471610f
41
41
--- /dev/null
42
42
+++ b/build_backend.py
43
- @@ -0,0 +1,23 @@
43
+ @@ -0,0 +1,30 @@
44
44
+ import maturin
45
45
+ import os
46
46
+ import shutil
47
47
+ import subprocess
48
+ + import tarfile
49
+ +
50
+ + from pathlib import Path
51
+ + from urllib.request import urlopen
48
52
+
49
53
+ build_sdist = maturin.build_sdist
50
54
+
55
+ +
56
+ + def get_crate_and_patch(namespace, name, version, patched_crates):
57
+ + with (
58
+ + urlopen(f'https://github.com/{namespace}/{name}/archive/refs/tags/v{version}.tar.gz') as f,
59
+ + tarfile.open(fileobj=f, mode='r:gz') as tar,
60
+ + ):
61
+ + tar.extractall(patched_crates, filter='data')
62
+ + crate = patched_crates / f'{name}-{version}'
63
+ + crate = crate.rename(patched_crates / name)
64
+ + subprocess.check_call(['patch', '-p1', '-d', str(crate), '-i', str((Path('patches') / f'{name}.patch').absolute())])
65
+ +
66
+ +
51
67
+ def build_wheel(wheel_directory, config_settings=None, metadata_directory=None):
52
- + shutil.rmtree('patched_crates', ignore_errors=True)
53
- + os.makedirs('patched_crates')
54
- + subprocess.check_call([
55
- + 'git', 'clone', 'https://github.com/PyO3/pyo3.git',
56
- + 'patched_crates/pyo3',
57
- + '--branch', 'v0.22.5',
58
- + ])
59
- + subprocess.check_call(['patch', '-p1', '-d', 'patched_crates/pyo3', '-i', '../../patches/pyo3.patch'])
60
- + subprocess.check_call([
61
- + 'git', 'clone', 'https://github.com/pydantic/jiter.git',
62
- + 'patched_crates/jiter',
63
- + '--branch', 'v0.7.0',
64
- + ])
65
- + subprocess.check_call(['patch', '-p1', '-d', 'patched_crates/jiter', '-i', '../../patches/jiter.patch'])
68
+ + patched_crates = Path('patched_crates')
69
+ + shutil.rmtree(patched_crates, ignore_errors=True)
70
+ + patched_crates.mkdir()
71
+ + get_crate_and_patch('PyO3', 'pyo3', '0.22.5', patched_crates)
72
+ + get_crate_and_patch('pydantic', 'jiter', '0.7.0', patched_crates)
66
73
+ return maturin.build_wheel(wheel_directory, config_settings, metadata_directory)
67
74
diff --git a/patches/jiter.patch b/patches/jiter.patch
68
75
new file mode 100644
0 commit comments