Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop CrystaX support and code base #1913

Merged
merged 8 commits into from
Jul 14, 2019
Merged
Show file tree
Hide file tree
Changes from 7 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
4 changes: 1 addition & 3 deletions ci/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

class TargetPython(Enum):
python2 = 0
python3crystax = 1
python3 = 2


Expand All @@ -22,7 +21,6 @@ class TargetPython(Enum):
'ffpyplayer',
'flask',
'groestlcoin_hash',
'hostpython3crystax',
# https://github.com/kivy/python-for-android/issues/1354
'kiwisolver',
'libmysqlclient',
Expand Down Expand Up @@ -88,5 +86,5 @@ class TargetPython(Enum):
# recipes that were already built will be skipped
CORE_RECIPES = set([
'pyjnius', 'kivy', 'openssl', 'requests', 'sqlite3', 'setuptools',
'numpy', 'android', 'python2', 'python3',
'numpy', 'android', 'hostpython2', 'hostpython3', 'python2', 'python3',
])
15 changes: 14 additions & 1 deletion ci/rebuild_updated_recipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from pythonforandroid.graph import get_recipe_order_and_bootstrap
from pythonforandroid.toolchain import current_directory
from pythonforandroid.util import BuildInterruptingException
from pythonforandroid.recipe import Recipe
from ci.constants import TargetPython, CORE_RECIPES, BROKEN_RECIPES


Expand Down Expand Up @@ -66,7 +67,7 @@ def build(target_python, requirements):
# iterates to stream the output
for line in sh.python(
testapp, 'apk', '--sdk-dir', android_sdk_home,
'--ndk-dir', android_ndk_home, '--bootstrap', 'sdl2', '--requirements',
'--ndk-dir', android_ndk_home, '--requirements',
requirements, _err_to_out=True, _iter=True):
print(line)

Expand All @@ -78,6 +79,18 @@ def main():
recipes -= CORE_RECIPES
logger.info('recipes to build: {}'.format(recipes))
context = Context()

# removing the deleted recipes for the given target (if any)
for recipe_name in recipes.copy():
try:
Recipe.get_recipe(recipe_name, context)
except ValueError:
# recipe doesn't exist, so probably we remove it
recipes.remove(recipe_name)
logger.warning(
'removed {} from recipes because deleted'.format(recipe_name)
)

# forces the default target
recipes_and_target = recipes | set([target_python.name])
try:
Expand Down
33 changes: 14 additions & 19 deletions doc/source/buildoptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,20 @@ e.g. ``--requirements=python3``.


CrystaX python3
###############

.. warning:: python-for-android originally supported Python 3 using the CrystaX
NDK. This support is now being phased out as CrystaX is no longer
actively developed.

.. note:: You must manually download the `CrystaX NDK
<https://www.crystax.net/android/ndk>`__ and tell
python-for-android to use it with ``--ndk-dir /path/to/NDK``.

Select this by adding the ``python3crystax`` recipe to your
requirements, e.g. ``--requirements=python3crystax``.

This uses the prebuilt Python from the `CrystaX NDK
<https://www.crystax.net/android/ndk>`__, a drop-in replacement for
Google's official NDK which includes many improvements. You
*must* use the CrystaX NDK 10.3.0 or higher when building with
python3. You can get it `here
<https://www.crystax.net/en/download>`__.
~~~~~~~~~~~~~~~

python-for-android originally supported Python 3 using the CrystaX NDK. Since
we have a working python3 recipe, we don't support CrystaX NDK anymore. If you
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be more direct with this kind of doc, you can just write

python-for-android no longer supports building for Python 3 using the CrystaX NDK. Instead, use the python3 recipe, which can be built using the normal Google NDK.

The last python-for-android version supporting CrystaX was 0.7.0.

No need for this to hold up merging the PR, we can improve the doc later (there are plenty of parts that I wrote that also need improvement), just noting as something I've been thinking about.

were using `python3crystax`, we recommend to give it a try to the new `python3`
recipe.

.. note:: Since we don't support `python3crystax` anymore, the old instructions
has been removed from here. If you, still have the need to make use
of this old recipe, you should do it with an old `python-for-android`
release. Probably, a good starting point would be `version 0.7.0
<https://github.com/kivy/python-for-android/archive/0.7.0.zip>`__ or
if that doesn't work , then go for `version 0.6.0
<https://github.com/kivy/python-for-android/archive/0.6.0.zip>`__

.. _bootstrap_build_options:

Expand Down
11 changes: 5 additions & 6 deletions doc/source/docker.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ already have Docker preinstalled and set up.
.. warning::
This approach is highly space unfriendly! The more layers (``commit``) or
even Docker images (``build``) you create the more space it'll consume.
Within the Docker image there is Android + Crystax SDK and NDK + various
dependencies. Within the custom diff made by building the distribution
there is another big chunk of space eaten. The very basic stuff such as
a distribution with: CPython 3, setuptools, Python for Android ``android``
module, SDL2 (+ deps), PyJNIus and Kivy takes almost 13 GB. Check your free
space first!
Within the Docker image there is Android SDK and NDK + various dependencies.
Within the custom diff made by building the distribution there is another
big chunk of space eaten. The very basic stuff such as a distribution with:
CPython 3, setuptools, Python for Android ``android`` module, SDL2 (+ deps),
PyJNIus and Kivy takes almost 2 GB. Check your free space first!

1. Clone the repository::

Expand Down
11 changes: 1 addition & 10 deletions pythonforandroid/archs.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,6 @@ def get_env(self, with_flags_in_cc=True, clang=False):

env["LDFLAGS"] += " ".join(['-lm', '-L' + self.ctx.get_libs_dir(self.arch)])

if self.ctx.ndk == 'crystax':
env['LDFLAGS'] += ' -L{}/sources/crystax/libs/{} -lcrystax'.format(self.ctx.ndk_dir, self.arch)

toolchain_prefix = self.ctx.toolchain_prefix
toolchain_version = self.ctx.toolchain_version
command_prefix = self.command_prefix
Expand Down Expand Up @@ -154,10 +151,7 @@ def get_env(self, with_flags_in_cc=True, clang=False):
env['LD'] = '{}-ld'.format(command_prefix)
env['LDSHARED'] = env["CC"] + " -pthread -shared " +\
"-Wl,-O1 -Wl,-Bsymbolic-functions "
if self.ctx.python_recipe and self.ctx.python_recipe.from_crystax:
# For crystax python, we can't use the host python headers:
env["CFLAGS"] += ' -I{}/sources/python/{}/include/python/'.\
format(self.ctx.ndk_dir, self.ctx.python_recipe.version[0:3])

env['STRIP'] = '{}-strip --strip-unneeded'.format(command_prefix)
env['MAKE'] = 'make -j5'
env['READELF'] = '{}-readelf'.format(command_prefix)
Expand All @@ -180,9 +174,6 @@ def get_env(self, with_flags_in_cc=True, clang=False):
env['ARCH'] = self.arch
env['NDK_API'] = 'android-{}'.format(str(self.ctx.ndk_api))

if self.ctx.python_recipe and self.ctx.python_recipe.from_crystax:
env['CRYSTAX_PYTHON_VERSION'] = self.ctx.python_recipe.version

return env


Expand Down
8 changes: 1 addition & 7 deletions pythonforandroid/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,7 @@ class Bootstrap(object):
distribution = None

# All bootstraps should include Python in some way:
recipe_depends = [
("python2", "python3", "python3crystax"),
'android',
]
recipe_depends = [("python2", "python3"), 'android']

can_be_chosen_automatically = True
'''Determines whether the bootstrap can be chosen as one that
Expand Down Expand Up @@ -345,9 +342,6 @@ def _unpack_aar(self, aar, arch):

def strip_libraries(self, arch):
info('Stripping libraries')
if self.ctx.python_recipe.from_crystax:
info('Python was loaded from CrystaX, skipping strip')
return
env = arch.get_env()
tokens = shlex.split(env['STRIP'])
strip = sh.Command(tokens[0])
Expand Down
19 changes: 8 additions & 11 deletions pythonforandroid/bootstraps/common/build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,7 @@ def make_package(args):
shutil.copyfile(join(args.private, "main.py"),
join(main_py_only_dir, "main.py"))
tar_dirs.append(main_py_only_dir)
for python_bundle_dir in ('private',
'crystax_python',
'_python_bundle'):
for python_bundle_dir in ('private', '_python_bundle'):
if exists(python_bundle_dir):
tar_dirs.append(python_bundle_dir)
if get_bootstrap_name() == "webview":
Expand Down Expand Up @@ -783,14 +781,13 @@ def _read_configuration():
if args.try_system_python_compile:
# Hardcoding python2.7 is okay for now, as python3 skips the
# compilation anyway
if not exists('crystax_python'):
python_executable = 'python2.7'
try:
subprocess.call([python_executable, '--version'])
except (OSError, subprocess.CalledProcessError):
pass
else:
PYTHON = python_executable
python_executable = 'python2.7'
try:
subprocess.call([python_executable, '--version'])
except (OSError, subprocess.CalledProcessError):
pass
else:
PYTHON = python_executable

if args.no_compile_pyo:
PYTHON = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,3 @@ LOCAL_LDLIBS := -lGLESv1_CM -lGLESv2 -llog $(EXTRA_LDLIBS)
LOCAL_LDFLAGS += -L$(PYTHON_LINK_ROOT) $(APPLICATION_ADDITIONAL_LDFLAGS)

include $(BUILD_SHARED_LIBRARY)

ifdef CRYSTAX_PYTHON_VERSION
$(call import-module,python/$(CRYSTAX_PYTHON_VERSION))
endif
Original file line number Diff line number Diff line change
Expand Up @@ -165,26 +165,14 @@ int main(int argc, char *argv[]) {
// Set up the python path
char paths[256];

char crystax_python_dir[256];
snprintf(crystax_python_dir, 256,
"%s/crystax_python", getenv("ANDROID_UNPACK"));
char python_bundle_dir[256];
snprintf(python_bundle_dir, 256,
"%s/_python_bundle", getenv("ANDROID_UNPACK"));
if (dir_exists(crystax_python_dir) || dir_exists(python_bundle_dir)) {
if (dir_exists(crystax_python_dir)) {
LOGP("crystax_python exists");
snprintf(paths, 256,
"%s/stdlib.zip:%s/modules",
crystax_python_dir, crystax_python_dir);
}

if (dir_exists(python_bundle_dir)) {
LOGP("_python_bundle dir exists");
snprintf(paths, 256,
"%s/stdlib.zip:%s/modules",
python_bundle_dir, python_bundle_dir);
}
if (dir_exists(python_bundle_dir)) {
LOGP("_python_bundle dir exists");
snprintf(paths, 256,
"%s/stdlib.zip:%s/modules",
python_bundle_dir, python_bundle_dir);

LOGP("calculated paths to be...");
LOGP(paths);
Expand All @@ -196,10 +184,8 @@ int main(int argc, char *argv[]) {

LOGP("set wchar paths...");
} else {
// We do not expect to see crystax_python any more, so no point
// reminding the user about it. If it does exist, we'll have
// logged it earlier.
LOGP("_python_bundle does not exist");
LOGP("_python_bundle does not exist...this not looks good, all python"
" recipes should have this folder, should we expect a crash soon?");
}

Py_Initialize();
Expand Down Expand Up @@ -234,18 +220,6 @@ int main(int argc, char *argv[]) {
PyRun_SimpleString("import sys, posix\n");

char add_site_packages_dir[256];
if (dir_exists(crystax_python_dir)) {
snprintf(add_site_packages_dir, 256,
"sys.path.append('%s/site-packages')",
crystax_python_dir);

PyRun_SimpleString("import sys\n"
"sys.argv = ['notaninterpreterreally']\n"
"from os.path import realpath, join, dirname");
PyRun_SimpleString(add_site_packages_dir);
/* "sys.path.append(join(dirname(realpath(__file__)), 'site-packages'))") */
PyRun_SimpleString("sys.path = ['.'] + sys.path");
}

if (dir_exists(python_bundle_dir)) {
snprintf(add_site_packages_dir, 256,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ protected static void addLibraryIfExists(ArrayList<String> libsList, String patt

protected static ArrayList<String> getLibraries(File libsDir) {
ArrayList<String> libsList = new ArrayList<String>();
addLibraryIfExists(libsList, "crystax", libsDir);
addLibraryIfExists(libsList, "sqlite3", libsDir);
addLibraryIfExists(libsList, "ffi", libsDir);
addLibraryIfExists(libsList, "ssl.*", libsDir);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ protected static void addLibraryIfExists(ArrayList<String> libsList, String patt

protected static ArrayList<String> getLibraries(File libsDir) {
ArrayList<String> libsList = new ArrayList<String>();
addLibraryIfExists(libsList, "crystax", libsDir);
addLibraryIfExists(libsList, "sqlite3", libsDir);
addLibraryIfExists(libsList, "ffi", libsDir);
addLibraryIfExists(libsList, "png16", libsDir);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,3 @@ LOCAL_LDLIBS := -llog $(EXTRA_LDLIBS)
LOCAL_LDFLAGS += -L$(PYTHON_LINK_ROOT) $(APPLICATION_ADDITIONAL_LDFLAGS)

include $(BUILD_SHARED_LIBRARY)

ifdef CRYSTAX_PYTHON_VERSION
$(call import-module,python/$(CRYSTAX_PYTHON_VERSION))
endif
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,3 @@ LOCAL_LDLIBS := -llog $(EXTRA_LDLIBS)
LOCAL_LDFLAGS += -L$(PYTHON_LINK_ROOT) $(APPLICATION_ADDITIONAL_LDFLAGS)

include $(BUILD_SHARED_LIBRARY)

ifdef CRYSTAX_PYTHON_VERSION
$(call import-module,python/$(CRYSTAX_PYTHON_VERSION))
endif
7 changes: 5 additions & 2 deletions pythonforandroid/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,10 +561,13 @@ def build_recipes(build_order, python_modules, ctx, project_dir,

# 4) biglink everything
info_main('# Biglinking object files')
if not ctx.python_recipe or not ctx.python_recipe.from_crystax:
if not ctx.python_recipe:
biglink(ctx, arch)
else:
info('NDK is crystax, skipping biglink (will this work?)')
warning(
"Context's python recipe found, "
"skipping biglink (will this work?)"
)

# 5) postbuild packages
info_main('# Postbuilding recipes')
Expand Down
14 changes: 1 addition & 13 deletions pythonforandroid/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,9 @@ class GuestPythonRecipe(TargetPythonRecipe):
this limitation.
'''

from_crystax = False
'''True if the python is used from CrystaX, False otherwise (i.e. if
it is built by p4a).'''

configure_args = ()
'''The configure arguments needed to build the python recipe. Those are
used in method :meth:`build_arch` (if not overwritten like python3crystax's
used in method :meth:`build_arch` (if not overwritten like python3's
recipe does).

.. note:: This variable should be properly set in subclass.
Expand Down Expand Up @@ -108,10 +104,6 @@ def __init__(self, *args, **kwargs):
super(GuestPythonRecipe, self).__init__(*args, **kwargs)

def get_recipe_env(self, arch=None, with_flags_in_cc=True):
if self.from_crystax:
return super(GuestPythonRecipe, self).get_recipe_env(
arch=arch, with_flags_in_cc=with_flags_in_cc)

env = environ.copy()

android_host = env['HOSTARCH'] = arch.command_prefix
Expand Down Expand Up @@ -215,10 +207,6 @@ def add_flags(include_flags, link_dirs, link_libs):

def prebuild_arch(self, arch):
super(TargetPythonRecipe, self).prebuild_arch(arch)
if self.from_crystax and self.ctx.ndk != 'crystax':
raise BuildInterruptingException(
'The {} recipe can only be built when using the CrystaX NDK. '
'Exiting.'.format(self.name))
self.ctx.python_recipe = self

def build_arch(self, arch):
Expand Down
Loading