@@ -667,7 +667,9 @@ def import_python_sources(args):
667
667
mapping = {
668
668
"_memoryview.c" : "memoryobject.c" ,
669
669
"_cpython_sre.c" : "_sre.c" ,
670
+ "_cpython_unicodedata.c" : "unicodedata.c" ,
670
671
}
672
+
671
673
parser = ArgumentParser (prog = 'mx python-src-import' )
672
674
parser .add_argument ('--cpython' , action = 'store' , help = 'Path to CPython sources' , required = True )
673
675
parser .add_argument ('--pypy' , action = 'store' , help = 'Path to PyPy sources' , required = True )
@@ -722,9 +724,11 @@ def import_python_sources(args):
722
724
""" .format (mapping )
723
725
raw_input ("Got it?" )
724
726
725
- files = []
727
+ cpy_files = []
728
+ pypy_files = []
726
729
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" ]
728
732
729
733
# move to orphaned branch with sources
730
734
if SUITE .vc .isDirty (SUITE .dir ):
@@ -734,7 +738,28 @@ def import_python_sources(args):
734
738
SUITE .vc .git_command (SUITE .dir , ["clean" , "-fdx" ])
735
739
shutil .rmtree ("graalpython" )
736
740
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 :
738
763
# C files are mostly just copied
739
764
original_file = None
740
765
name = os .path .basename (inlined_file )
@@ -757,8 +782,7 @@ def import_python_sources(args):
757
782
mx .warn ("Could not update %s - original file not found" % inlined_file )
758
783
759
784
# 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 ())
762
786
763
787
# commit and check back
764
788
SUITE .vc .git_command (SUITE .dir , ["add" , "." ])
0 commit comments