Skip to content

Commit 6e09b75

Browse files
committed
Provide path and result substitution for GraalPy's SO ABI
1 parent a4dec02 commit 6e09b75

File tree

2 files changed

+32
-12
lines changed

2 files changed

+32
-12
lines changed

mx.graalpython/mx_graalpython.py

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@
8686
SUITE_SULONG = mx.suite("sulong")
8787

8888
GRAAL_VERSION = ".".join(SUITE.suiteDict['version'].split('.')[:2])
89+
GRAAL_VERSION_NODOT = GRAAL_VERSION.replace('.', '')
8990
PYTHON_VERSION = "3.10"
91+
PYTHON_VERSION_NODOT = "3.10".replace('.', '')
9092

9193
GRAALPYTHON_MAIN_CLASS = "com.oracle.graal.python.shell.GraalPythonMain"
9294

@@ -1603,18 +1605,35 @@ def _get_output_root(projectname):
16031605
mx.abort("Could not find out dir for project %s" % projectname)
16041606

16051607

1606-
def py_version_short(*args):
1608+
def py_version_short(variant=None, **kwargs):
1609+
if variant == 'major_minor_nodot':
1610+
return PYTHON_VERSION_NODOT
16071611
return PYTHON_VERSION
16081612

16091613

1610-
def graal_version_short(*args):
1614+
def graal_version_short(variant=None, **kwargs):
1615+
if variant == 'major_minor_nodot':
1616+
return GRAAL_VERSION_NODOT
16111617
return GRAAL_VERSION
16121618

1613-
def graalpy_ext(arg):
1614-
if arg == "soabi":
1615-
# TODO(fa): do properly
1616-
return ".graalpy231-310-native-x86_64-darwin.so"
1617-
raise ValueError("unknown ext type requested: " + arg)
1619+
def graalpy_ext(llvm_mode, **kwargs):
1620+
if not llvm_mode:
1621+
mx.abort("substitution 'graalpy_ext' is missing argument 'llvm_mode'")
1622+
os = mx_subst.path_substitutions.substitute('<os>')
1623+
arch = mx_subst.path_substitutions.substitute('<arch>')
1624+
if arch == 'amd64':
1625+
# be compatible with CPython's designation
1626+
# (see also: 'PythonUtils.getPythonArch')
1627+
arch = 'x86_64'
1628+
1629+
# not ".dylib", similar to CPython:
1630+
# https://github.com/python/cpython/issues/37510
1631+
if os == 'windows':
1632+
ext = 'pyd'
1633+
else:
1634+
ext = 'so'
1635+
1636+
return f'.graalpy{GRAAL_VERSION_NODOT}-{PYTHON_VERSION_NODOT}-{llvm_mode}-{arch}-{os}.{ext}'
16181637

16191638

16201639
mx_subst.path_substitutions.register_with_arg('suite', _get_suite_dir)
@@ -1623,7 +1642,8 @@ def graalpy_ext(arg):
16231642
mx_subst.path_substitutions.register_with_arg('py_ver', py_version_short)
16241643
mx_subst.path_substitutions.register_with_arg('graal_ver', graal_version_short)
16251644

1626-
mx_subst.string_substitutions.register_with_arg('ext', graalpy_ext)
1645+
mx_subst.path_substitutions.register_with_arg('graalpy_ext', graalpy_ext)
1646+
mx_subst.results_substitutions.register_with_arg('graalpy_ext', graalpy_ext)
16271647

16281648

16291649
def delete_self_if_testdownstream(args):

mx.graalpython/suite.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -868,10 +868,10 @@
868868
"./": [
869869
"file:mx.graalpython/native-image.properties",
870870
],
871-
"./lib/python<py_ver:major_minor_nodot>/": [
871+
"./lib/python<py_ver:major_minor>/": [
872872
"extracted-dependency:graalpython:GRAALPYTHON_PYTHON_LIB",
873873
],
874-
"./lib/graalpy<graal_ver:major_minor_nodot>/": [
874+
"./lib/graalpy<graal_ver:major_minor>/": [
875875
"file:graalpython/lib-graalpython/*",
876876
"extracted-dependency:GRAALPYTHON_JNI/*",
877877
{
@@ -892,10 +892,10 @@
892892
},
893893
"dependency:com.oracle.graal.python.hpy.llvm/bin/*",
894894
],
895-
"./lib/graalpy<graal_ver:major_minor_nodot>/modules/graalpy_virtualenv": [
895+
"./lib/graalpy<graal_ver:major_minor>/modules/graalpy_virtualenv": [
896896
"file:graalpy_virtualenv/graalpy_virtualenv",
897897
],
898-
"./include/python<py_ver:major_minor_nodot>/": [
898+
"./include/python<py_ver:major_minor>/": [
899899
"file:graalpython/com.oracle.graal.python.cext/include/*",
900900
"file:graalpython/com.oracle.graal.python.hpy.llvm/include/*",
901901
],

0 commit comments

Comments
 (0)