[GR-76114] Use new delvewheel replace-needed command · steve-s/graalpython@ebc2608 · GitHub
Skip to content

Commit ebc2608

Browse files
committed
[GR-76114] Use new delvewheel replace-needed command
PullRequest: graalpython/4589
2 parents 1d10b14 + dd0599c commit ebc2608

4 files changed

Lines changed: 24 additions & 39 deletions

File tree

‎ci.jsonnet‎

Lines changed: 2 additions & 2 deletions

‎graalpython/com.oracle.graal.python.test.integration/src/com/oracle/graal/python/test/integration/advanced/NativeExtTest.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
* because we cannot create multiple contexts that would load native extensions.
6262
*/
6363
public class NativeExtTest {
64-
private static final String DELVEWHEEL_VERSION = "1.9.0";
64+
private static final String DELVEWHEEL_VERSION = "1.13.0";
6565

6666
@BeforeClass
6767
public static void setUpClass() {
@@ -133,7 +133,7 @@ public void testMissingDelvewheelError() throws IOException {
133133
Value exception = ex.getGuestObject();
134134
Assert.assertTrue(exception.isException());
135135
Assert.assertEquals(ex.getMessage(), "SystemError", exception.getMetaObject().getMetaSimpleName());
136-
Assert.assertTrue(ex.getMessage(), ex.getMessage().contains("delvewheel==" + DELVEWHEEL_VERSION));
136+
Assert.assertTrue(ex.getMessage(), ex.getMessage().contains("delvewheel>=" + DELVEWHEEL_VERSION));
137137
}
138138
} finally {
139139
Files.deleteIfExists(tempDir);

‎graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/copying/PEFile.java‎

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@
5151
import com.oracle.truffle.api.TruffleFile;
5252

5353
final class PEFile extends SharedObject {
54-
private static final String DELVEWHEEL_VERSION = "1.9.0";
55-
private static final String DELVEWHEEL_INSTALL_INSTRUCTION = "IsolateNativeModules option needs `delvewheel` tool to copy libraries. Make sure you have `delvewheel==" + DELVEWHEEL_VERSION +
54+
private static final String DELVEWHEEL_VERSION = "1.13.0";
55+
private static final String DELVEWHEEL_INSTALL_INSTRUCTION = "IsolateNativeModules option needs `delvewheel` tool to copy libraries. Make sure you have `delvewheel>=" + DELVEWHEEL_VERSION +
5656
"` available in the virtualenv or on PATH (needs environment access).";
5757

5858
private final PythonContext context;
@@ -79,7 +79,7 @@ public void setId(String newId) {
7979
// TODO
8080
}
8181

82-
private String getDelvewheelPython() throws NativeLibraryToolException {
82+
private String getDelvewheel() throws NativeLibraryToolException {
8383
TruffleFile delvewheel = which(context, "delvewheel.exe");
8484
if (!delvewheel.exists()) {
8585
delvewheel = which(context, "delvewheel.bat");
@@ -90,38 +90,17 @@ private String getDelvewheelPython() throws NativeLibraryToolException {
9090
if (!delvewheel.exists()) {
9191
throw new NativeLibraryToolException("Could not find `delvewheel`. " + DELVEWHEEL_INSTALL_INSTRUCTION);
9292
}
93-
TruffleFile python = delvewheel.resolveSibling("python.exe");
94-
if (!python.exists()) {
95-
python = delvewheel.resolveSibling("python.bat");
96-
}
97-
if (!python.exists()) {
98-
python = delvewheel.resolveSibling("python.cmd");
99-
}
100-
if (!python.exists()) {
101-
python = delvewheel.getParent().resolveSibling("python.exe");
102-
}
103-
if (!python.exists()) {
104-
python = delvewheel.getParent().resolveSibling("python.bat");
105-
}
106-
if (!python.exists()) {
107-
python = delvewheel.getParent().resolveSibling("python.cmd");
108-
}
109-
if (!python.exists()) {
110-
throw new NativeLibraryToolException("Could not find Python executable next to `delvewheel` at '" + delvewheel + "'. " + DELVEWHEEL_INSTALL_INSTRUCTION);
111-
}
112-
return python.toString();
93+
return delvewheel.toString();
11394
}
11495

11596
@Override
11697
public void changeOrAddDependency(String oldName, String newName) throws NativeLibraryToolException {
11798
var pb = newProcessBuilder(context);
11899
var stderr = new ByteArrayOutputStream();
119100
pb.redirectError(pb.createRedirectToStream(stderr));
120-
var tempfileWithForwardSlashes = tempfile.toString().replace('\\', '/');
121-
String pythonExe = getDelvewheelPython();
122-
pb.command(pythonExe, "-c",
123-
String.format("from delvewheel import _dll_utils; _dll_utils.replace_needed('%s', ['%s'], {'%s': '%s'}, strip=True, verbose=2, test=[])",
124-
tempfileWithForwardSlashes, oldName, oldName, newName));
101+
String delvewheel = getDelvewheel();
102+
pb.command(delvewheel, "replace-needed", "-v", "-v", "--strip", "-change", oldName, newName,
103+
tempfile.toString());
125104
Process proc;
126105
try {
127106
proc = pb.start();

‎mx.graalpython/mx_graalpython.py‎

Lines changed: 13 additions & 7 deletions

0 commit comments

Comments
 (0)