Skip to content

Commit e2372d5

Browse files
committed
structure the build differently so we can build GRAALPYTHON cleanly again
1 parent a5d2f45 commit e2372d5

File tree

3 files changed

+33
-30
lines changed

3 files changed

+33
-30
lines changed

graalpython/com.oracle.graal.python.frozen/freeze_modules.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,7 @@ def write_frozen_module_file(file, modules):
552552
atime, mtime = stat_result.st_atime, stat_result.st_mtime
553553
else:
554554
content = None
555+
os.makedirs(os.path.dirname(file), exist_ok=True)
555556
with open(file, "w") as out_file:
556557
out_file.write(trim(FROZEN_MODULES_HEADER))
557558
out_file.write("\n\n")

mx.graalpython/mx_graalpython.py

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,16 @@ def do_run_python(args, extra_vm_args=None, env=None, jdk=None, extra_dists=None
164164
elif check_vm_env == '0':
165165
check_vm()
166166

167-
dists = [f'{"BOOTSTRAP_" if minimal else ""}GRAALPYTHON', 'TRUFFLE_NFI', 'SULONG_NATIVE']
167+
if minimal:
168+
x, *__ = *[x for x in SUITE.dists if x.name == "GRAALPYTHON"],
169+
dists = [dep for dep in x.deps if dep.isJavaProject() or dep.isJARDistribution()]
170+
else:
171+
dists = ['GRAALPYTHON']
172+
dists += ['TRUFFLE_NFI', 'SULONG_NATIVE']
168173

169174
vm_args, graalpython_args = mx.extract_VM_args(args, useDoubleDash=True, defaultAllVMArgs=False)
175+
if minimal:
176+
vm_args.insert(0, f"-Dorg.graalvm.language.python.home={_dev_pythonhome()}")
170177
graalpython_args, additional_dists = _extract_graalpython_internal_options(graalpython_args)
171178
dists += additional_dists
172179

@@ -1880,6 +1887,9 @@ def __str__(self):
18801887
return 'Building project {}'.format(self.subject.name)
18811888

18821889
def build(self):
1890+
if not self.args.force and not self.args.all and not self.needsBuild(None)[0]:
1891+
mx.log(f"Refusing build of {self.subject.name}. Use e.g. `mx -f --only {self.subject.name}' to force a build.")
1892+
return True
18831893
args = [mx_subst.path_substitutions.substitute(a, dependency=self) for a in self.subject.args]
18841894
return self.run(args)
18851895

@@ -1938,7 +1948,7 @@ def needsBuild(self, newestInput):
19381948
if tsOldest == sys.maxsize:
19391949
tsOldest = 0
19401950
if tsOldest < tsNewest:
1941-
self.clean() # we clean here, because setuptools doesn't check timestamps
1951+
self.clean(forBuild="reallyForBuild") # we clean here, because setuptools doesn't check timestamps
19421952
if newestFile and oldestFile:
19431953
return (True, "rebuild needed, %s newer than %s" % (newestFile, oldestFile))
19441954
else:
@@ -1950,12 +1960,12 @@ def newestOutput(self):
19501960
return None
19511961

19521962
def clean(self, forBuild=False):
1953-
try:
1954-
shutil.rmtree(self.subject.get_output_root())
1955-
except BaseException:
1956-
return 1
1957-
else:
1958-
return 0
1963+
if forBuild == "reallyForBuild":
1964+
try:
1965+
shutil.rmtree(self.subject.get_output_root())
1966+
except BaseException:
1967+
return 1
1968+
return 0
19591969

19601970

19611971
class GraalpythonCAPIBuildTask(GraalpythonBuildTask):
@@ -1983,23 +1993,18 @@ def _prepare_headers(self):
19831993

19841994
def build(self):
19851995
self._prepare_headers()
1986-
19871996
# n.b.: we do the following to ensure that there's a directory when the
19881997
# importlib PathFinder initializes it's directory finders
19891998
mx.ensure_dir_exists(os.path.join(self.subject.get_output_root(), "modules"))
1990-
1991-
args = [
1992-
os.path.join(self.src_dir(), "setup.py"),
1993-
self.subject.get_output_root()
1994-
]
1995-
return self.run(args)
1999+
return super().build()
19962000

19972001
def clean(self, forBuild=False):
19982002
result = 0
1999-
try:
2000-
shutil.rmtree(self._dev_headers_dir())
2001-
except BaseException:
2002-
result = 1
2003+
if not forBuild:
2004+
try:
2005+
shutil.rmtree(self._dev_headers_dir())
2006+
except BaseException:
2007+
result = 1
20032008
return max(result, super().clean(forBuild=forBuild))
20042009

20052010

mx.graalpython/suite.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@
254254
],
255255
"platformDependent": False,
256256
"buildDependencies": [
257-
"BOOTSTRAP_GRAALPYTHON",
257+
"com.oracle.graal.python",
258258
],
259259
},
260260

@@ -366,8 +366,12 @@
366366
"vpath": True,
367367
"type": "GraalpythonCAPIProject",
368368
"platformDependent": False,
369+
"args": [
370+
"<src_dir:com.oracle.graal.python.cext>/setup.py",
371+
"<output_root:com.oracle.graal.python.cext>",
372+
],
369373
"buildDependencies": [
370-
"BOOTSTRAP_GRAALPYTHON",
374+
"com.oracle.graal.python",
371375
"sulong:SULONG_HOME",
372376
"sulong:SULONG_LEGACY",
373377
"sulong:SULONG_BOOTSTRAP_TOOLCHAIN",
@@ -467,9 +471,10 @@
467471
"maven": True,
468472
},
469473

470-
"BOOTSTRAP_GRAALPYTHON": {
474+
"GRAALPYTHON": {
471475
"dependencies": [
472476
"com.oracle.graal.python",
477+
"com.oracle.graal.python.frozen",
473478
],
474479
"distDependencies": [
475480
"GRAALPYTHON-LAUNCHER",
@@ -485,14 +490,6 @@
485490
"sulong:SULONG_API",
486491
"sulong:SULONG_NATIVE", # this is actually just a runtime dependency
487492
],
488-
"description": "GraalPython engine during build time",
489-
},
490-
491-
"GRAALPYTHON": {
492-
"dependencies": [
493-
"BOOTSTRAP_GRAALPYTHON",
494-
"com.oracle.graal.python.frozen",
495-
],
496493
"javaProperties": {
497494
"python.jni.library": "<lib:pythonjni>"
498495
},

0 commit comments

Comments
 (0)