Skip to content

Commit accbf89

Browse files
msimacektimfel
authored andcommitted
[GR-64261] ABI version should not change automatically
PullRequest: graalpython/3756
2 parents 35fc80f + 18e7710 commit accbf89

4 files changed

Lines changed: 14 additions & 18 deletions

File tree

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonLanguage.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,9 @@ public final class PythonLanguage extends TruffleLanguage<PythonContext> {
205205
public static final int GRAALVM_MAJOR;
206206
public static final int GRAALVM_MINOR;
207207
public static final int GRAALVM_MICRO;
208-
public static final String DEV_TAG;
208+
209+
/** See {@code mx_graalpython.py:abi_version} */
210+
public static final String GRAALPY_ABI_VERSION;
209211

210212
/* Magic number used to mark pyc files */
211213
public static final int MAGIC_NUMBER = 21000 + Compiler.BYTECODE_VERSION * 10;
@@ -226,8 +228,6 @@ public final class PythonLanguage extends TruffleLanguage<PythonContext> {
226228

227229
static {
228230
// The resource file is built by mx from "graalpy-versions" project using mx substitutions.
229-
// The actual values of the versions are computed by mx helper functions py_version_short,
230-
// graal_version_short, and dev_tag defined in mx_graalpython.py
231231
try (InputStream is = PythonLanguage.class.getResourceAsStream("/graalpy_versions")) {
232232
int ch;
233233
if (MAJOR != (ch = is.read() - VERSION_BASE)) {
@@ -257,13 +257,7 @@ public final class PythonLanguage extends TruffleLanguage<PythonContext> {
257257
default:
258258
RELEASE_LEVEL_STRING = tsLiteral("final");
259259
}
260-
// see mx.graalpython/mx_graalpython.py:dev_tag
261-
byte[] rev = new byte[3 /* 'dev' */ + 10 /* revision */];
262-
if (is.read(rev) == rev.length) {
263-
DEV_TAG = new String(rev, StandardCharsets.US_ASCII).strip();
264-
} else {
265-
DEV_TAG = "";
266-
}
260+
GRAALPY_ABI_VERSION = new String(is.readAllBytes(), StandardCharsets.US_ASCII).strip();
267261
} catch (IOException e) {
268262
throw new RuntimeException(e);
269263
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SysModuleBuiltins.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
*/
4141
package com.oracle.graal.python.builtins.modules;
4242

43-
import static com.oracle.graal.python.PythonLanguage.J_GRAALPYTHON_ID;
4443
import static com.oracle.graal.python.PythonLanguage.RELEASE_LEVEL;
4544
import static com.oracle.graal.python.PythonLanguage.RELEASE_SERIAL;
4645
import static com.oracle.graal.python.PythonLanguage.T_GRAALPYTHON_ID;
@@ -472,10 +471,7 @@ protected List<? extends NodeFactory<? extends PythonBuiltinBaseNode>> getNodeFa
472471
private static PSimpleNamespace makeImplementation(PythonLanguage language, PTuple graalpyVersionInfo, TruffleString gmultiarch) {
473472
final PSimpleNamespace ns = PFactory.createSimpleNamespace(language);
474473
ns.setAttribute(StringLiterals.T_NAME, T_GRAALPYTHON_ID);
475-
/*- 'cache_tag' must match the format of mx.graalpython/mx_graalpython.py:graalpy_ext */
476-
ns.setAttribute(T_CACHE_TAG, toTruffleStringUncached(J_GRAALPYTHON_ID +
477-
PythonLanguage.GRAALVM_MAJOR + PythonLanguage.GRAALVM_MINOR + PythonLanguage.DEV_TAG +
478-
"-" + PythonLanguage.MAJOR + PythonLanguage.MINOR));
474+
ns.setAttribute(T_CACHE_TAG, toTruffleStringUncached(PythonLanguage.GRAALPY_ABI_VERSION));
479475
ns.setAttribute(T_VERSION, graalpyVersionInfo);
480476
ns.setAttribute(T__MULTIARCH, gmultiarch);
481477
ns.setAttribute(tsLiteral("hexversion"), PythonLanguage.GRAALVM_MAJOR << 24 | PythonLanguage.GRAALVM_MINOR << 16 | PythonLanguage.GRAALVM_MICRO << 8 | RELEASE_LEVEL << 4 | RELEASE_SERIAL);

mx.graalpython/mx_graalpython.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ def get_boolean_env(name, default=False):
9090
SUITE = cast(mx.SourceSuite, mx.suite('graalpython'))
9191
SUITE_COMPILER = mx.suite("compiler", fatalIfMissing=False)
9292

93+
GRAALPY_ABI_VERSION = 'graalpy250'
9394
GRAAL_VERSION = SUITE.suiteDict['version']
9495
IS_RELEASE = SUITE.suiteDict['release']
9596
GRAAL_VERSION_MAJ_MIN = ".".join(GRAAL_VERSION.split(".")[:2])
@@ -1923,7 +1924,7 @@ def graalpy_ext(*_):
19231924
# on Windows we use '.pyd' else '.so' but never '.dylib' (similar to CPython):
19241925
# https://github.com/python/cpython/issues/37510
19251926
ext = 'pyd' if os == 'windows' else 'so'
1926-
return f'.graalpy{GRAAL_VERSION_MAJ_MIN.replace(".", "") + dev_tag()}-{PYTHON_VERSION_MAJ_MIN.replace(".", "")}-native-{arch}-{pyos}.{ext}'
1927+
return f'.{abi_version()}-native-{arch}-{pyos}.{ext}'
19271928

19281929

19291930
def dev_tag(_=None):
@@ -1949,14 +1950,19 @@ def dev_tag(_=None):
19491950
return res
19501951

19511952

1953+
def abi_version():
1954+
# The ABI version for wheel cache tag
1955+
return f'{GRAALPY_ABI_VERSION}{dev_tag()}-{PYTHON_VERSION_MAJ_MIN.replace(".", "")}'
1956+
1957+
19521958
mx_subst.path_substitutions.register_with_arg('suite', _get_suite_dir)
19531959
mx_subst.path_substitutions.register_with_arg('suite_parent', _get_suite_parent_dir)
19541960
mx_subst.path_substitutions.register_with_arg('src_dir', _get_src_dir)
19551961
mx_subst.path_substitutions.register_with_arg('output_root', _get_output_root)
19561962
mx_subst.path_substitutions.register_with_arg('py_ver', py_version_short)
19571963
mx_subst.path_substitutions.register_with_arg('graal_ver', graal_version_short)
19581964
mx_subst.path_substitutions.register_with_arg('release_level', release_level)
1959-
mx_subst.results_substitutions.register_with_arg('dev_tag', dev_tag)
1965+
mx_subst.results_substitutions.register_no_arg('abi_version', abi_version)
19601966

19611967
mx_subst.path_substitutions.register_no_arg('graalpy_ext', graalpy_ext)
19621968
mx_subst.results_substitutions.register_no_arg('graalpy_ext', graalpy_ext)

mx.graalpython/suite.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@
630630
"max_jobs": "1",
631631
"ninja_targets": ["all"],
632632
"cmakeConfig": {
633-
"GRAALPY_VER": "<py_ver:binary><graal_ver:binary><release_level:binary><dev_tag:none>",
633+
"GRAALPY_VER": "<py_ver:binary><graal_ver:binary><release_level:binary><abi_version>",
634634
},
635635
"results": [
636636
"graalpy_versions"

0 commit comments

Comments
 (0)