Skip to content

Commit 2b33eae

Browse files
opacaminclement
andauthored
🔥 Drop Python 2 support (kivy#2105)
* 🔥 Remove `hostpython2` recipe * 🔥 Remove `python2` recipe * 🔥 Remove python2 related from `ci/constants` * 🔥 Remove python2 environ/tests from `tox` * 🔥 Remove python2 code from `PythonUtil.java` * 🔥 Remove python2 patch from `recipes/numpy` * 🔥 Remove python2 code from `ci/rebuild_updated_recipes` * 🔥 Remove `test_entrypoints_python2.py` * 🔥 Remove python2 code from `start.c` * 🔥 Remove python2 testapps * 🔥 Remove python2 code from `bs/common/build/build.py` * 🍱 Update shebang: from `python2` to `python` * 🍱 Update requirements for `testlauncher_setup` * 🔥 Remove python2 from class `Bootstrap.recipe_depends` * 🔥 Remove python2 code from `recipe.py` * 🔥 Remove `Dockerfile.py2` * 🍱 Update docstring example for `ToolchainCL.recipes` `python2` it will not be a conflict anymore, since it doesn't exist. * 🔥 Remove `note` about `python2` target * 🍱 Update `android` recipe to avoid `python2` * 🔥 Remove `python2` from recipes's `depends` * 🔥 Remove `hostpython2` from recipes's `depends` * 🔥 Remove `python2` from recipes's `conflicts` * 🍱 Change `hostpython2` to `hostpython3` for `mysqldb` recipe * 🔥 Remove python2 code from `python` module * ✅ Update tests to work without `python2` * 🍱 Update `ndghttpsclient` recipe? This is strange...that recipe should be in a folder right? * 🔥 Remove python2 tests from `Makefile`, `travis.yml` and `push.yml` * 🔥 Remove `make_python_zip` Because we don't use it anymore. We used to package `python2` but our `python3` was never zipped with that function, so there is no point to maintain it now that we get rid of python2. * 📝 Update docs * Clean up README for Python 2 changes * Update Python version support documentation * Removed Python 2 app build from release process This build was only there to check Python 2 support, so it's fine to skip it now. * Made note about python2 support more explicit * Changed a /usr/bin/env call to explicitly python3 I think being explicit is still best practice, correct me if I'm wrong. We don't really support calling this script directly any more anyway, but I guess may as well do it right! Co-authored-by: Alexander Taylor <alexanderjohntaylor@gmail.com>
1 parent c47f697 commit 2b33eae

Some content is hidden

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

65 files changed

+84
-1189
lines changed

.github/workflows/push.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
- name: Build apk for Python 3 ${{ matrix.build-arch }}
5858
run: |
5959
mkdir -p apks
60-
make docker/run/make/with-artifact/testapps/python3/${{ matrix.build-arch }}
60+
make docker/run/make/with-artifact/testapps/${{ matrix.build-arch }}
6161
- uses: actions/upload-artifact@v1
6262
with:
6363
name: bdisttest_python3_sqlite_openssl_googlendk__${{ matrix.build-arch }}-debug-1.1.apk

.travis.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ jobs:
3636
- tox -- tests/ --ignore tests/test_pythonpackage.py
3737
name: "Tox Pep8"
3838
env: TOXENV=pep8
39-
- <<: *unittests
40-
name: "Tox Python 2"
41-
env: TOXENV=py27
4239
- <<: *unittests
4340
name: "Tox Python 3 & Coverage"
4441
env: TOXENV=py3
@@ -48,7 +45,7 @@ jobs:
4845
name: Python 3 arm64-v8a (with numpy)
4946
stage: build testapps
5047
before_script: make docker/pull
51-
script: make docker/run/make/testapps/python3/arm64-v8a
48+
script: make docker/run/make/testapps/arm64-v8a
5249
- <<: *testapps
5350
name: Python 3 armeabi-v7a
5451
os: osx
@@ -57,10 +54,7 @@ jobs:
5754
# installs java 1.8, android's SDK/NDK and p4a
5855
- make -f ci/makefiles/osx.mk
5956
- export JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
60-
script: make testapps/python3/armeabi-v7a PYTHON_WITH_VERSION=python3
61-
- <<: *testapps
62-
name: Python 2 armeabi-v7a
63-
script: make docker/run/make/testapps/python2/armeabi-v7a
57+
script: make testapps/armeabi-v7a PYTHON_WITH_VERSION=python3
6458
- <<: *testapps
6559
name: Rebuild updated recipes
6660
script: travis_wait 30 make docker/run/make/rebuild_updated_recipes

Dockerfile.py2

Lines changed: 0 additions & 94 deletions
This file was deleted.

Makefile

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,13 @@ rebuild_updated_recipes: virtualenv
3535
ANDROID_SDK_HOME=$(ANDROID_SDK_HOME) ANDROID_NDK_HOME=$(ANDROID_NDK_HOME) \
3636
$(PYTHON) ci/rebuild_updated_recipes.py
3737

38-
testapps/python2/armeabi-v7a: virtualenv
39-
. $(ACTIVATE) && cd testapps/ && \
40-
python setup_testapp_python2_sqlite_openssl.py apk --sdk-dir $(ANDROID_SDK_HOME) --ndk-dir $(ANDROID_NDK_HOME) \
41-
--requirements sdl2,pyjnius,kivy,python2,openssl,requests,sqlite3,setuptools
42-
43-
testapps/python3/arm64-v8a: virtualenv
38+
testapps/arm64-v8a: virtualenv
4439
. $(ACTIVATE) && cd testapps/ && \
4540
python setup_testapp_python3_sqlite_openssl.py apk --sdk-dir $(ANDROID_SDK_HOME) --ndk-dir $(ANDROID_NDK_HOME) \
4641
--requirements libffi,sdl2,pyjnius,kivy,python3,openssl,requests,sqlite3,setuptools,numpy \
4742
--arch=arm64-v8a
4843

49-
testapps/python3/armeabi-v7a: virtualenv
44+
testapps/armeabi-v7a: virtualenv
5045
. $(ACTIVATE) && cd testapps/ && \
5146
python setup_testapp_python3_sqlite_openssl.py apk --sdk-dir $(ANDROID_SDK_HOME) --ndk-dir $(ANDROID_NDK_HOME) \
5247
--arch=armeabi-v7a
@@ -77,11 +72,7 @@ docker/run/make/%: docker/build
7772
docker run --rm --env-file=.env $(DOCKER_IMAGE) make $*
7873

7974
docker/run/make/with-artifact/%: docker/build
80-
ifeq (,$(findstring python3,$($*)))
8175
$(eval $@_APP_NAME := bdisttest_python3_sqlite_openssl_googlendk)
82-
else
83-
$(eval $@_APP_NAME := bdisttest_python2_sqlite_openssl)
84-
endif
8576
$(eval $@_APP_ARCH := $(shell basename $*))
8677
docker run --name p4a-latest --env-file=.env $(DOCKER_IMAGE) make $*
8778
docker cp p4a-latest:/home/user/app/testapps/$($@_APP_NAME)__$($@_APP_ARCH)-debug-1.1-.apk ./apks

README.md

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -102,23 +102,13 @@ new recipe for python3 (3.7.1) had a new build system which was
102102
applied to the ancient python recipe, allowing us to bump the python2
103103
version number to 2.7.15. This change unified the build process for
104104
both python recipes, and probably solved various issues detected over the
105-
years. It should also be mentioned that these **unified python recipes**
106-
require a **minimum target api level of 21**,
107-
*Android 5.0 - Lollipop*, so in the case that you need to build targeting an
105+
years. These **unified python recipes** require a **minimum target api level of 21**,
106+
*Android 5.0 - Lollipop*. If you need to build targeting an
108107
api level below 21, you should use an older version of python-for-android
109108
(<=0.7.1).
110109

111-
Be aware that this project is in constant development so, as per time of writing,
112-
you should use a minimum on Android's NDK r19, and ``we recommend using NDK r19b``.
113-
This is because the toolchains installed by
114-
default with the NDK can be used *in-place* and the python-for-android project
115-
has been adapted for that feature. Also be aware that more recent versions of the
116-
Android's NDK may not work.
117-
118-
Those mentioned changes has been done this way to make easier the transition
119-
between python3 and python2. We will slowly phase out python2 support
120-
towards 2020...so...if you are using python2 in your projects you should
121-
consider migrating it into python3.
110+
On March of 2020 we dropped support for creating apps that use Python 2. The latest
111+
python-for-android release that supported building Python 2 was version 2019.10.6.
122112

123113
## Contributors
124114

ci/constants.py

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2,59 +2,12 @@
22

33

44
class TargetPython(Enum):
5-
python2 = 0
65
python3 = 2
76

87

98
# recipes that currently break the build
109
# a recipe could be broken for a target Python and not for the other,
1110
# hence we're maintaining one list per Python target
12-
BROKEN_RECIPES_PYTHON2 = set([
13-
# pythonhelpers.h:12:18: fatal error: string: No such file or directory
14-
'atom',
15-
# https://github.com/kivy/python-for-android/issues/550
16-
'audiostream',
17-
'brokenrecipe',
18-
'evdev',
19-
# distutils.errors.DistutilsError
20-
# Could not find suitable distribution for Requirement.parse('cython')
21-
'ffpyplayer',
22-
'flask',
23-
'groestlcoin_hash',
24-
# https://github.com/kivy/python-for-android/issues/1354
25-
'kiwisolver',
26-
'libmysqlclient',
27-
'libsecp256k1',
28-
'libtribler',
29-
'ndghttpsclient',
30-
'm2crypto',
31-
# ImportError: No module named setuptools
32-
'netifaces',
33-
'Pillow',
34-
# depends on cffi that still seems to have compilation issues
35-
'protobuf_cpp',
36-
'xeddsa',
37-
'x3dh',
38-
'pynacl',
39-
'doubleratchet',
40-
'omemo',
41-
# requires `libpq-dev` system dependency e.g. for `pg_config` binary
42-
'psycopg2',
43-
# most likely some setup in the Docker container, because it works in host
44-
'pyjnius', 'pyopenal',
45-
'pyproj',
46-
'pysdl2',
47-
'pyzmq',
48-
'secp256k1',
49-
'shapely',
50-
# mpmath package with a version >= 0.19 required
51-
'sympy',
52-
'twisted',
53-
'vlc',
54-
'websocket-client',
55-
'zeroconf',
56-
'zope',
57-
])
5811
BROKEN_RECIPES_PYTHON3 = set([
5912
'brokenrecipe',
6013
# enum34 is not compatible with Python 3.6 standard library
@@ -76,11 +29,10 @@ class TargetPython(Enum):
7629
])
7730

7831
BROKEN_RECIPES = {
79-
TargetPython.python2: BROKEN_RECIPES_PYTHON2,
8032
TargetPython.python3: BROKEN_RECIPES_PYTHON3,
8133
}
8234
# recipes that were already built will be skipped
8335
CORE_RECIPES = set([
8436
'pyjnius', 'kivy', 'openssl', 'requests', 'sqlite3', 'setuptools',
85-
'numpy', 'android', 'hostpython2', 'hostpython3', 'python2', 'python3',
37+
'numpy', 'android', 'hostpython3', 'python3',
8638
])

ci/rebuild_updated_recipes.py

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,12 @@
1919
[ERROR]: Didn't find any valid dependency graphs.
2020
[ERROR]: This means that some of your requirements pull in conflicting dependencies.
2121
- only rebuilds on sdl2 bootstrap
22-
- supports mainly python3 with fallback to python2
2322
"""
2423
import sh
2524
import os
2625
from pythonforandroid.build import Context
2726
from pythonforandroid import logger
28-
from pythonforandroid.graph import get_recipe_order_and_bootstrap
2927
from pythonforandroid.toolchain import current_directory
30-
from pythonforandroid.util import BuildInterruptingException
3128
from pythonforandroid.recipe import Recipe
3229
from ci.constants import TargetPython, CORE_RECIPES, BROKEN_RECIPES
3330

@@ -55,11 +52,9 @@ def build(target_python, requirements):
5552
"""
5653
if not requirements:
5754
return
58-
testapp = 'setup_testapp_python2.py'
55+
testapp = 'setup_testapp_python3_sqlite_openssl.py'
5956
android_sdk_home = os.environ['ANDROID_SDK_HOME']
6057
android_ndk_home = os.environ['ANDROID_NDK_HOME']
61-
if target_python == TargetPython.python3:
62-
testapp = 'setup_testapp_python3_sqlite_openssl.py'
6358
requirements.add(target_python.name)
6459
requirements = ','.join(requirements)
6560
logger.info('requirements: {}'.format(requirements))
@@ -91,16 +86,6 @@ def main():
9186
'removed {} from recipes because deleted'.format(recipe_name)
9287
)
9388

94-
# forces the default target
95-
recipes_and_target = recipes | set([target_python.name])
96-
try:
97-
build_order, python_modules, bs = get_recipe_order_and_bootstrap(
98-
context, recipes_and_target, None)
99-
except BuildInterruptingException:
100-
# fallback to python2 if default target is not compatible
101-
logger.info('incompatible with {}'.format(target_python.name))
102-
target_python = TargetPython.python2
103-
logger.info('falling back to {}'.format(target_python.name))
10489
# removing the known broken recipe for the given target
10590
broken_recipes = BROKEN_RECIPES[target_python]
10691
recipes -= broken_recipes

doc/source/buildoptions.rst

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,14 @@ This page contains instructions for using different build options.
88
Python versions
99
---------------
1010

11-
python2
12-
~~~~~~~
13-
14-
Select this by adding it in your requirements, e.g. ``--requirements=python2``.
15-
16-
This option builds Python 2.7.2 for your selected Android
17-
architecture. There are no special requirements, all the building is
18-
done locally.
19-
20-
21-
python3
22-
~~~~~~~
23-
24-
Python3 is supported in two ways. The default method uses CPython 3.7+
25-
and works with any recent version of the Android NDK.
26-
27-
Select Python 3 by adding it to your requirements,
28-
e.g. ``--requirements=python3``.
29-
30-
.. note:: ctypes is not included automatically, if you would like to use it
31-
then add libffi to your requirements,
32-
e.g. ``--requirements=kivy,libffi,python3``.
33-
34-
35-
CrystaX python3
36-
~~~~~~~~~~~~~~~
11+
python-for-android supports using Python 3.7 or higher. To explicitly select a Python
12+
version in your requirements, use e.g. ``--requirements=python3==3.7.1,hostpython3==3.7.1``.
3713

38-
python-for-android no longer supports building for Python 3 using the CrystaX
39-
NDK. Instead, use the python3 recipe, which can be built using the normal
40-
Google NDK.
14+
The last python-for-android version supporting Python2 was `v2019.10.06
15+
<https://github.com/kivy/python-for-android/archive/v2019.10.06.zip>`__
4116

42-
.. note:: The last python-for-android version supporting CrystaX was `0.7.0.
17+
Python-for-android no longer supports building for Python 3 using the CrystaX
18+
NDK. The last python-for-android version supporting CrystaX was `0.7.0.
4319
<https://github.com/kivy/python-for-android/archive/0.7.0.zip>`__
4420

4521
.. _bootstrap_build_options:
@@ -60,7 +36,7 @@ sdl2
6036
~~~~
6137

6238
Use this with ``--bootstrap=sdl2``, or just include the
63-
``sdl2`` recipe, e.g. ``--requirements=sdl2,python2``.
39+
``sdl2`` recipe, e.g. ``--requirements=sdl2,python3``.
6440

6541
SDL2 is a popular cross-platform depelopment library, particularly for
6642
games. It has its own Android project support, which
@@ -120,7 +96,7 @@ webview
12096
~~~~~~~
12197

12298
You can use this with ``--bootstrap=webview``, or include the
123-
``webviewjni`` recipe, e.g. ``--requirements=webviewjni,python2``.
99+
``webviewjni`` recipe, e.g. ``--requirements=webviewjni,python3``.
124100

125101
The webview bootstrap gui is, per the name, a WebView displaying a
126102
webpage, but this page is hosted on the device via a Python

doc/source/contribute.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,6 @@ Release checklist
7575
- `python3 setup_testapp_python3_sqlite_openssl.py apk`
7676
- [ ] `armeabi-v7a`
7777
- [ ] `arm64-v8a`
78-
- `python3 setup_testapp_python2.py apk`
79-
- [ ] `armeabi-v7a`
80-
- [ ] `arm64-v8a`
8178
- [ ] Check that the version number is correct
8279

8380

0 commit comments

Comments
 (0)