@@ -779,12 +779,14 @@ def get_recipe_env(self, arch=None, with_flags_in_cc=True):
779
779
hppath .append (join (dirname (self .hostpython_location ), 'Lib' ))
780
780
hppath .append (join (hppath [0 ], 'site-packages' ))
781
781
builddir = join (dirname (self .hostpython_location ), 'build' )
782
- hppath += [join (builddir , d ) for d in listdir (builddir )
783
- if isdir (join (builddir , d ))]
784
- if 'PYTHONPATH' in env :
785
- env ['PYTHONPATH' ] = ':' .join (hppath + [env ['PYTHONPATH' ]])
786
- else :
787
- env ['PYTHONPATH' ] = ':' .join (hppath )
782
+ if exists (builddir ):
783
+ hppath += [join (builddir , d ) for d in listdir (builddir )
784
+ if isdir (join (builddir , d ))]
785
+ if len (hppath ) > 0 :
786
+ if 'PYTHONPATH' in env :
787
+ env ['PYTHONPATH' ] = ':' .join (hppath + [env ['PYTHONPATH' ]])
788
+ else :
789
+ env ['PYTHONPATH' ] = ':' .join (hppath )
788
790
return env
789
791
790
792
def should_build (self , arch ):
@@ -955,16 +957,6 @@ def build_cython_components(self, arch):
955
957
956
958
env = self .get_recipe_env (arch )
957
959
958
- if self .ctx .python_recipe .from_crystax :
959
- command = sh .Command ('python{}' .format (self .ctx .python_recipe .version ))
960
- site_packages_dirs = command (
961
- '-c' , 'import site; print("\\ n".join(site.getsitepackages()))' )
962
- site_packages_dirs = site_packages_dirs .stdout .decode ('utf-8' ).split ('\n ' )
963
- if 'PYTHONPATH' in env :
964
- env ['PYTHONPATH' ] = env ['PYTHONPATH' ] + ':{}' .format (':' .join (site_packages_dirs ))
965
- else :
966
- env ['PYTHONPATH' ] = ':' .join (site_packages_dirs )
967
-
968
960
with current_directory (self .get_build_dir (arch .arch )):
969
961
hostpython = sh .Command (self .ctx .hostpython )
970
962
shprint (hostpython , '-c' , 'import sys; print(sys.path)' , _env = env )
@@ -989,8 +981,15 @@ def build_cython_components(self, arch):
989
981
info ('First build appeared to complete correctly, skipping manual'
990
982
'cythonising.' )
991
983
984
+ self .strip_object_files (arch , env )
985
+
986
+ def strip_object_files (self , arch , env , build_dir = None ):
987
+ if build_dir is None :
988
+ build_dir = self .get_build_dir (arch .arch )
989
+ with current_directory (build_dir ):
992
990
info ('Stripping object files' )
993
991
if self .ctx .python_recipe .name == 'python2legacy' :
992
+ info ('Stripping object files' )
994
993
build_lib = glob .glob ('./build/lib*' )
995
994
shprint (sh .find , build_lib [0 ], '-name' , '*.o' , '-exec' ,
996
995
env ['STRIP' ], '{}' , ';' , _env = env )
@@ -1055,6 +1054,24 @@ def get_recipe_env(self, arch, with_flags_in_cc=True):
1055
1054
env ['LIBLINK_PATH' ] = liblink_path
1056
1055
ensure_dir (liblink_path )
1057
1056
1057
+ # Add crystax-specific site packages:
1058
+ if self .ctx .python_recipe .from_crystax :
1059
+ command = sh .Command ('python{}' .format (self .ctx .python_recipe .version ))
1060
+ site_packages_dirs = command (
1061
+ '-c' , 'import site; print("\\ n".join(site.getsitepackages()))' )
1062
+ site_packages_dirs = site_packages_dirs .stdout .decode ('utf-8' ).split ('\n ' )
1063
+ if 'PYTHONPATH' in env :
1064
+ env ['PYTHONPATH' ] = env ['PYTHONPATH' ] + \
1065
+ ':{}' .format (':' .join (site_packages_dirs ))
1066
+ else :
1067
+ env ['PYTHONPATH' ] = ':' .join (site_packages_dirs )
1068
+ while env ['PYTHONPATH' ].find ("::" ) > 0 :
1069
+ env ['PYTHONPATH' ] = env ['PYTHONPATH' ].replace ("::" , ":" )
1070
+ if env ['PYTHONPATH' ].endswith (":" ):
1071
+ env ['PYTHONPATH' ] = env ['PYTHONPATH' ][:- 1 ]
1072
+ if env ['PYTHONPATH' ].startswith (":" ):
1073
+ env ['PYTHONPATH' ] = env ['PYTHONPATH' ][1 :]
1074
+
1058
1075
return env
1059
1076
1060
1077
0 commit comments