Skip to content

[R.I.P.] Remove python2legacy and hospython2legacy #1831

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

Merged
merged 1 commit into from
Jun 2, 2019
Merged
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
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,14 @@ new recipe for python3 (3.7.1) has a new build system which has been
applied to the ancient python recipe, allowing us to bump the python2
version number to 2.7.15. This change, unifies the build process for
both python recipes, and probably solve some issues detected over the
years. Also should be mentioned that the old python recipe is still
usable, and has been renamed to `python2legacy`. This `python2legacy`
recipe allow us to build with a minimum api lower than 21, which is
not the case for the new python recipes which are limited to a minimum
api of 21. All this work has been done using android ndk version r17c,
and your build should success with that version...but be aware that
the project is in constant development so...the ndk version will
change at some time.
years. Also should be mentioned that this **unified python recipes**
require to target to a **minimum api level of 21**,
*Android 5.0 - Lollipop*, so in case the you need to build targeting an
api level below 21, you must use an old version of python-for-android
(<=0.7.1). All this work has been done using android ndk version r17c,
and your build should success with that version...but be aware that the
project is in constant development so...the ndk version will change at
some time.

Those mentioned changes has been done this way to make easier the transition
between python3 and python2. We will slowly phase out python2 support
Expand Down
4 changes: 1 addition & 3 deletions pythonforandroid/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Bootstrap(object):

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

Expand Down Expand Up @@ -275,8 +275,6 @@ def strip_libraries(self, arch):

libs_dir = join(self.dist_dir, '_python_bundle',
'_python_bundle', 'modules')
if self.ctx.python_recipe.name == 'python2legacy':
libs_dir = join(self.dist_dir, 'private')
filens = shprint(sh.find, libs_dir, join(self.dist_dir, 'libs'),
'-iname', '*.so', _env=env).stdout.decode('utf-8')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,20 +232,6 @@ int main(int argc, char *argv[]) {
* replace sys.path with our path
*/
PyRun_SimpleString("import sys, posix\n");
if (dir_exists("lib")) {
/* If we built our own python, set up the paths correctly.
* This is only the case if we are using the python2legacy recipe
*/
LOGP("Setting up python from ANDROID_APP_PATH");
PyRun_SimpleString("private = posix.environ['ANDROID_APP_PATH']\n"
"argument = posix.environ['ANDROID_ARGUMENT']\n"
"sys.path[:] = [ \n"
" private + '/lib/python27.zip', \n"
" private + '/lib/python2.7/', \n"
" private + '/lib/python2.7/lib-dynload/', \n"
" private + '/lib/python2.7/site-packages/', \n"
" argument ]\n");
}

char add_site_packages_dir[256];
if (dir_exists(crystax_python_dir)) {
Expand Down
5 changes: 0 additions & 5 deletions pythonforandroid/bootstraps/sdl2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ def run_distribute(self):
info("Copying Python distribution")

python_bundle_dir = join('_python_bundle', '_python_bundle')
if 'python2legacy' in self.ctx.recipe_build_order:
# a special case with its own packaging location
python_bundle_dir = 'private'
# And also must had an install directory, make sure of that
self.ctx.python_recipe.create_python_install(self.dist_dir)

self.distribute_libs(arch, [self.ctx.get_libs_dir(arch.arch)])
self.distribute_javaclasses(self.ctx.javaclass_dir,
Expand Down
3 changes: 0 additions & 3 deletions pythonforandroid/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,9 +471,6 @@ def get_site_packages_dir(self, arch=None):
'''Returns the location of site-packages in the python-install build
dir.
'''
if self.python_recipe.name == 'python2legacy':
return join(self.get_python_install_dir(),
'lib', 'python2.7', 'site-packages')
return self.get_python_install_dir()

def get_libs_dir(self, arch):
Expand Down
59 changes: 15 additions & 44 deletions pythonforandroid/recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ class PythonRecipe(Recipe):
def __init__(self, *args, **kwargs):
super(PythonRecipe, self).__init__(*args, **kwargs)
depends = self.depends
depends.append(('python2', 'python2legacy', 'python3', 'python3crystax'))
depends.append(('python2', 'python3', 'python3crystax'))
depends = list(set(depends))
self.depends = depends

Expand All @@ -753,7 +753,7 @@ def real_hostpython_location(self):
host_build = Recipe.get_recipe(host_name, self.ctx).get_build_dir()
if host_name in ['hostpython2', 'hostpython3']:
return join(host_build, 'native-build', 'python')
elif host_name in ['hostpython3crystax', 'hostpython2legacy']:
elif host_name in ['hostpython3crystax']:
return join(host_build, 'hostpython')
else:
python_recipe = self.ctx.python_recipe
Expand Down Expand Up @@ -795,10 +795,6 @@ def get_recipe_env(self, arch=None, with_flags_in_cc=True):
self.ctx.python_recipe.major_minor_version_string)
if python_name == 'python3':
env['LDFLAGS'] += 'm'
elif python_name == 'python2legacy':
env['PYTHON_ROOT'] = join(
self.ctx.python_recipe.get_build_dir(
arch.arch), 'python-install')
else:
ndk_dir_python = join(self.ctx.ndk_dir, 'sources',
'python', python_version)
Expand Down Expand Up @@ -850,27 +846,11 @@ def install_python_package(self, arch, name=None, env=None, is_dir=True):

with current_directory(self.get_build_dir(arch.arch)):
hostpython = sh.Command(self.hostpython_location)

if self.ctx.python_recipe.name != 'python2legacy':
hpenv = env.copy()
shprint(hostpython, 'setup.py', 'install', '-O2',
'--root={}'.format(self.ctx.get_python_install_dir()),
'--install-lib=.',
_env=hpenv, *self.setup_extra_args)
elif self.call_hostpython_via_targetpython:
shprint(hostpython, 'setup.py', 'install', '-O2', _env=env,
*self.setup_extra_args)
else: # python2legacy
hppath = join(dirname(self.hostpython_location), 'Lib', 'site-packages')
hpenv = env.copy()
if 'PYTHONPATH' in hpenv:
hpenv['PYTHONPATH'] = ':'.join([hppath] + hpenv['PYTHONPATH'].split(':'))
else:
hpenv['PYTHONPATH'] = hppath
shprint(hostpython, 'setup.py', 'install', '-O2',
'--root={}'.format(self.ctx.get_python_install_dir()),
'--install-lib=lib/python2.7/site-packages',
_env=hpenv, *self.setup_extra_args)
hpenv = env.copy()
shprint(hostpython, 'setup.py', 'install', '-O2',
'--root={}'.format(self.ctx.get_python_install_dir()),
'--install-lib=.',
_env=hpenv, *self.setup_extra_args)

# If asked, also install in the hostpython build dir
if self.install_in_hostpython:
Expand Down Expand Up @@ -974,7 +954,7 @@ class CythonRecipe(PythonRecipe):
def __init__(self, *args, **kwargs):
super(CythonRecipe, self).__init__(*args, **kwargs)
depends = self.depends
depends.append(('python2', 'python2legacy', 'python3', 'python3crystax'))
depends.append(('python2', 'python3', 'python3crystax'))
depends = list(set(depends))
self.depends = depends

Expand Down Expand Up @@ -1022,18 +1002,12 @@ def strip_object_files(self, arch, env, build_dir=None):
build_dir = self.get_build_dir(arch.arch)
with current_directory(build_dir):
info('Stripping object files')
if self.ctx.python_recipe.name == 'python2legacy':
info('Stripping object files')
build_lib = glob.glob('./build/lib*')
shprint(sh.find, build_lib[0], '-name', '*.o', '-exec',
env['STRIP'], '{}', ';', _env=env)
else:
shprint(sh.find, '.', '-iname', '*.so', '-exec',
'/usr/bin/echo', '{}', ';', _env=env)
shprint(sh.find, '.', '-iname', '*.so', '-exec',
env['STRIP'].split(' ')[0], '--strip-unneeded',
# '/usr/bin/strip', '--strip-unneeded',
'{}', ';', _env=env)
shprint(sh.find, '.', '-iname', '*.so', '-exec',
'/usr/bin/echo', '{}', ';', _env=env)
shprint(sh.find, '.', '-iname', '*.so', '-exec',
env['STRIP'].split(' ')[0], '--strip-unneeded',
# '/usr/bin/strip', '--strip-unneeded',
'{}', ';', _env=env)

def cythonize_file(self, env, build_dir, filename):
short_filename = filename
Expand Down Expand Up @@ -1071,10 +1045,7 @@ def get_recipe_env(self, arch, with_flags_in_cc=True):
env['LDFLAGS'] = (env['LDFLAGS'] +
' -L{}'.format(join(self.ctx.bootstrap.build_dir, 'libs', arch.arch)))

if self.ctx.python_recipe.name == 'python2legacy':
env['LDSHARED'] = join(self.ctx.root_dir, 'tools', 'liblink.sh')
else:
env['LDSHARED'] = env['CC'] + ' -shared'
env['LDSHARED'] = env['CC'] + ' -shared'
# shprint(sh.whereis, env['LDSHARED'], _env=env)
env['LIBLINK'] = 'NOTNONE'
env['NDKPLATFORM'] = self.ctx.ndk_platform
Expand Down
2 changes: 1 addition & 1 deletion pythonforandroid/recipes/hostpython2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Hostpython2Recipe(HostPythonRecipe):
'''
version = '2.7.15'
name = 'hostpython2'
conflicts = ['hostpython3', 'hostpython3crystax', 'hostpython2legacy']
conflicts = ['hostpython3', 'hostpython3crystax']


recipe = Hostpython2Recipe()
Loading