Skip to content

Commit 63274a4

Browse files
committed
make sure our hardcoded versions do not cause problems when they disagree with the suite version
1 parent 71b6dca commit 63274a4

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

mx.graalpython/mx_graalpython.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2370,6 +2370,62 @@ def __closing__(self):
23702370

23712371

23722372
def mx_post_parse_cmd_line(namespace):
2373+
"""
2374+
Ensure hardcoded versions everywhere match the suite version.
2375+
Fix and warn if they do not in CI, fail the build locally.
2376+
"""
2377+
files_with_versions = {
2378+
"graalpython/graalpy-maven-plugin/pom.xml": {
2379+
r"^ <version>(\d+\.\d+(?:\.\d+)*)</version>": GRAAL_VERSION,
2380+
r"<graalpy.version>(\d+\.\d+(?:\.\d+)*)</graalpy.version>": GRAAL_VERSION,
2381+
},
2382+
"graalpython/com.oracle.graal.python.test.integration/pom.xml": {
2383+
r"<com.oracle.graal.python.test.polyglot.version>(\d+\.\d+(?:\.\d+)*)</com.oracle.graal.python.test.polyglot.version>": GRAAL_VERSION,
2384+
},
2385+
"graalpython/graalpy-archetype-polyglot-app/pom.xml": {
2386+
r"^ <version>(\d+\.\d+(?:\.\d+)*)</version>": GRAAL_VERSION,
2387+
},
2388+
"graalpython/graalpy-jbang/examples/hello.java": {
2389+
r"//DEPS org.graalvm.python:python[^:]*:(\d+\.\d+(?:\.\d+)*)": GRAAL_VERSION,
2390+
},
2391+
"graalpython/graalpy-jbang/templates/graalpy-template_local_repo.java.qute": {
2392+
r"//DEPS org.graalvm.python:python[^:]*:(\d+\.\d+(?:\.\d+)*)": GRAAL_VERSION,
2393+
},
2394+
"graalpython/graalpy-jbang/templates/graalpy-template.java.qute": {
2395+
r"//DEPS org.graalvm.python:python[^:]*:(\d+\.\d+(?:\.\d+)*)": GRAAL_VERSION,
2396+
},
2397+
"graalpython/graalpy-archetype-polyglot-app/src/main/resources/archetype-resources/pom.xml": {
2398+
r"<graalpy.version>(\d+\.\d+(?:\.\d+)*)</graalpy.version>": GRAAL_VERSION,
2399+
},
2400+
"graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonLanguage.java": {
2401+
r"GRAALVM_MAJOR = (\d+);" : GRAAL_VERSION.split(".")[0],
2402+
r"GRAALVM_MINOR = (\d+);" : GRAAL_VERSION.split(".")[1],
2403+
},
2404+
}
2405+
replacements = set()
2406+
for path, patterns in files_with_versions.items():
2407+
full_path = os.path.join(SUITE.dir, path)
2408+
with open(full_path, "r", encoding="utf-8") as f:
2409+
content = f.read()
2410+
has_replacement = False
2411+
for pattern, replacement in patterns.items():
2412+
pattern = re.compile(pattern, flags=re.M)
2413+
start = 0
2414+
while m := pattern.search(content, start):
2415+
group = m.group(1)
2416+
length_diff = len(replacement) - len(group)
2417+
mx.logvv(f"[{SUITE.name}] {path} with hardcoded version `{m.group()}'")
2418+
if group != replacement:
2419+
replacements.add(path)
2420+
has_replacement = True
2421+
content = content[:m.start(1)] + replacement + content[m.end(1):]
2422+
start = m.end() + length_diff
2423+
if has_replacement:
2424+
with open(full_path, "w", encoding="utf-8") as f:
2425+
f.write(content)
2426+
for replacement in replacements:
2427+
mx.warn(f"Updated Graal version in {replacement}, you should check this in!")
2428+
23732429
# all projects are now available at this time
23742430
_register_vms(namespace)
23752431
_register_bench_suites(namespace)
@@ -3419,6 +3475,7 @@ def graalpy_standalone_wrapper(args_in):
34193475
mx.abort("You must add --dynamicimports graalpython-enterprise for EE edition")
34203476
print(graalpy_standalone(args.type, enterprise=args.edition == 'ee', build=not args.no_build))
34213477

3478+
34223479
# ----------------------------------------------------------------------------------------------------------------------
34233480
#
34243481
# register the suite commands (if any)

0 commit comments

Comments
 (0)