Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,9 @@ public final class PythonLanguage extends TruffleLanguage<PythonContext> {
public static final int GRAALVM_MAJOR;
public static final int GRAALVM_MINOR;
public static final int GRAALVM_MICRO;
public static final String DEV_TAG;

/** See {@code mx_graalpython.py:abi_version} */
public static final String GRAALPY_ABI_VERSION;

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

static {
// The resource file is built by mx from "graalpy-versions" project using mx substitutions.
// The actual values of the versions are computed by mx helper functions py_version_short,
// graal_version_short, and dev_tag defined in mx_graalpython.py
try (InputStream is = PythonLanguage.class.getResourceAsStream("/graalpy_versions")) {
int ch;
if (MAJOR != (ch = is.read() - VERSION_BASE)) {
Expand Down Expand Up @@ -257,13 +257,7 @@ public final class PythonLanguage extends TruffleLanguage<PythonContext> {
default:
RELEASE_LEVEL_STRING = tsLiteral("final");
}
// see mx.graalpython/mx_graalpython.py:dev_tag
byte[] rev = new byte[3 /* 'dev' */ + 10 /* revision */];
if (is.read(rev) == rev.length) {
DEV_TAG = new String(rev, StandardCharsets.US_ASCII).strip();
} else {
DEV_TAG = "";
}
GRAALPY_ABI_VERSION = new String(is.readAllBytes(), StandardCharsets.US_ASCII).strip();
} catch (IOException e) {
throw new RuntimeException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
*/
package com.oracle.graal.python.builtins.modules;

import static com.oracle.graal.python.PythonLanguage.J_GRAALPYTHON_ID;
import static com.oracle.graal.python.PythonLanguage.RELEASE_LEVEL;
import static com.oracle.graal.python.PythonLanguage.RELEASE_SERIAL;
import static com.oracle.graal.python.PythonLanguage.T_GRAALPYTHON_ID;
Expand Down Expand Up @@ -472,10 +471,7 @@ protected List<? extends NodeFactory<? extends PythonBuiltinBaseNode>> getNodeFa
private static PSimpleNamespace makeImplementation(PythonLanguage language, PTuple graalpyVersionInfo, TruffleString gmultiarch) {
final PSimpleNamespace ns = PFactory.createSimpleNamespace(language);
ns.setAttribute(StringLiterals.T_NAME, T_GRAALPYTHON_ID);
/*- 'cache_tag' must match the format of mx.graalpython/mx_graalpython.py:graalpy_ext */
ns.setAttribute(T_CACHE_TAG, toTruffleStringUncached(J_GRAALPYTHON_ID +
PythonLanguage.GRAALVM_MAJOR + PythonLanguage.GRAALVM_MINOR + PythonLanguage.DEV_TAG +
"-" + PythonLanguage.MAJOR + PythonLanguage.MINOR));
ns.setAttribute(T_CACHE_TAG, toTruffleStringUncached(PythonLanguage.GRAALPY_ABI_VERSION));
ns.setAttribute(T_VERSION, graalpyVersionInfo);
ns.setAttribute(T__MULTIARCH, gmultiarch);
ns.setAttribute(tsLiteral("hexversion"), PythonLanguage.GRAALVM_MAJOR << 24 | PythonLanguage.GRAALVM_MINOR << 16 | PythonLanguage.GRAALVM_MICRO << 8 | RELEASE_LEVEL << 4 | RELEASE_SERIAL);
Expand Down
10 changes: 8 additions & 2 deletions mx.graalpython/mx_graalpython.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def get_boolean_env(name, default=False):
SUITE = cast(mx.SourceSuite, mx.suite('graalpython'))
SUITE_COMPILER = mx.suite("compiler", fatalIfMissing=False)

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


def dev_tag(_=None):
Expand All @@ -1949,14 +1950,19 @@ def dev_tag(_=None):
return res


def abi_version():
# The ABI version for wheel cache tag
return f'{GRAALPY_ABI_VERSION}{dev_tag()}-{PYTHON_VERSION_MAJ_MIN.replace(".", "")}'


mx_subst.path_substitutions.register_with_arg('suite', _get_suite_dir)
mx_subst.path_substitutions.register_with_arg('suite_parent', _get_suite_parent_dir)
mx_subst.path_substitutions.register_with_arg('src_dir', _get_src_dir)
mx_subst.path_substitutions.register_with_arg('output_root', _get_output_root)
mx_subst.path_substitutions.register_with_arg('py_ver', py_version_short)
mx_subst.path_substitutions.register_with_arg('graal_ver', graal_version_short)
mx_subst.path_substitutions.register_with_arg('release_level', release_level)
mx_subst.results_substitutions.register_with_arg('dev_tag', dev_tag)
mx_subst.results_substitutions.register_no_arg('abi_version', abi_version)

mx_subst.path_substitutions.register_no_arg('graalpy_ext', graalpy_ext)
mx_subst.results_substitutions.register_no_arg('graalpy_ext', graalpy_ext)
Expand Down
2 changes: 1 addition & 1 deletion mx.graalpython/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@
"max_jobs": "1",
"ninja_targets": ["all"],
"cmakeConfig": {
"GRAALPY_VER": "<py_ver:binary><graal_ver:binary><release_level:binary><dev_tag:none>",
"GRAALPY_VER": "<py_ver:binary><graal_ver:binary><release_level:binary><abi_version>",
},
"results": [
"graalpy_versions"
Expand Down
Loading