Skip to content

Commit bcc2a0c

Browse files
authored
Merge pull request #10739 from SomberNight/202607_android_build
android build: use --no-isolation, hash-pin more deps, only one install of setuptools
2 parents f985656 + 6b79d16 commit bcc2a0c

10 files changed

Lines changed: 84 additions & 9 deletions

File tree

contrib/android/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ RUN apt -y update -qq \
176176
&& apt -y install -qq --no-install-recommends --allow-downgrades \
177177
libopengl-dev \
178178
libegl-dev \
179+
ninja-build \
179180
&& apt -y autoremove \
180181
&& apt -y clean
181182

@@ -225,7 +226,7 @@ RUN /opt/venv/bin/python3 -m pip install --no-build-isolation --no-dependencies
225226
-r /opt/deterministic-build/requirements-build-android.txt
226227

227228
# install buildozer
228-
ENV BUILDOZER_CHECKOUT_COMMIT="4403ecf445f10b5fbf7c74f4621bf2b922ad35b5"
229+
ENV BUILDOZER_CHECKOUT_COMMIT="6242e3e41365e70f76bd18f30992dcc5898ad40e"
229230
# ^ from branch electrum_20240930 (note: careful with force-pushing! see #8162)
230231
RUN cd /opt \
231232
&& git clone https://github.com/spesmilo/buildozer \
@@ -234,7 +235,7 @@ RUN cd /opt \
234235
&& /opt/venv/bin/python3 -m pip install --no-build-isolation --no-dependencies -e .
235236

236237
# install python-for-android
237-
ENV P4A_CHECKOUT_COMMIT="1098be6964cfc2156959e435e81c2c50f8398586"
238+
ENV P4A_CHECKOUT_COMMIT="8c0fcc9ef2e559918ca96ecde6e09fe521bb1427"
238239
# ^ from branch electrum_202602 (note: careful with force-pushing! see #8162)
239240
RUN cd /opt \
240241
&& git clone https://github.com/spesmilo/python-for-android \

contrib/android/p4a_recipes/hostpython3/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
assert HostPython3Recipe.depends == []
1010
assert HostPython3Recipe.python_depends == []
11+
assert HostPython3Recipe.patches == []
1112

1213

1314
class HostPython3RecipePinned(util.InheritedRecipeMixin, HostPython3Recipe):
@@ -18,6 +19,11 @@ class HostPython3RecipePinned(util.InheritedRecipeMixin, HostPython3Recipe):
1819
# use official releases from python.org that have sigs, instead of auto-generated archives from github
1920
url = 'https://www.python.org/ftp/python/{version}/Python-{version}.tgz'
2021

22+
# TODO: remove patch once CPython >= 3.12 is used (no more bundled setuptools)
23+
patches = [
24+
os.path.join(os.path.dirname(__file__), "patches", "cpython-311-ensurepip-no-setuptools.patch"),
25+
]
26+
2127
# this property overrides the default hostpython dependencies for PyProjectRecipe recipies
2228
pyproject_base_dependencies = [
2329
HashPinnedDependency(package="build==1.4.0",
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Backport of Python 3.12's removal of setuptools from ensurepip (gh-95299,
2+
https://github.com/python/cpython/pull/101039) onto CPython 3.11.
3+
4+
ensurepip is only used to bootstrap pip into hostpython. Without this patch
5+
it would also install its bundled, unpinned setuptools, which would later
6+
coexist with the hash-pinned setuptools we install ourselves: pip's
7+
"--target" mode cannot uninstall, so the stale setuptools-79.0.1.dist-info
8+
would survive next to the pinned version and which distribution gets picked
9+
up during the build depends on os.listdir() order, breaking reproducibility.
10+
11+
The now-unreferenced setuptools wheel in Lib/ensurepip/_bundled/ is left in
12+
the source tree ("patch" cannot delete binary files); it is never installed.
13+
14+
The deleted _SETUPTOOLS_VERSION line changes between CPython 3.11.x releases,
15+
so this patch is coupled to the CPython version pinned in our hostpython3
16+
recipe and must be refreshed together with it. Remove the patch when
17+
hostpython3 is >= 3.12.
18+
19+
--- a/Lib/ensurepip/__init__.py
20+
+++ b/Lib/ensurepip/__init__.py
21+
@@ -9,11 +9,9 @@
22+
23+
24+
__all__ = ["version", "bootstrap"]
25+
-_PACKAGE_NAMES = ('setuptools', 'pip')
26+
-_SETUPTOOLS_VERSION = "79.0.1"
27+
+_PACKAGE_NAMES = ('pip',)
28+
_PIP_VERSION = "24.0"
29+
_PROJECTS = [
30+
- ("setuptools", _SETUPTOOLS_VERSION, "py3"),
31+
("pip", _PIP_VERSION, "py3"),
32+
]
33+

contrib/android/p4a_recipes/packaging/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from pythonforandroid.recipes.packaging import PackagingRecipe
2+
from pythonforandroid.util import HashPinnedDependency
23

34

45
assert PackagingRecipe._version == "26.0"
@@ -8,6 +9,10 @@
89

910
class PackagingRecipePinned(PackagingRecipe):
1011
sha512sum = "27a066a7d65ba76189212973b6a0d162f3d361848b1b0c34a82865cf180b3284a837cc34206c297f002a73feae414e25a26c5960bb884a74ea337f582585f1d2"
12+
hostpython_prerequisites = [
13+
HashPinnedDependency(package="flit-core==3.12.0",
14+
hashes=['sha256:e7a0304069ea895172e3c7bb703292e992c5d1555dd1233ab7b5621b5b69e62c']),
15+
]
1116

1217

1318
recipe = PackagingRecipePinned()

contrib/android/p4a_recipes/pyjnius/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313

1414
class PyjniusRecipePinned(util.InheritedRecipeMixin, PyjniusRecipe):
1515
hostpython_prerequisites = [
16+
HashPinnedDependency(package="setuptools==80.9.0",
17+
hashes=['sha256:062d34222ad13e0cc312a4c02d73f059e86a4acbfbdea8f8f76b28c99f306922']),
18+
HashPinnedDependency(package="wheel==0.45.1",
19+
hashes=['sha256:708e7481cc80179af0e556bbf0cc00b8444c7321e2700b8d8580231d13017248']),
1620
HashPinnedDependency(package="Cython==3.1.8",
1721
hashes=['sha256:282b3c8e6abc3fea421919e862e898ffdd86fc0796009bdb5ffdf8211413219f'])
1822
]

contrib/android/p4a_recipes/pyqt6sip/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ class PyQt6SipRecipePinned(util.InheritedRecipeMixin, PyQt6SipRecipe):
1717
hostpython_prerequisites = [
1818
HashPinnedDependency(package="setuptools==80.9.0",
1919
hashes=['sha256:062d34222ad13e0cc312a4c02d73f059e86a4acbfbdea8f8f76b28c99f306922']),
20-
HashPinnedDependency(package="packaging==26.0",
21-
hashes=['sha256:b36f1fef9334a5588b4166f8bcd26a14e521f2b55e6b9de3aaa80d3ff7a37529']),
2220
]
2321

2422

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from pythonforandroid.recipes.setuptools import SetuptoolsRecipe
2+
from pythonforandroid.util import HashPinnedDependency
3+
4+
5+
assert SetuptoolsRecipe._version == "80.9.0"
6+
assert SetuptoolsRecipe.depends == ['python3']
7+
assert SetuptoolsRecipe.python_depends == []
8+
9+
10+
class SetuptoolsRecipePinned(SetuptoolsRecipe):
11+
sha512sum = "36eb1f219d29c6b9e135936bde2001ad70a971c8069cd0175d3a5325b450e6843a903d3f70043c9f534768ebeab8ab0c544b8f44456555d333f1ed72daa5c18b"
12+
hostpython_prerequisites = [
13+
HashPinnedDependency(package="setuptools==80.9.0",
14+
hashes=['sha256:062d34222ad13e0cc312a4c02d73f059e86a4acbfbdea8f8f76b28c99f306922']),
15+
]
16+
17+
18+
recipe = SetuptoolsRecipePinned()

contrib/android/p4a_recipes/sip/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from pythonforandroid.util import HashPinnedDependency
33

44
assert SipRecipe._version == "6.15.1"
5-
assert SipRecipe.depends == ["python3"], SipRecipe.depends
5+
assert SipRecipe.depends == ["python3", "packaging"], SipRecipe.depends
66
assert SipRecipe.python_depends == []
77

88

@@ -12,6 +12,11 @@ class SipRecipePinned(SipRecipe):
1212
hostpython_prerequisites = [
1313
HashPinnedDependency(package="setuptools==80.9.0",
1414
hashes=['sha256:062d34222ad13e0cc312a4c02d73f059e86a4acbfbdea8f8f76b28c99f306922']),
15+
HashPinnedDependency(package="setuptools-scm==8.3.1",
16+
hashes=['sha256:332ca0d43791b818b841213e76b1971b7711a960761c5bea5fc5cdb5196fbce3']),
17+
HashPinnedDependency(package="packaging==26.0", # pulled in by setuptools-scm
18+
hashes=['sha256:b36f1fef9334a5588b4166f8bcd26a14e521f2b55e6b9de3aaa80d3ff7a37529']),
19+
1520
]
1621

1722

contrib/deterministic-build/requirements-build-android.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
appdirs==1.4.4 \
22
--hash=sha256:7d5d0167b2b1ba821647616af46a749d1c653740dd0d2415100fe26e27afdf41
3+
build==1.4.0 \
4+
--hash=sha256:f1b91b925aa322be454f8330c6fb48b465da993d1e7e7e6fa35027ec49f3c936
35
colorama==0.4.5 \
46
--hash=sha256:e6c6b4334fc50988a639d9b98aa429a0b57da6e17b9a44f0451f930b6967b7a4
57
Cython==0.29.37 \
@@ -10,14 +12,14 @@ MarkupSafe==3.0.3 \
1012
--hash=sha256:722695808f4b6457b320fdc131280796bdceb04ab50fe1795cd540799ebe1698
1113
packaging==26.2 \
1214
--hash=sha256:ff452ff5a3e828ce110190feff1178bb1f2ea2281fa2075aadb987c2fb221661
13-
pep517==0.13.1 \
14-
--hash=sha256:1b2fa2ffd3938bb4beffe5d6146cbcb2bda996a5a4da9f31abffd8b24e07b317
1515
pexpect==4.9.0 \
1616
--hash=sha256:ee7d41123f3c9911050ea2c2dac107568dc43b2d3b0c7557a33212c398ead30f
1717
pip==25.1.1 \
1818
--hash=sha256:3de45d411d308d5054c2168185d8da7f9a2cd753dbac8acbfa88a8909ecd9077
1919
ptyprocess==0.7.0 \
2020
--hash=sha256:5c5d0a3b48ceee0b48485e0c26037c0acd7d29765ca3fbb5cb3831d347423220
21+
pyproject-hooks==1.2.0 \
22+
--hash=sha256:1e859bd5c40fae9448642dd871adf459e5e2084186e8d2c2a79a824c970da1f8
2123
setuptools==80.9.0 \
2224
--hash=sha256:f36b47402ecde768dbfafc46e8e4207b4360c654f1f3bb84475f0a28628fb19c
2325
sh==2.2.2 \

contrib/requirements/requirements-build-android.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@ sh
99
cython<3.0
1010

1111
# needed by python-for-android:
12+
# ref https://github.com/spesmilo/python-for-android/blob/1098be6964cfc2156959e435e81c2c50f8398586/setup.py#L22
13+
# (meson and ninja we skip as not needed)
1214
appdirs
1315
# colorama upper bound to avoid needing hatchling
1416
colorama>=0.3.3,<0.4.6
1517
jinja2
16-
sh>=1.10
17-
pep517
18+
sh>=2,<3.0
1819
toml
20+
build
21+
packaging
1922

2023
# needed for the Qt/QML Android GUI:
2124
# TODO double-check this

0 commit comments

Comments
 (0)