Skip to content

Commit ff42ca5

Browse files
authored
Merge pull request kivy#1831 from opacam/rip-python2-legacy
[R.I.P.] Remove `python2legacy` and `hospython2legacy`
2 parents e43c3cd + fa57687 commit ff42ca5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+31
-2203
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,14 @@ new recipe for python3 (3.7.1) has a new build system which has been
9797
applied to the ancient python recipe, allowing us to bump the python2
9898
version number to 2.7.15. This change, unifies the build process for
9999
both python recipes, and probably solve some issues detected over the
100-
years. Also should be mentioned that the old python recipe is still
101-
usable, and has been renamed to `python2legacy`. This `python2legacy`
102-
recipe allow us to build with a minimum api lower than 21, which is
103-
not the case for the new python recipes which are limited to a minimum
104-
api of 21. All this work has been done using android ndk version r17c,
105-
and your build should success with that version...but be aware that
106-
the project is in constant development so...the ndk version will
107-
change at some time.
100+
years. Also should be mentioned that this **unified python recipes**
101+
require to target to a **minimum api level of 21**,
102+
*Android 5.0 - Lollipop*, so in case the you need to build targeting an
103+
api level below 21, you must use an old version of python-for-android
104+
(<=0.7.1). All this work has been done using android ndk version r17c,
105+
and your build should success with that version...but be aware that the
106+
project is in constant development so...the ndk version will change at
107+
some time.
108108

109109
Those mentioned changes has been done this way to make easier the transition
110110
between python3 and python2. We will slowly phase out python2 support

pythonforandroid/bootstrap.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class Bootstrap(object):
5151

5252
# All bootstraps should include Python in some way:
5353
recipe_depends = [
54-
("python2", "python2legacy", "python3", "python3crystax"),
54+
("python2", "python3", "python3crystax"),
5555
'android',
5656
]
5757

@@ -275,8 +275,6 @@ def strip_libraries(self, arch):
275275

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

pythonforandroid/bootstraps/common/build/jni/application/src/start.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -232,20 +232,6 @@ int main(int argc, char *argv[]) {
232232
* replace sys.path with our path
233233
*/
234234
PyRun_SimpleString("import sys, posix\n");
235-
if (dir_exists("lib")) {
236-
/* If we built our own python, set up the paths correctly.
237-
* This is only the case if we are using the python2legacy recipe
238-
*/
239-
LOGP("Setting up python from ANDROID_APP_PATH");
240-
PyRun_SimpleString("private = posix.environ['ANDROID_APP_PATH']\n"
241-
"argument = posix.environ['ANDROID_ARGUMENT']\n"
242-
"sys.path[:] = [ \n"
243-
" private + '/lib/python27.zip', \n"
244-
" private + '/lib/python2.7/', \n"
245-
" private + '/lib/python2.7/lib-dynload/', \n"
246-
" private + '/lib/python2.7/site-packages/', \n"
247-
" argument ]\n");
248-
}
249235

250236
char add_site_packages_dir[256];
251237
if (dir_exists(crystax_python_dir)) {

pythonforandroid/bootstraps/sdl2/__init__.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@ def run_distribute(self):
3434
info("Copying Python distribution")
3535

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

4338
self.distribute_libs(arch, [self.ctx.get_libs_dir(arch.arch)])
4439
self.distribute_javaclasses(self.ctx.javaclass_dir,

pythonforandroid/build.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -471,9 +471,6 @@ def get_site_packages_dir(self, arch=None):
471471
'''Returns the location of site-packages in the python-install build
472472
dir.
473473
'''
474-
if self.python_recipe.name == 'python2legacy':
475-
return join(self.get_python_install_dir(),
476-
'lib', 'python2.7', 'site-packages')
477474
return self.get_python_install_dir()
478475

479476
def get_libs_dir(self, arch):

pythonforandroid/recipe.py

Lines changed: 15 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ class PythonRecipe(Recipe):
730730
def __init__(self, *args, **kwargs):
731731
super(PythonRecipe, self).__init__(*args, **kwargs)
732732
depends = self.depends
733-
depends.append(('python2', 'python2legacy', 'python3', 'python3crystax'))
733+
depends.append(('python2', 'python3', 'python3crystax'))
734734
depends = list(set(depends))
735735
self.depends = depends
736736

@@ -753,7 +753,7 @@ def real_hostpython_location(self):
753753
host_build = Recipe.get_recipe(host_name, self.ctx).get_build_dir()
754754
if host_name in ['hostpython2', 'hostpython3']:
755755
return join(host_build, 'native-build', 'python')
756-
elif host_name in ['hostpython3crystax', 'hostpython2legacy']:
756+
elif host_name in ['hostpython3crystax']:
757757
return join(host_build, 'hostpython')
758758
else:
759759
python_recipe = self.ctx.python_recipe
@@ -795,10 +795,6 @@ def get_recipe_env(self, arch=None, with_flags_in_cc=True):
795795
self.ctx.python_recipe.major_minor_version_string)
796796
if python_name == 'python3':
797797
env['LDFLAGS'] += 'm'
798-
elif python_name == 'python2legacy':
799-
env['PYTHON_ROOT'] = join(
800-
self.ctx.python_recipe.get_build_dir(
801-
arch.arch), 'python-install')
802798
else:
803799
ndk_dir_python = join(self.ctx.ndk_dir, 'sources',
804800
'python', python_version)
@@ -850,27 +846,11 @@ def install_python_package(self, arch, name=None, env=None, is_dir=True):
850846

851847
with current_directory(self.get_build_dir(arch.arch)):
852848
hostpython = sh.Command(self.hostpython_location)
853-
854-
if self.ctx.python_recipe.name != 'python2legacy':
855-
hpenv = env.copy()
856-
shprint(hostpython, 'setup.py', 'install', '-O2',
857-
'--root={}'.format(self.ctx.get_python_install_dir()),
858-
'--install-lib=.',
859-
_env=hpenv, *self.setup_extra_args)
860-
elif self.call_hostpython_via_targetpython:
861-
shprint(hostpython, 'setup.py', 'install', '-O2', _env=env,
862-
*self.setup_extra_args)
863-
else: # python2legacy
864-
hppath = join(dirname(self.hostpython_location), 'Lib', 'site-packages')
865-
hpenv = env.copy()
866-
if 'PYTHONPATH' in hpenv:
867-
hpenv['PYTHONPATH'] = ':'.join([hppath] + hpenv['PYTHONPATH'].split(':'))
868-
else:
869-
hpenv['PYTHONPATH'] = hppath
870-
shprint(hostpython, 'setup.py', 'install', '-O2',
871-
'--root={}'.format(self.ctx.get_python_install_dir()),
872-
'--install-lib=lib/python2.7/site-packages',
873-
_env=hpenv, *self.setup_extra_args)
849+
hpenv = env.copy()
850+
shprint(hostpython, 'setup.py', 'install', '-O2',
851+
'--root={}'.format(self.ctx.get_python_install_dir()),
852+
'--install-lib=.',
853+
_env=hpenv, *self.setup_extra_args)
874854

875855
# If asked, also install in the hostpython build dir
876856
if self.install_in_hostpython:
@@ -974,7 +954,7 @@ class CythonRecipe(PythonRecipe):
974954
def __init__(self, *args, **kwargs):
975955
super(CythonRecipe, self).__init__(*args, **kwargs)
976956
depends = self.depends
977-
depends.append(('python2', 'python2legacy', 'python3', 'python3crystax'))
957+
depends.append(('python2', 'python3', 'python3crystax'))
978958
depends = list(set(depends))
979959
self.depends = depends
980960

@@ -1022,18 +1002,12 @@ def strip_object_files(self, arch, env, build_dir=None):
10221002
build_dir = self.get_build_dir(arch.arch)
10231003
with current_directory(build_dir):
10241004
info('Stripping object files')
1025-
if self.ctx.python_recipe.name == 'python2legacy':
1026-
info('Stripping object files')
1027-
build_lib = glob.glob('./build/lib*')
1028-
shprint(sh.find, build_lib[0], '-name', '*.o', '-exec',
1029-
env['STRIP'], '{}', ';', _env=env)
1030-
else:
1031-
shprint(sh.find, '.', '-iname', '*.so', '-exec',
1032-
'/usr/bin/echo', '{}', ';', _env=env)
1033-
shprint(sh.find, '.', '-iname', '*.so', '-exec',
1034-
env['STRIP'].split(' ')[0], '--strip-unneeded',
1035-
# '/usr/bin/strip', '--strip-unneeded',
1036-
'{}', ';', _env=env)
1005+
shprint(sh.find, '.', '-iname', '*.so', '-exec',
1006+
'/usr/bin/echo', '{}', ';', _env=env)
1007+
shprint(sh.find, '.', '-iname', '*.so', '-exec',
1008+
env['STRIP'].split(' ')[0], '--strip-unneeded',
1009+
# '/usr/bin/strip', '--strip-unneeded',
1010+
'{}', ';', _env=env)
10371011

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

1074-
if self.ctx.python_recipe.name == 'python2legacy':
1075-
env['LDSHARED'] = join(self.ctx.root_dir, 'tools', 'liblink.sh')
1076-
else:
1077-
env['LDSHARED'] = env['CC'] + ' -shared'
1048+
env['LDSHARED'] = env['CC'] + ' -shared'
10781049
# shprint(sh.whereis, env['LDSHARED'], _env=env)
10791050
env['LIBLINK'] = 'NOTNONE'
10801051
env['NDKPLATFORM'] = self.ctx.ndk_platform

pythonforandroid/recipes/hostpython2/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Hostpython2Recipe(HostPythonRecipe):
1212
'''
1313
version = '2.7.15'
1414
name = 'hostpython2'
15-
conflicts = ['hostpython3', 'hostpython3crystax', 'hostpython2legacy']
15+
conflicts = ['hostpython3', 'hostpython3crystax']
1616

1717

1818
recipe = Hostpython2Recipe()

0 commit comments

Comments
 (0)