@@ -779,12 +779,14 @@ def get_recipe_env(self, arch=None, with_flags_in_cc=True):
779779 hppath .append (join (dirname (self .hostpython_location ), 'Lib' ))
780780 hppath .append (join (hppath [0 ], 'site-packages' ))
781781 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 )
788790 return env
789791
790792 def should_build (self , arch ):
@@ -955,16 +957,6 @@ def build_cython_components(self, arch):
955957
956958 env = self .get_recipe_env (arch )
957959
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-
968960 with current_directory (self .get_build_dir (arch .arch )):
969961 hostpython = sh .Command (self .ctx .hostpython )
970962 shprint (hostpython , '-c' , 'import sys; print(sys.path)' , _env = env )
@@ -989,8 +981,15 @@ def build_cython_components(self, arch):
989981 info ('First build appeared to complete correctly, skipping manual'
990982 'cythonising.' )
991983
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 ):
992990 info ('Stripping object files' )
993991 if self .ctx .python_recipe .name == 'python2legacy' :
992+ info ('Stripping object files' )
994993 build_lib = glob .glob ('./build/lib*' )
995994 shprint (sh .find , build_lib [0 ], '-name' , '*.o' , '-exec' ,
996995 env ['STRIP' ], '{}' , ';' , _env = env )
@@ -1055,6 +1054,24 @@ def get_recipe_env(self, arch, with_flags_in_cc=True):
10551054 env ['LIBLINK_PATH' ] = liblink_path
10561055 ensure_dir (liblink_path )
10571056
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+
10581075 return env
10591076
10601077
0 commit comments