@@ -2019,54 +2019,55 @@ def import_files(from_dir, to_dir):
2019
2019
dest_file = join (to_dir , relative_dir_path , filename )
2020
2020
import_file (src_file , dest_file )
2021
2021
2022
- def remove_inexisting_file (src_file , dest_file ):
2022
+ def remove_inexistent_file (src_file , dest_file ):
2023
2023
if not os .path .exists (dest_file ):
2024
2024
mx .logv ("Removing file {} since {} does not exist" .format (src_file , dest_file ))
2025
2025
vc .git_command (SUITE .dir , ["rm" , src_file ])
2026
2026
2027
- def remove_inexisting_files (hpy_dir , our_dir ):
2027
+ def remove_inexistent_files (hpy_dir , our_dir ):
2028
2028
mx .log ("Looking for removed files in {} (HPy reference dir {})" .format (our_dir , hpy_dir ))
2029
2029
for dirpath , _ , filenames in os .walk (our_dir ):
2030
2030
relative_dir_path = os .path .relpath (dirpath , start = our_dir )
2031
2031
for filename in filenames :
2032
2032
src_file = join (dirpath , filename )
2033
2033
dest_file = join (hpy_dir , relative_dir_path , filename )
2034
- remove_inexisting_file (src_file , dest_file )
2034
+ remove_inexistent_file (src_file , dest_file )
2035
2035
2036
2036
# headers go into 'com.oracle.graal.python.cext/include'
2037
2037
header_dest = join (mx .dependency ("com.oracle.graal.python.cext" ).dir , "include" )
2038
2038
2039
2039
# copy headers from .../hpy/hpy/devel/include' to 'header_dest'
2040
2040
# but exclude subdir 'cpython' (since that's only for CPython)
2041
2041
import_files (hpy_repo_include_dir , header_dest )
2042
- remove_inexisting_files (hpy_repo_include_dir , header_dest )
2042
+ remove_inexistent_files (hpy_repo_include_dir , header_dest )
2043
2043
2044
2044
# runtime sources go into 'lib-graalpython/module/hpy/devel/src'
2045
2045
runtime_files_dest = join (_get_core_home (), "modules" , "hpy" , "devel" , "src" )
2046
2046
import_files (hpy_repo_runtime_dir , runtime_files_dest )
2047
- remove_inexisting_files (hpy_repo_runtime_dir , runtime_files_dest )
2047
+ remove_inexistent_files (hpy_repo_runtime_dir , runtime_files_dest )
2048
2048
2049
2049
# tests go to 'lib-graalpython/module/hpy/tests'
2050
2050
test_files_dest = _hpy_test_root ()
2051
2051
import_files (hpy_repo_test_dir , test_files_dest )
2052
- remove_inexisting_files (hpy_repo_test_dir , test_files_dest )
2052
+ remove_inexistent_files (hpy_repo_test_dir , test_files_dest )
2053
2053
2054
2054
# 'version.py' goes to 'lib-graalpython/module/hpy/devel/'
2055
2055
dest_version_file = join (_get_core_home (), "modules" , "hpy" , "devel" , "version.py" )
2056
2056
import_file (join (hpy_repo_path , "hpy" , "devel" , "version.py" ), dest_version_file )
2057
2057
2058
- # read version from 'version.py'
2059
- with open (dest_version_file , "r" ) as f :
2060
- dummy_globals = {}
2061
- exec (f .read (), dummy_globals )
2062
- imported_version = dummy_globals ["__version__" ]
2058
+ # import 'version.py' by path and read '__version__'
2059
+ from importlib import util
2060
+ spec = util .spec_from_file_location ("version" , dest_version_file )
2061
+ version_module = util .module_from_spec (spec )
2062
+ spec .loader .exec_module (version_module )
2063
+ imported_version = version_module .__version__
2063
2064
2064
2065
SUITE .vc .git_command (SUITE .dir , ["add" , header_dest , runtime_files_dest , test_files_dest ])
2065
2066
raw_input ("Check that the updated files look as intended, then press RETURN..." )
2066
2067
SUITE .vc .commit (SUITE .dir , "Update HPy inlined files: %s" % import_version )
2067
2068
SUITE .vc .git_command (SUITE .dir , ["checkout" , "-" ])
2068
2069
SUITE .vc .git_command (SUITE .dir , ["merge" , HPY_IMPORT_ORPHAN_BRANCH_NAME ])
2069
-
2070
+
2070
2071
# update PKG-INFO version
2071
2072
pkg_info_file = join (_get_core_home (), "modules" , "hpy.devel.egg-info" , "PKG-INFO" )
2072
2073
with open (pkg_info_file , "w" ) as f :
0 commit comments