@@ -2370,6 +2370,62 @@ def __closing__(self):
2370
2370
2371
2371
2372
2372
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
+
2373
2429
# all projects are now available at this time
2374
2430
_register_vms (namespace )
2375
2431
_register_bench_suites (namespace )
@@ -3419,6 +3475,7 @@ def graalpy_standalone_wrapper(args_in):
3419
3475
mx .abort ("You must add --dynamicimports graalpython-enterprise for EE edition" )
3420
3476
print (graalpy_standalone (args .type , enterprise = args .edition == 'ee' , build = not args .no_build ))
3421
3477
3478
+
3422
3479
# ----------------------------------------------------------------------------------------------------------------------
3423
3480
#
3424
3481
# register the suite commands (if any)
0 commit comments