16
16
from pythonforandroid .util import (
17
17
current_directory , ensure_dir , walk_valid_filens ,
18
18
BuildInterruptingException , build_platform )
19
+ from pythonforandroid .patching import is_darwin
19
20
20
21
21
22
class GuestPythonRecipe (TargetPythonRecipe ):
@@ -382,6 +383,22 @@ class HostPythonRecipe(Recipe):
382
383
'''The default url to download our host python recipe. This url will
383
384
change depending on the python version set in attribute :attr:`version`.'''
384
385
386
+ @property
387
+ def python_bin (self ):
388
+ if is_darwin ():
389
+ return 'python.exe'
390
+ return 'python'
391
+
392
+ def should_build (self , arch ):
393
+ python_bin = join (
394
+ self .get_build_dir (arch .arch ), self .build_subdir , self .python_bin
395
+ )
396
+ if exists (python_bin ):
397
+ # no need to build, but we must set:
398
+ self .ctx .hostpython = python_bin
399
+ return False
400
+ return True
401
+
385
402
def get_build_container_dir (self , arch = None ):
386
403
choices = self .check_recipe_choices ()
387
404
dir_name = '-' .join ([self .name ] + choices )
@@ -404,22 +421,18 @@ def build_arch(self, arch):
404
421
build_dir = join (recipe_build_dir , self .build_subdir )
405
422
ensure_dir (build_dir )
406
423
407
- if not exists (join (build_dir , 'python' )):
408
- with current_directory (recipe_build_dir ):
409
- # Configure the build
410
- with current_directory (build_dir ):
411
- if not exists ('config.status' ):
412
- shprint (
413
- sh .Command (join (recipe_build_dir , 'configure' )))
424
+ with current_directory (recipe_build_dir ):
425
+ # Configure the build
426
+ with current_directory (build_dir ):
427
+ if not exists ('config.status' ):
428
+ shprint (
429
+ sh .Command (join (recipe_build_dir , 'configure' )))
414
430
415
- # Create the Setup file. This copying from Setup.dist
416
- # seems to be the normal and expected procedure.
417
- shprint (sh .cp , join ('Modules' , 'Setup.dist' ),
418
- join (build_dir , 'Modules' , 'Setup' ))
431
+ # Create the Setup file. This copying from Setup.dist
432
+ # seems to be the normal and expected procedure.
433
+ shprint (sh .cp , join ('Modules' , 'Setup.dist' ),
434
+ join (build_dir , 'Modules' , 'Setup' ))
419
435
420
- shprint (sh .make , '-j' , str (cpu_count ()), '-C' , build_dir )
421
- else :
422
- info ('Skipping {name} ({version}) build, as it has already '
423
- 'been completed' .format (name = self .name , version = self .version ))
436
+ shprint (sh .make , '-j' , str (cpu_count ()), '-C' , build_dir )
424
437
425
- self .ctx .hostpython = join (build_dir , 'python' )
438
+ self .ctx .hostpython = join (build_dir , self . python_bin )
0 commit comments