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

Open
mhsmith wants to merge10 commits intopython:main
base:main
Choose a base branch
Loading
frommhsmith:cibuildwheel

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.

f"PREFIX={prefix}; "
f". {env_script}; "
f"export",
check=True, shell=True, capture_output=True, text=True,
Copy link
Member

Choose a reason for hiding this comment

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

Is there a way to avoidshell=True? We should try to avoid it, especially as code inpython/cpython is prominent. Also, prefer 'encoding' to 'text':

Suggested change
check=True,shell=True,capture_output=True,text=True,
check=True,shell=True,capture_output=True,encoding='utf-8',

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

In this case the whole point of the code is to run a shell script and determine which environment variables it sets, soshell=True is unavoidable. However, the script is entirely under our control – it's in the repository right next to this file.

Also, prefer 'encoding' to 'text'

Thanks, fixed.

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
Copy link

🤖 New build scheduled with the buildbot fleet by@mhsmith for commit9c46ab0 🤖

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.

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.

# when building third-party extension modules, so pass them via the
# NODIST environment variables.
host_env = android_env(host)
for name in ["CFLAGS", "CXXFLAGS", "LDFLAGS"]:
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are these needed for the testbed environment? Is this script being used to drive cibuildwheel?

Or - I guess - why are they needed now to support compilation when they weren't required previously?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

This section of the script is only directly used when building Python itself. This PR doesn't change the flags, it only moves the flags which contain build-time paths from the...FLAGS variables (which are exposed by sysconfig for the purpose of building packages) to the...FLAGS_NODIST variables (which are only used when building Python). This approach is recommended inPython's build documentation.

This may be unnecessary for cibuildwheel, because it contains code to rewrite any paths in the sysconfigdata. But cibuildwheel isn't the only context in which packages could be built – e.g. we may also see "native" (non-cross) compilation on Termux.

@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

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

I think it's caused by this PR – I'll look into it.

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 requested changes

Assignees
No one assigned
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