Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-131531: android.py enhancements to support cibuildwheel#132870

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
freakboy3742 merged 18 commits intopython:mainfrommhsmith:cibuildwheel
Jun 5, 2025

Conversation

mhsmith
Copy link
Member

@mhsmithmhsmith commentedApr 24, 2025
edited
Loading

#131532 added an Android release package format for the use of external tools such as cibuildwheel. This PR adds a number of features to that package to allow third-party wheels to be built and tested against it:

  • Add anandroid.py env command which prints necessary environment variables (CC, CFLAGS, etc.).
  • Generalize theandroid.py test command so it can be used to run any test suite, not only Python's own tests. This involves adding the following options:
    • --site-packages to copy code into the app
    • --cwd to copy files into the app's working directory
    • -c to run a Python statement
    • -m to run a Python module

The corresponding cibuildwheel PR ispypa/cibuildwheel#2349.

mhsmithand others added3 commitsApril 24, 2025 17:14
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
@mhsmith
Copy link
MemberAuthor

@freakboy3742: Please review this PR, but don't actually merge it yet, as there may be some further updates depending on what happens on the cibuildwheel PR.

@mhsmith
Copy link
MemberAuthor

!buildbot android

@bedevere-bot

This comment was marked as outdated.

Copy link
Contributor

@freakboy3742freakboy3742 left a comment

Choose a reason for hiding this comment

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

The broad strokes of this (especially the modifications to kick off an external test suite) make sense; a couple of questions inline about specific decisions/changes.

There's also the issue with the CI failures; not sure how many of those are transient issues caused by the state of main, and how many are caused by changes in this PR - at least one of the errors seems to be related to ctypes availability.

env_script = ANDROID_DIR / "android-env.sh"
env_output = subprocess.run(
f"set -eu; "
f"export HOST={host}; "
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason this has become a full export?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

HOST is a somewhat standardized way of indicating cross-compilation, e.g. it's used by conda-build. So it makes sense to expose it to the build system.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I'm also using it in the cibuildwheel PR to setsys.implementation._multiarch in the cross-compilation environment.

freakboy3742 reacted with thumbs up emoji
@bedevere-app
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phraseI have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@serhiy-storchakaserhiy-storchaka added the needs backport to 3.14bugs and security fixes labelMay 8, 2025
@mhsmith
Copy link
MemberAuthor

!buildbot android

@bedevere-bot

This comment was marked as outdated.

@freakboy3742
Copy link
Contributor

!buildbot android

@bedevere-bot

This comment was marked as outdated.

Copy link
Contributor

@freakboy3742freakboy3742 left a comment

Choose a reason for hiding this comment

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

The set of changes here all make sense, and it's passing CI; but in my local testing, I'm hitting a problem.

The problem appears to be caused by the intersection of a packaging issue with the binary dependencies, and a change in behavior inshutil.unpack_archive.

The bzip2 download (possibly others, but the bzip2 build is where it fails) contains symlinks to absolute paths.android.py usesshutil.unpack_archive() to unpack the download; but if you use Python 3.14.0b1, this raises:

rkm@eunectes cpython % python3.14 Android/android.py configure-host aarch64-linux-android> curl -Lf --retry 5 --retry-all-errors -o ./bzip2-1.0.8-2-aarch64-linux-android.tar.gz https://github.com/beeware/cpython-android-source-deps/releases/download/bzip2-1.0.8-2/bzip2-1.0.8-2-aarch64-linux-android.tar.gz  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current                                 Dload  Upload   Total   Spent    Left  Speed  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0100  192k  100  192k    0     0   146k      0  0:00:01  0:00:01 --:--:-- 2381kTraceback (most recent call last):  File "/Users/rkm/projects/python/cpython/Android/android.py", line 811, in <module>    main()    ~~~~^^  File "/Users/rkm/projects/python/cpython/Android/android.py", line 787, in main    result = dispatch[context.subcommand](context)  File "/Users/rkm/projects/python/cpython/Android/android.py", line 198, in configure_host_python    unpack_deps(context.host, prefix_dir)    ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/Users/rkm/projects/python/cpython/Android/android.py", line 180, in unpack_deps    shutil.unpack_archive(filename, prefix_dir)    ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^  File "/Library/Frameworks/Python.framework/Versions/3.14/lib/python3.14/shutil.py", line 1432, in unpack_archive    func(filename, extract_dir, **kwargs)    ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/Library/Frameworks/Python.framework/Versions/3.14/lib/python3.14/shutil.py", line 1349, in _unpack_tarfile    tarobj.extractall(extract_dir, filter=filter)    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/Library/Frameworks/Python.framework/Versions/3.14/lib/python3.14/tarfile.py", line 2389, in extractall    tarinfo = self._get_extract_tarinfo(member, filter_function, path)  File "/Library/Frameworks/Python.framework/Versions/3.14/lib/python3.14/tarfile.py", line 2443, in _get_extract_tarinfo    self._handle_fatal_error(e)    ~~~~~~~~~~~~~~~~~~~~~~~~^^^  File "/Library/Frameworks/Python.framework/Versions/3.14/lib/python3.14/tarfile.py", line 2441, in _get_extract_tarinfo    tarinfo = filter_function(tarinfo, path)  File "/Library/Frameworks/Python.framework/Versions/3.14/lib/python3.14/tarfile.py", line 842, in data_filter    new_attrs = _get_filtered_attrs(member, dest_path, True)  File "/Library/Frameworks/Python.framework/Versions/3.14/lib/python3.14/tarfile.py", line 819, in _get_filtered_attrs    raise AbsoluteLinkError(member)tarfile.AbsoluteLinkError: 'bin/bzless' is a link to an absolute path

This doesn't happen if you use Python 3.13 to runandroid.py. This appears to be a side effect of the change in 3.14 to default tofilter="data"

AFAICT, this isn't a problem in CI because it isn't using the build version of python to runandroid.py - it's using whatever version is in the environment to run the buildbot server (I want to say 3.9...?)

It's also not animmediate problem, but it's safe to assume it will be as soon as 3.14 is final. I'm not sure if the fix is in this repo, fixing the filter argument; or to the binary package to fix the creation of symlinks. I suspect it's probably the latter, but I might be missing an obvious fix that can be applied to this repo.

Other than that, I think this is good to land and back port.

@@ -3,7 +3,7 @@
: "${HOST:?}" # GNU target triplet

# You may also override the following:
: "${api_level:=24}" # Minimum Android API level the build will run on
: "${ANDROID_API_LEVEL:=24}" # Minimum Android API level the build will run on
Copy link
MemberAuthor

@mhsmithmhsmithJun 4, 2025
edited
Loading

Choose a reason for hiding this comment

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

I'm not sure whether there will be a merge conflict on this line when backporting to 3.13, but either way, the API level on that branch should remain at 21. Apart from that, this file should be identical on all branches.

@mhsmith
Copy link
MemberAuthor

mhsmith commentedJun 4, 2025
edited
Loading

I'm not sure if the fix is in this repo, fixing the filter argument; or to the binary package to fix the creation of symlinks. I suspect it's probably the latter

Yes, this was a bug in the bzip2 Makefile, so I've added a patch and a new release incpython-android-source-deps, and updated this PR to use it. It doesn't look like any of the other tarballs had the same problem.

AFAICT, this isn't a problem in CI because it isn't using the build version of python to runandroid.py - it's using whatever version is in the environment to run the buildbot server (I want to say 3.9...?)

3.12 actually, which was the current stable version when I set up the buildbot. It probably wouldn't work as far back as 3.9 because it uses some fairly new asyncio APIs.

@freakboy3742
Copy link
Contributor

!buildbot android

@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by@freakboy3742 for commit6f18528 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F132870%2Fmerge

The command will test the builders whose names match following regular expression:android

The builders matched are:

  • AMD64 Android PR
  • aarch64 Android PR

Copy link
Contributor

@freakboy3742freakboy3742 left a comment

Choose a reason for hiding this comment

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

That updated bzip2 archive looks like it has done the trick, so this is good to go!

@freakboy3742freakboy3742 merged commit2e1544f intopython:mainJun 5, 2025
44 of 45 checks passed
@miss-islington-app
Copy link

Thanks@mhsmith for the PR, and@freakboy3742 for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestJun 5, 2025
…honGH-132870)Modifies the environment handling and execution arguments of the Android managementscript to support the compilation of third-party binaries, and the use of the testbed toinvoke third-party test code.(cherry picked from commit2e1544f)Co-authored-by: Malcolm Smith <smith@chaquo.com>Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
@miss-islington-app
Copy link

Sorry,@mhsmith and@freakboy3742, I could not cleanly backport this to3.13 due to a conflict.
Please backport usingcherry_picker on command line.

cherry_picker 2e1544fd2b0cd46ba93fc51e3cdd47f4781d7499 3.13

@bedevere-app
Copy link

GH-135158 is a backport of this pull request to the3.14 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.14bugs and security fixes labelJun 5, 2025
freakboy3742 added a commit that referenced this pull requestJun 5, 2025
…-132870) (#135158)Modifies the environment handling and execution arguments of the Android managementscript to support the compilation of third-party binaries, and the use of the testbed toinvoke third-party test code.(cherry picked from commit2e1544f)Co-authored-by: Malcolm Smith <smith@chaquo.com>Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
mhsmith added a commit to mhsmith/cpython that referenced this pull requestJun 5, 2025
…el (pythonGH-132870)Modifies the environment handling and execution arguments of the Android managementscript to support the compilation of third-party binaries, and the use of the testbed toinvoke third-party test code.(cherry picked from commit2e1544f)Co-authored-by: Malcolm Smith <smith@chaquo.com>Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
@bedevere-app
Copy link

GH-135164 is a backport of this pull request to the3.13 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.13bugs and security fixes labelJun 5, 2025
freakboy3742 added a commit that referenced this pull requestJun 5, 2025
…-132870) (#135164)Modifies the environment handling and execution arguments of the Android managementscript to support the compilation of third-party binaries, and the use of the testbed toinvoke third-party test code.(cherry picked from commit2e1544f)Co-authored-by: Malcolm Smith <smith@chaquo.com>Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@AA-TurnerAA-TurnerAA-Turner left review comments

@freakboy3742freakboy3742freakboy3742 approved these changes

Assignees

@freakboy3742freakboy3742

Labels
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

5 participants
@mhsmith@bedevere-bot@freakboy3742@AA-Turner@serhiy-storchaka

[8]ページ先頭

©2009-2025 Movatter.jp