|
| 1 | +from pythonforandroid.toolchain import Recipe, shprint, info, warning |
| 2 | +from pythonforandroid.util import ensure_dir, current_directory |
| 3 | +from os.path import join, exists |
| 4 | +import os |
| 5 | +import sh |
| 6 | + |
| 7 | + |
| 8 | +class Hostpython3Recipe(Recipe): |
| 9 | + version = 'bpo-30386' |
| 10 | + url = 'https://github.com/inclement/cpython/archive/{version}.zip' |
| 11 | + name = 'hostpython3' |
| 12 | + |
| 13 | + conflicts = ['hostpython2'] |
| 14 | + |
| 15 | + def get_build_container_dir(self, arch=None): |
| 16 | + choices = self.check_recipe_choices() |
| 17 | + dir_name = '-'.join([self.name] + choices) |
| 18 | + return join(self.ctx.build_dir, 'other_builds', dir_name, 'desktop') |
| 19 | + |
| 20 | + def get_build_dir(self, arch=None): |
| 21 | + # Unlike other recipes, the hostpython build dir doesn't depend on the target arch |
| 22 | + return join(self.get_build_container_dir(), self.name) |
| 23 | + |
| 24 | + def build_arch(self, arch): |
| 25 | + recipe_build_dir = self.get_build_dir(arch.arch) |
| 26 | + with current_directory(recipe_build_dir): |
| 27 | + # Create a subdirectory to actually perform the build |
| 28 | + build_dir = join(recipe_build_dir, 'native-build') |
| 29 | + ensure_dir(build_dir) |
| 30 | + |
| 31 | + env = {} # The command line environment we will use |
| 32 | + |
| 33 | + |
| 34 | + # Configure the build |
| 35 | + with current_directory(build_dir): |
| 36 | + if not exists('config.status'): |
| 37 | + shprint(sh.Command(join(recipe_build_dir, 'configure'))) |
| 38 | + |
| 39 | + # Create the Setup file. This copying from Setup.dist |
| 40 | + # seems to be the normal and expected procedure. |
| 41 | + assert exists(join(build_dir, 'Modules')), ( |
| 42 | + 'Expected dir {} does not exist'.format(join(build_dir, 'Modules'))) |
| 43 | + shprint(sh.cp, join('Modules', 'Setup.dist'), join(build_dir, 'Modules', 'Setup')) |
| 44 | + |
| 45 | + result = shprint(sh.make, '-C', build_dir) |
| 46 | + |
| 47 | + self.ctx.hostpython = join(build_dir, 'python') |
| 48 | + self.ctx.hostpgen = '/usr/bin/false' # is this actually used for anything? |
| 49 | + |
| 50 | + print('result is', result) |
| 51 | + exit(1) |
| 52 | + |
| 53 | +recipe = Hostpython3Recipe() |
0 commit comments