Skip to content

Commit 6a591dc

Browse files
committed
[GR-48735] Autopatch common Rust extensions
PullRequest: graalpython/2982
2 parents 292af19 + 3f20852 commit 6a591dc

File tree

15 files changed

+794
-5
lines changed

15 files changed

+794
-5
lines changed

graalpython/com.oracle.graal.python.cext/include/sliceobject.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ typedef struct {
2929
PyObject_HEAD
3030
PyObject *start, *stop, *step; /* not NULL */
3131
} PySliceObject;
32+
33+
// functions introduced by GraalPy as replacements for direct access to the slice struct fields
34+
PyAPI_FUNC(PyObject*) PySlice_Start(PySliceObject *slice);
35+
PyAPI_FUNC(PyObject*) PySlice_Stop(PySliceObject *slice);
36+
PyAPI_FUNC(PyObject*) PySlice_Step(PySliceObject *slice);
3237
#endif
3338

3439
PyAPI_DATA(PyTypeObject) PySlice_Type;
@@ -58,9 +63,6 @@ PyAPI_FUNC(int) PySlice_GetIndicesEx(PyObject *r, Py_ssize_t length,
5863
((*(slicelen) = 0), -1) : \
5964
((*(slicelen) = PySlice_AdjustIndices((length), (start), (stop), *(step))), \
6065
0))
61-
PyAPI_FUNC(PyObject*) PySlice_Start(PySliceObject *slice);
62-
PyAPI_FUNC(PyObject*) PySlice_Stop(PySliceObject *slice);
63-
PyAPI_FUNC(PyObject*) PySlice_Step(PySliceObject *slice);
6466
PyAPI_FUNC(int) PySlice_Unpack(PyObject *slice,
6567
Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step);
6668
PyAPI_FUNC(Py_ssize_t) PySlice_AdjustIndices(Py_ssize_t length,

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextErrBuiltins.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ Object newEx(TruffleString name, Object base, Object dict,
388388
abstract static class PyErr_NewExceptionWithDoc extends CApiQuaternaryBuiltinNode {
389389

390390
@Specialization
391-
Object raise(TruffleString name, TruffleString doc, Object base, Object dict,
391+
Object raise(TruffleString name, Object doc, Object base, Object dict,
392392
@Cached PyErr_NewException newExNode,
393393
@Cached WriteAttributeToObjectNode writeAtrrNode) {
394394
if (base == PNone.NO_VALUE) {
@@ -398,7 +398,9 @@ Object raise(TruffleString name, TruffleString doc, Object base, Object dict,
398398
dict = factory().createDict();
399399
}
400400
Object ex = newExNode.execute(name, base, dict);
401-
writeAtrrNode.execute(ex, T___DOC__, doc);
401+
if (doc != PNone.NO_VALUE) {
402+
writeAtrrNode.execute(ex, T___DOC__, doc);
403+
}
402404
return ex;
403405
}
404406
}
Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
From b980fb68c36c14438d216fe63e5643aab19cbea0 Mon Sep 17 00:00:00 2001
2+
From: Tim Felgentreff <tim.felgentreff@oracle.com>
3+
Date: Tue, 19 Sep 2023 03:50:15 +0200
4+
Subject: [PATCH] graalpy support
5+
6+
---
7+
setup.py | 2 +-
8+
src/_bcrypt/Cargo.lock | 96 +++++++++++++++++-------------------------
9+
src/_bcrypt/Cargo.toml | 2 +-
10+
3 files changed, 40 insertions(+), 60 deletions(-)
11+
12+
diff --git a/setup.py b/setup.py
13+
index dab1d7d..ddc5f77 100644
14+
--- a/setup.py
15+
+++ b/setup.py
16+
@@ -41,7 +41,7 @@ try:
17+
# Enable abi3 mode if we're not using PyPy.
18+
features=(
19+
[]
20+
- if platform.python_implementation() == "PyPy"
21+
+ if platform.python_implementation() in ["PyPy", "GraalVM"]
22+
else ["pyo3/abi3-py36"]
23+
),
24+
rust_version=">=1.56.0",
25+
diff --git a/src/_bcrypt/Cargo.lock b/src/_bcrypt/Cargo.lock
26+
index 404be82..dfd7ecc 100644
27+
--- a/src/_bcrypt/Cargo.lock
28+
+++ b/src/_bcrypt/Cargo.lock
29+
@@ -147,26 +147,9 @@ dependencies = [
30+
31+
[[package]]
32+
name = "indoc"
33+
-version = "0.3.6"
34+
+version = "1.0.9"
35+
source = "registry+https://github.com/rust-lang/crates.io-index"
36+
-checksum = "47741a8bc60fb26eb8d6e0238bbb26d8575ff623fdc97b1a2c00c050b9684ed8"
37+
-dependencies = [
38+
- "indoc-impl",
39+
- "proc-macro-hack",
40+
-]
41+
-
42+
-[[package]]
43+
-name = "indoc-impl"
44+
-version = "0.3.6"
45+
-source = "registry+https://github.com/rust-lang/crates.io-index"
46+
-checksum = "ce046d161f000fffde5f432a0d034d0341dc152643b2598ed5bfce44c4f3a8f0"
47+
-dependencies = [
48+
- "proc-macro-hack",
49+
- "proc-macro2",
50+
- "quote",
51+
- "syn",
52+
- "unindent",
53+
-]
54+
+checksum = "bfa799dd5ed20a7e349f3b4639aa80d74549c81716d9ec4f994c9b5815598306"
55+
56+
[[package]]
57+
name = "inout"
58+
@@ -202,6 +185,15 @@ dependencies = [
59+
"scopeguard",
60+
]
61+
62+
+[[package]]
63+
+name = "memoffset"
64+
+version = "0.6.5"
65+
+source = "registry+https://github.com/rust-lang/crates.io-index"
66+
+checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce"
67+
+dependencies = [
68+
+ "autocfg",
69+
+]
70+
+
71+
[[package]]
72+
name = "once_cell"
73+
version = "1.15.0"
74+
@@ -233,25 +225,6 @@ dependencies = [
75+
"winapi",
76+
]
77+
78+
-[[package]]
79+
-name = "paste"
80+
-version = "0.1.18"
81+
-source = "registry+https://github.com/rust-lang/crates.io-index"
82+
-checksum = "45ca20c77d80be666aef2b45486da86238fabe33e38306bd3118fe4af33fa880"
83+
-dependencies = [
84+
- "paste-impl",
85+
- "proc-macro-hack",
86+
-]
87+
-
88+
-[[package]]
89+
-name = "paste-impl"
90+
-version = "0.1.18"
91+
-source = "registry+https://github.com/rust-lang/crates.io-index"
92+
-checksum = "d95a7db200b97ef370c8e6de0088252f7e0dfff7d047a28528e47456c0fc98b6"
93+
-dependencies = [
94+
- "proc-macro-hack",
95+
-]
96+
-
97+
[[package]]
98+
name = "pbkdf2"
99+
version = "0.10.1"
100+
@@ -261,12 +234,6 @@ dependencies = [
101+
"digest",
102+
]
103+
104+
-[[package]]
105+
-name = "proc-macro-hack"
106+
-version = "0.5.19"
107+
-source = "registry+https://github.com/rust-lang/crates.io-index"
108+
-checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5"
109+
-
110+
[[package]]
111+
name = "proc-macro2"
112+
version = "1.0.46"
113+
@@ -278,35 +245,44 @@ dependencies = [
114+
115+
[[package]]
116+
name = "pyo3"
117+
-version = "0.15.2"
118+
-source = "registry+https://github.com/rust-lang/crates.io-index"
119+
-checksum = "d41d50a7271e08c7c8a54cd24af5d62f73ee3a6f6a314215281ebdec421d5752"
120+
+version = "0.17.3"
121+
+source = "git+https://github.com/timfel/pyo3.git?branch=v0.17.3.graalpy#33c0f0dbd9a736dd2f8b896445239478d9da219c"
122+
dependencies = [
123+
"cfg-if",
124+
"indoc",
125+
"libc",
126+
+ "memoffset",
127+
"parking_lot",
128+
- "paste",
129+
"pyo3-build-config",
130+
+ "pyo3-ffi",
131+
"pyo3-macros",
132+
"unindent",
133+
]
134+
135+
[[package]]
136+
name = "pyo3-build-config"
137+
-version = "0.15.2"
138+
-source = "registry+https://github.com/rust-lang/crates.io-index"
139+
-checksum = "779239fc40b8e18bc8416d3a37d280ca9b9fb04bda54b98037bb6748595c2410"
140+
+version = "0.17.3"
141+
+source = "git+https://github.com/timfel/pyo3.git?branch=v0.17.3.graalpy#33c0f0dbd9a736dd2f8b896445239478d9da219c"
142+
dependencies = [
143+
"once_cell",
144+
+ "target-lexicon",
145+
+]
146+
+
147+
+[[package]]
148+
+name = "pyo3-ffi"
149+
+version = "0.17.3"
150+
+source = "git+https://github.com/timfel/pyo3.git?branch=v0.17.3.graalpy#33c0f0dbd9a736dd2f8b896445239478d9da219c"
151+
+dependencies = [
152+
+ "libc",
153+
+ "pyo3-build-config",
154+
]
155+
156+
[[package]]
157+
name = "pyo3-macros"
158+
-version = "0.15.2"
159+
-source = "registry+https://github.com/rust-lang/crates.io-index"
160+
-checksum = "00b247e8c664be87998d8628e86f282c25066165f1f8dda66100c48202fdb93a"
161+
+version = "0.17.3"
162+
+source = "git+https://github.com/timfel/pyo3.git?branch=v0.17.3.graalpy#33c0f0dbd9a736dd2f8b896445239478d9da219c"
163+
dependencies = [
164+
+ "proc-macro2",
165+
"pyo3-macros-backend",
166+
"quote",
167+
"syn",
168+
@@ -314,12 +290,10 @@ dependencies = [
169+
170+
[[package]]
171+
name = "pyo3-macros-backend"
172+
-version = "0.15.2"
173+
-source = "registry+https://github.com/rust-lang/crates.io-index"
174+
-checksum = "5a8c2812c412e00e641d99eeb79dd478317d981d938aa60325dfa7157b607095"
175+
+version = "0.17.3"
176+
+source = "git+https://github.com/timfel/pyo3.git?branch=v0.17.3.graalpy#33c0f0dbd9a736dd2f8b896445239478d9da219c"
177+
dependencies = [
178+
"proc-macro2",
179+
- "pyo3-build-config",
180+
"quote",
181+
"syn",
182+
]
183+
@@ -382,6 +356,12 @@ dependencies = [
184+
"unicode-ident",
185+
]
186+
187+
+[[package]]
188+
+name = "target-lexicon"
189+
+version = "0.12.11"
190+
+source = "registry+https://github.com/rust-lang/crates.io-index"
191+
+checksum = "9d0e916b1148c8e263850e1ebcbd046f333e0683c724876bb0da63ea4373dc8a"
192+
+
193+
[[package]]
194+
name = "typenum"
195+
version = "1.15.0"
196+
diff --git a/src/_bcrypt/Cargo.toml b/src/_bcrypt/Cargo.toml
197+
index 6c75126..d7970fd 100644
198+
--- a/src/_bcrypt/Cargo.toml
199+
+++ b/src/_bcrypt/Cargo.toml
200+
@@ -6,7 +6,7 @@ edition = "2018"
201+
publish = false
202+
203+
[dependencies]
204+
-pyo3 = { version = "0.15.2" }
205+
+pyo3 = { git = "https://github.com/timfel/pyo3.git", branch = "v0.17.3.graalpy", optional = true }
206+
bcrypt = "0.13"
207+
bcrypt-pbkdf = "0.8.1"
208+
base64 = "0.13.0"
209+
--
210+
2.34.1
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[[rules]]
2+
version = '== 4.0.1'
3+
patch = 'bcrypt-4.0.1.patch'
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
From 564f9fe0b947840da14bf59c1bb0c72c0816dd17 Mon Sep 17 00:00:00 2001
2+
From: Tim Felgentreff <tim.felgentreff@oracle.com>
3+
Date: Tue, 19 Sep 2023 06:31:59 +0200
4+
Subject: [PATCH] graalpy pyo3
5+
6+
---
7+
Cargo.lock | 15 +++++----------
8+
Cargo.toml | 2 +-
9+
2 files changed, 6 insertions(+), 11 deletions(-)
10+
11+
diff --git a/Cargo.lock b/Cargo.lock
12+
index 645c5b4..001fe06 100644
13+
--- a/Cargo.lock
14+
+++ b/Cargo.lock
15+
@@ -407,8 +407,7 @@ dependencies = [
16+
[[package]]
17+
name = "pyo3"
18+
version = "0.18.1"
19+
-source = "registry+https://github.com/rust-lang/crates.io-index"
20+
-checksum = "06a3d8e8a46ab2738109347433cb7b96dffda2e4a218b03ef27090238886b147"
21+
+source = "git+https://github.com/timfel/pyo3.git?branch=v0.18.1.graalpy#2d2b3532c28738f9b1355c47d9b69f53540283d7"
22+
dependencies = [
23+
"cfg-if",
24+
"indoc",
25+
@@ -424,8 +423,7 @@ dependencies = [
26+
[[package]]
27+
name = "pyo3-build-config"
28+
version = "0.18.1"
29+
-source = "registry+https://github.com/rust-lang/crates.io-index"
30+
-checksum = "75439f995d07ddfad42b192dfcf3bc66a7ecfd8b4a1f5f6f046aa5c2c5d7677d"
31+
+source = "git+https://github.com/timfel/pyo3.git?branch=v0.18.1.graalpy#2d2b3532c28738f9b1355c47d9b69f53540283d7"
32+
dependencies = [
33+
"once_cell",
34+
"target-lexicon",
35+
@@ -434,8 +432,7 @@ dependencies = [
36+
[[package]]
37+
name = "pyo3-ffi"
38+
version = "0.18.1"
39+
-source = "registry+https://github.com/rust-lang/crates.io-index"
40+
-checksum = "839526a5c07a17ff44823679b68add4a58004de00512a95b6c1c98a6dcac0ee5"
41+
+source = "git+https://github.com/timfel/pyo3.git?branch=v0.18.1.graalpy#2d2b3532c28738f9b1355c47d9b69f53540283d7"
42+
dependencies = [
43+
"libc",
44+
"pyo3-build-config",
45+
@@ -444,8 +441,7 @@ dependencies = [
46+
[[package]]
47+
name = "pyo3-macros"
48+
version = "0.18.1"
49+
-source = "registry+https://github.com/rust-lang/crates.io-index"
50+
-checksum = "bd44cf207476c6a9760c4653559be4f206efafb924d3e4cbf2721475fc0d6cc5"
51+
+source = "git+https://github.com/timfel/pyo3.git?branch=v0.18.1.graalpy#2d2b3532c28738f9b1355c47d9b69f53540283d7"
52+
dependencies = [
53+
"proc-macro2",
54+
"pyo3-macros-backend",
55+
@@ -456,8 +452,7 @@ dependencies = [
56+
[[package]]
57+
name = "pyo3-macros-backend"
58+
version = "0.18.1"
59+
-source = "registry+https://github.com/rust-lang/crates.io-index"
60+
-checksum = "dc1f43d8e30460f36350d18631ccf85ded64c059829208fe680904c65bcd0a4c"
61+
+source = "git+https://github.com/timfel/pyo3.git?branch=v0.18.1.graalpy#2d2b3532c28738f9b1355c47d9b69f53540283d7"
62+
dependencies = [
63+
"proc-macro2",
64+
"quote",
65+
diff --git a/Cargo.toml b/Cargo.toml
66+
index dda5041..67963e0 100644
67+
--- a/Cargo.toml
68+
+++ b/Cargo.toml
69+
@@ -18,5 +18,5 @@ extension-module = ["pyo3/extension-module"]
70+
71+
72+
[dependencies]
73+
-pyo3 = { version = "^0.18", default-features = false, features = ["macros"] }
74+
+pyo3 = { git = "https://github.com/timfel/pyo3.git", branch = "v0.18.1.graalpy", default-features = false, features = ["macros"] }
75+
libcramjam = { path = "local_dependencies/libcramjam" }
76+
--
77+
2.34.1
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[[rules]]
2+
version = '== 2.7.0'
3+
patch = 'cramjam-2.7.0.patch'

0 commit comments

Comments
 (0)