Skip to content

Commit fb3c7d6

Browse files
committed
Added hostpython3 recipe
1 parent c50dd3d commit fb3c7d6

File tree

9 files changed

+107
-6
lines changed

9 files changed

+107
-6
lines changed

pythonforandroid/bootstraps/sdl2/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
class SDL2GradleBootstrap(Bootstrap):
1414
name = 'sdl2_gradle'
1515

16-
recipe_depends = ['sdl2', ('python2', 'python3crystax')]
16+
recipe_depends = ['sdl2', ('python2', 'python3', 'python3crystax')]
1717

1818
def run_distribute(self):
1919
info_main("# Creating Android project ({})".format(self.name))

pythonforandroid/recipe.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ class CythonRecipe(PythonRecipe):
949949
def __init__(self, *args, **kwargs):
950950
super(CythonRecipe, self).__init__(*args, **kwargs)
951951
depends = self.depends
952-
depends.append(('python2', 'python3crystax'))
952+
depends.append(('python2', 'python3', 'python3crystax'))
953953
depends = list(set(depends))
954954
self.depends = depends
955955

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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()

pythonforandroid/recipes/pyjnius/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class PyjniusRecipe(CythonRecipe):
99
version = 'master'
1010
url = 'https://github.com/kivy/pyjnius/archive/{version}.zip'
1111
name = 'pyjnius'
12-
depends = [('python2', 'python3crystax'), ('genericndkbuild', 'sdl2', 'sdl'), 'six']
12+
depends = [('python2', 'python3', 'python3crystax'), ('genericndkbuild', 'sdl2', 'sdl'), 'six']
1313
site_packages_name = 'jnius'
1414

1515
patches = [('sdl2_jnienv_getter.patch', will_build('sdl2')),
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from pythonforandroid.recipe import TargetPythonRecipe, Recipe
2+
from pythonforandroid.toolchain import shprint, current_directory, info
3+
from pythonforandroid.patching import (is_darwin, is_api_gt,
4+
check_all, is_api_lt, is_ndk)
5+
from os.path import exists, join, realpath
6+
import sh
7+
8+
9+
class Python3Recipe(TargetPythonRecipe):
10+
version = 'bpo-30386'
11+
url = 'https://github.com/inclement/cpython/archive/{version}.zip'
12+
name = 'python3'
13+
14+
depends = ['hostpython3']
15+
conflicts = ['python3crystax', 'python2']
16+
opt_depends = ['openssl', 'sqlite3']
17+
18+
recipe = Python3Recipe()

pythonforandroid/recipes/sdl2/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class LibSDL2Recipe(BootstrapNDKRecipe):
1010

1111
dir_name = 'SDL'
1212

13-
depends = [('python2', 'python3crystax'), 'sdl2_image', 'sdl2_mixer', 'sdl2_ttf']
13+
depends = [('python2', 'python3', 'python3crystax'), 'sdl2_image', 'sdl2_mixer', 'sdl2_ttf']
1414
conflicts = ['sdl', 'pygame', 'pygame_bootstrap_components']
1515

1616
patches = ['add_nativeSetEnv.patch']

pythonforandroid/recipes/six/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
class SixRecipe(PythonRecipe):
66
version = '1.9.0'
77
url = 'https://pypi.python.org/packages/source/s/six/six-{version}.tar.gz'
8-
depends = [('python2', 'python3crystax')]
98

109

1110
recipe = SixRecipe()

testapps/setup_testapp_python3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from setuptools import find_packages
44

55
options = {'apk': {'debug': None,
6-
'requirements': 'sdl2,pyjnius,kivy,python3crystax',
6+
'requirements': 'sdl2,pyjnius,kivy,python3',
77
'android-api': 19,
88
'ndk-dir': '/home/asandy/android/crystax-ndk-10.3.2',
99
'dist-name': 'bdisttest_python3',
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
from distutils.core import setup
3+
from setuptools import find_packages
4+
5+
options = {'apk': {'debug': None,
6+
'requirements': 'sdl2,pyjnius,kivy,python3crystax',
7+
'android-api': 19,
8+
'ndk-dir': '/home/asandy/android/crystax-ndk-10.3.2',
9+
'dist-name': 'bdisttest_python3',
10+
'ndk-version': '10.3.2',
11+
'arch': 'armeabi-v7a',
12+
'permission': 'VIBRATE',
13+
}}
14+
15+
package_data = {'': ['*.py',
16+
'*.png']
17+
}
18+
19+
packages = find_packages()
20+
print('packages are', packages)
21+
22+
setup(
23+
name='testapp_python3',
24+
version='1.1',
25+
description='p4a setup.py test',
26+
author='Alexander Taylor',
27+
author_email='[email protected]',
28+
packages=find_packages(),
29+
options=options,
30+
package_data={'testapp': ['*.py', '*.png']}
31+
)

0 commit comments

Comments
 (0)