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
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,10 @@
180180
"linux:aarch64:jdk-latest" : daily + t("01:00:00"),
181181
"darwin:aarch64:jdk-latest" : daily + t("01:00:00"),
182182
}),
183-
"python-unittest-multi-context": gpgate + require(GPY_JVM_STANDALONE) + platform_spec(no_jobs) + platform_spec({
183+
"python-unittest-multi-context": gpgate + require(GPY_NATIVE_STANDALONE) + platform_spec(no_jobs) + platform_spec({
184184
"linux:amd64:jdk-latest" : tier3,
185185
"linux:aarch64:jdk-latest" : daily + t("02:00:00"),
186-
"windows:amd64:jdk-latest" : daily + t("01:30:00"),
186+
"windows:amd64:jdk-latest" : daily + t("02:00:00"),
187187
}),
188188
"python-unittest-jython": gpgate + platform_spec(no_jobs) + platform_spec({
189189
"linux:amd64:jdk21" : daily + t("00:30:00") + require(GPY_JVM21_STANDALONE),

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
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ def _dev_pythonhome():
808808
return os.path.join(SUITE.dir, "graalpython")
809809

810810

811-
def get_path_with_patchelf():
811+
def get_path_with_patchelf(graalpy=None):
812812
path = os.environ.get("PATH", "")
813813
if mx.is_linux() and not shutil.which("patchelf"):
814814
venv = Path(SUITE.get_output_root()).absolute() / "patchelf-venv"
@@ -823,11 +823,17 @@ def get_path_with_patchelf():
823823
venv = Path(SUITE.get_output_root()).absolute() / "delvewheel-venv"
824824
path += os.pathsep + str(venv / "Scripts")
825825
if not shutil.which("delvewheel", path=path):
826-
mx.log(f"{time.strftime('[%H:%M:%S] ')} Building delvewheel-venv with {sys.executable}... [delvewheel not found on PATH]")
826+
if sys.version_info < (3, 12):
827+
if graalpy is None:
828+
graalpy = graalpy_standalone_jvm()
829+
venv_python = [graalpy, "-X", "jit=0"]
830+
else:
831+
venv_python = [sys.executable]
832+
mx.log(f"{time.strftime('[%H:%M:%S] ')} Building delvewheel-venv with {shlex.join(venv_python)}... [delvewheel not found on PATH]")
827833
t0 = time.time()
828-
subprocess.check_call([sys.executable, "-m", "venv", str(venv)])
829-
subprocess.check_call([str(venv / "Scripts" / "pip.exe"), "install", "delvewheel"])
830-
mx.log(f"{time.strftime('[%H:%M:%S] ')} Building delvewheel-venv with {sys.executable}... [duration: {time.time() - t0}]")
834+
subprocess.check_call(venv_python + ["-m", "venv", str(venv)])
835+
subprocess.check_call([str(venv / "Scripts" / "pip.exe"), "install", "delvewheel>=1.13.0"])
836+
mx.log(f"{time.strftime('[%H:%M:%S] ')} Building delvewheel-venv with {shlex.join(venv_python)}... [duration: {time.time() - t0}]")
831837
return path
832838

833839

@@ -1841,8 +1847,8 @@ def graalpython_gate_runner(_, tasks):
18411847
with Task('GraalPython multi-context unittests', tasks, tags=[GraalPythonTags.unittest_multi]) as task:
18421848
if task:
18431849
env = os.environ.copy()
1844-
env['PATH'] = get_path_with_patchelf()
1845-
graalpy = graalpy_standalone_jvm()
1850+
graalpy = graalpy_standalone_native()
1851+
env['PATH'] = get_path_with_patchelf(graalpy)
18461852
mx.log("1. Running twice without shared engine")
18471853
run_python_unittests(
18481854
graalpy,

0 commit comments

Comments
 (0)