Skip to content

Commit 9ba7d51

Browse files
committed
update inlining script
1 parent c31bc60 commit 9ba7d51

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

mx.graalpython/mx_graalpython.py

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,9 @@ def import_python_sources(args):
667667
mapping = {
668668
"_memoryview.c": "memoryobject.c",
669669
"_cpython_sre.c": "_sre.c",
670+
"_cpython_unicodedata.c": "unicodedata.c",
670671
}
672+
671673
parser = ArgumentParser(prog='mx python-src-import')
672674
parser.add_argument('--cpython', action='store', help='Path to CPython sources', required=True)
673675
parser.add_argument('--pypy', action='store', help='Path to PyPy sources', required=True)
@@ -722,9 +724,11 @@ def import_python_sources(args):
722724
""".format(mapping)
723725
raw_input("Got it?")
724726

725-
files = []
727+
cpy_files = []
728+
pypy_files = []
726729
with open(os.path.join(os.path.dirname(__file__), "copyrights", "overrides")) as f:
727-
files = [line.split(",")[0] for line in f.read().split("\n") if len(line.split(",")) > 1 and line.split(",")[1] == "python.copyright"]
730+
cpy_files = [line.split(",")[0] for line in f.read().split("\n") if len(line.split(",")) > 1 and line.split(",")[1] == "python.copyright"]
731+
pypy_files = [line.split(",")[0] for line in f.read().split("\n") if len(line.split(",")) > 1 and line.split(",")[1] == "pypy.copyright"]
728732

729733
# move to orphaned branch with sources
730734
if SUITE.vc.isDirty(SUITE.dir):
@@ -734,7 +738,28 @@ def import_python_sources(args):
734738
SUITE.vc.git_command(SUITE.dir, ["clean", "-fdx"])
735739
shutil.rmtree("graalpython")
736740

737-
for inlined_file in files:
741+
for inlined_file in pypy_files:
742+
original_file = None
743+
name = os.path.basename(inlined_file)
744+
name = mapping.get(name, name)
745+
if inlined_file.endswith(".py"):
746+
# these files don't need to be updated, they inline some unittest code only
747+
if name.startswith("test_") or name.endswith("_tests.py"):
748+
original_file = inlined_file
749+
else:
750+
for root, dirs, files in os.walk(pypy_sources):
751+
if os.path.basename(name) in files:
752+
original_file = os.path.join(root, name)
753+
try:
754+
os.makedirs(os.path.dirname(inlined_file))
755+
except:
756+
pass
757+
shutil.copy(original_file, inlined_file)
758+
break
759+
if original_file is None:
760+
mx.warn("Could not update %s - original file not found" % inlined_file)
761+
762+
for inlined_file in cpy_files:
738763
# C files are mostly just copied
739764
original_file = None
740765
name = os.path.basename(inlined_file)
@@ -757,8 +782,7 @@ def import_python_sources(args):
757782
mx.warn("Could not update %s - original file not found" % inlined_file)
758783

759784
# re-copy lib-python
760-
libdir = os.path.join(SUITE.dir, "graalpython/lib-python/3")
761-
shutil.copytree(os.path.join(pypy_sources, "lib-python", "3"), libdir)
785+
shutil.copytree(os.path.join(python_sources, "Lib"), _get_stdlib_home())
762786

763787
# commit and check back
764788
SUITE.vc.git_command(SUITE.dir, ["add", "."])

0 commit comments

Comments
 (0)