Skip to content

Commit ed90d69

Browse files
committed
Avoid git in pydantic-core patch
1 parent 75abe6a commit ed90d69

File tree

2 files changed

+46
-32
lines changed

2 files changed

+46
-32
lines changed

graalpython/lib-graalpython/patches/pydantic-core-2.26.0.patch

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,32 +37,39 @@ index 625e474..e3ad221 100644
3737
dbg_macro = "warn"
3838
diff --git a/build_backend.py b/build_backend.py
3939
new file mode 100644
40-
index 0000000..4576d33
40+
index 0000000..471610f
4141
--- /dev/null
4242
+++ b/build_backend.py
43-
@@ -0,0 +1,23 @@
43+
@@ -0,0 +1,30 @@
4444
+import maturin
4545
+import os
4646
+import shutil
4747
+import subprocess
48+
+import tarfile
49+
+
50+
+from pathlib import Path
51+
+from urllib.request import urlopen
4852
+
4953
+build_sdist = maturin.build_sdist
5054
+
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+
+
5167
+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)
6673
+ return maturin.build_wheel(wheel_directory, config_settings, metadata_directory)
6774
diff --git a/patches/jiter.patch b/patches/jiter.patch
6875
new file mode 100644

graalpython/lib-graalpython/patches/pydantic-core-2.27.1.patch

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,32 +37,39 @@ index 3b3b8a9..718029a 100644
3737
dbg_macro = "warn"
3838
diff --git a/build_backend.py b/build_backend.py
3939
new file mode 100644
40-
index 0000000..bf9c44a
40+
index 0000000..4710e3f
4141
--- /dev/null
4242
+++ b/build_backend.py
43-
@@ -0,0 +1,23 @@
43+
@@ -0,0 +1,30 @@
4444
+import maturin
4545
+import os
4646
+import shutil
4747
+import subprocess
48+
+import tarfile
49+
+
50+
+from pathlib import Path
51+
+from urllib.request import urlopen
4852
+
4953
+build_sdist = maturin.build_sdist
5054
+
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+
+
5167
+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.6',
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.1',
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.6', patched_crates)
72+
+ get_crate_and_patch('pydantic', 'jiter', '0.7.1', patched_crates)
6673
+ return maturin.build_wheel(wheel_directory, config_settings, metadata_directory)
6774
diff --git a/patches/jiter.patch b/patches/jiter.patch
6875
new file mode 100644

0 commit comments

Comments
 (0)