Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions pythonforandroid/recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,11 +531,10 @@ def unpack(self, arch):
def get_recipe_env(self, arch=None, with_flags_in_cc=True):
"""Return the env specialized for the recipe
"""
if arch is None:
arch = self.filtered_archs[0]
arch = arch or self.filtered_archs[0]
env = arch.get_env(with_flags_in_cc=with_flags_in_cc)

for proxy_key in ['HTTP_PROXY', 'http_proxy', 'HTTPS_PROXY', 'https_proxy']:
for proxy_key in ('HTTP_PROXY', 'http_proxy', 'HTTPS_PROXY', 'https_proxy'):
if proxy_key in environ:
env[proxy_key] = environ[proxy_key]

Expand Down
62 changes: 36 additions & 26 deletions pythonforandroid/recipes/python3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,23 +73,28 @@ class Python3Recipe(TargetPythonRecipe):
configure_args = [
'--host={android_host}',
'--build={android_build}',
'--enable-shared',
'--enable-ipv6',
'--enable-loadable-sqlite-extensions',
'--without-static-libpython',
'--without-readline',
'--enable-shared',

# Attempt on making the builds lighter
'--disable-test-modules',
'--without-doc-strings',
'--without-ensurepip',
'--without-readline',
'--without-static-libpython',

# Android prefix
'--prefix={prefix}',
'--enable-loadable-sqlite-extensions',

# Special cross compile args
'ac_cv_file__dev_ptmx=yes',
'ac_cv_file__dev_ptc=no',
'ac_cv_header_sys_eventfd_h=no',
'ac_cv_little_endian_double=yes',
'ac_cv_file__dev_ptmx=yes',
'ac_cv_header_bzlib_h=no',
'ac_cv_header_sys_eventfd_h=no',
'py_cv_module__curses=n/a',
'py_cv_module__curses_panel=n/a',
'py_cv_module__tkinter=n/a'
]

'''The configure arguments needed to build the python recipe. Those are
Expand All @@ -100,26 +105,31 @@ class Python3Recipe(TargetPythonRecipe):
MIN_NDK_API = 21
'''Sets the minimal ndk api number needed to use the recipe.

.. warning:: This recipe can be built only against API 21+, so it means
that any class which inherits from class:`GuestPythonRecipe` will have
this limitation.
.. warning:: Starting from Python 3.14 this recipe can only be built
against API 24+, so it means that any class which inherits from
class:`GuestPythonRecipe` will have this limitation.
'''

stdlib_dir_blacklist = {
'__pycache__',
'test',
'tests',
'lib2to3',
'curses',
'ensurepip',
'idlelib',
'lib2to3',
'pydoc_data',
'test',
'tests',
'tkinter',
'turtledemo',
'venv'
}
'''The directories that we want to omit for our python bundle'''

stdlib_filen_blacklist = [
'*.py',
'*.exe',
'*.py',
'*.whl',
'turtle.pyc'
]
'''The file extensions that we want to blacklist for our python bundle'''

Expand All @@ -139,7 +149,8 @@ class Python3Recipe(TargetPythonRecipe):
if the full path contains any of these exceptions.'''

site_packages_filen_blacklist = [
'*.py'
'*.py',
'*.pyx'
]
'''The file extensions from site packages dir that we don't want to be
included in our python bundle.'''
Expand Down Expand Up @@ -235,19 +246,18 @@ def prebuild_arch(self, arch):
def get_recipe_env(self, arch=None, with_flags_in_cc=True):
env = super().get_recipe_env(arch)
env['HOSTARCH'] = arch.command_prefix

env['CC'] = arch.get_clang_exe(with_target=True)

env['PATH'] = (
'{hostpython_dir}:{old_path}').format(
hostpython_dir=self.get_recipe(
'host' + self.name, self.ctx).get_path_to_python(),
old_path=env['PATH'])

env['PATH'] = '{hostpython_dir}:{old_path}'.format(
hostpython_dir=self.get_recipe(
'host' + self.name, self.ctx
).get_path_to_python(),
old_path=env['PATH']
)
env['CFLAGS'] = ' '.join(
[
'-fPIC',
'-DANDROID'
'-ffunction-sections',
'-fdata-sections',
'-fPIC'
]
)

Expand Down Expand Up @@ -402,7 +412,7 @@ def compile_python_files(self, dir):
longer used...uses .pyc (https://www.python.org/dev/peps/pep-0488)
'''
args = [self.ctx.hostpython]
args += ['-OO', '-m', 'compileall', '-b', '-f', dir]
args += ['-OO', '-m', 'compileall', '-b', '-f', '-q', dir]
subprocess.call(args)

def create_python_bundle(self, dirn, arch):
Expand Down
4 changes: 2 additions & 2 deletions tests/recipes/test_python3.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def test_compile_python_files(self, mock_subprocess):
hostpy = self.recipe.ctx.hostpython = '/fake/hostpython3'
self.recipe.compile_python_files(fake_compile_dir)
mock_subprocess.assert_called_once_with(
[hostpy, '-OO', '-m', 'compileall', '-b', '-f', fake_compile_dir],
[hostpy, '-OO', '-m', 'compileall', '-b', '-f', '-q', fake_compile_dir],
)

@mock.patch("pythonforandroid.recipe.Recipe.check_recipe_choices")
Expand All @@ -61,7 +61,7 @@ def test_get_recipe_env(
)
env = self.recipe.get_recipe_env(self.arch)

self.assertIn('-fPIC -DANDROID', env["CFLAGS"])
self.assertIn('-fPIC', env["CFLAGS"])
self.assertEqual(env["CC"], self.arch.get_clang_exe(with_target=True))

# make sure that the mocked methods are actually called
Expand Down
Loading