Skip to content

Conversation

mhsmith
Copy link
Member

@mhsmith mhsmith commented Sep 11, 2025

#138649 and python/buildmaster-config#628 switched GitHub Actions and the buildbots over to using --fast-ci and --slow-ci on Android. However, this has introduced a warning, which has turned the buildbots orange:

Warning -- Failed to change Python options: FileNotFoundError(2, 'No such file or directory')
Warning -- Command: -u -W error -bb --dont-add-python-opts

Android runs the tests embedded in a larger app, so it's not possible to change the Python options by calling execv. Instead, this PR adds the ability to pass all Python command-line options to the Android testbed, so the options can be set to the expected values from the start.

This may also be useful in cibuildwheel, as it'll allow the testbed to accept a wider range of Python test commands (pypa/cibuildwheel#2590).

Copy link
Contributor

@freakboy3742 freakboy3742 left a comment

Choose a reason for hiding this comment

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

This mostly makes sense; a couple of minor clarification questions inline.


# Add warnings filter 'error'
if 'default' not in sys.warnoptions:
if 'error' not in sys.warnoptions:
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this intentional? It seems like a significant behavior change.

Copy link
Member Author

Choose a reason for hiding this comment

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

This fixes what I'm pretty sure was an oversight in #128973, which made warnings into errors in --fast-ci and --slow-ci.

But I don't think this change will make any difference to the other platforms, because sys.warnoptions represents the Python command line, not the actual warnings state. The other platforms aren't passing any warning options on the command line, so this if evaluates to true either way.


# Unbuffered stdout and stderr. This isn't helpful on Android, because
# it would cause lines to be split into multiple log messages.
if not sys.stdout.write_through and sys.platform != "android":
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't feel like the right place to check for this. If _add_ci_python_opts() does anything to modify the environment, then L716 below won't trigger, and an attempt will be made to run the test suite as a subprocess. It seems to me that we should be doing a higher-level check as to whether a subprocess test execution is possible at all, and avoiding the issue there.

In the #138176, when I added --fast/slow-ci support, I also used --dont-add-python-opts as a way to prevent environment modification (and thus the subprocess); that seems closer to the intent here.

Copy link
Member Author

Choose a reason for hiding this comment

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

A higher-level check to avoid the subprocess is a good idea, since it'll give a more understandable warning on Android, and avoid the instant crash when you try to start a subprocess on iOS.

However, I think --dont-add-python-opts is risky, because that'll lead to the mobile CI and buildbots using different options to the other platforms without warning. For example, when #128973 added -W error 6 months ago, it had no effect on the Android and iOS buildbots because they weren't using --slow-ci yet. When the Android buildbot started using --slow-ci, its status immediately turned orange because of the Python options mismatch. --dont-add-python-opts would have concealed that issue, possibly leading to bugs going unnoticed.

# Some platforms cannot change options after startup, so if these
# options are changed, also update the copies in:
# * cpython/Android/android.py
# * buildmaster-config/master/custom/factories.py
Copy link
Contributor

Choose a reason for hiding this comment

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

To confirm - is this an interim comment, or a long term plan? I thought the intention was to get all the options encoded into the android.py script so that "run CI checks" encoded all the defaults, rather than relying on multiple points of configuration.

Copy link
Member Author

@mhsmith mhsmith Sep 19, 2025

Choose a reason for hiding this comment

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

The idea is that _add_ci_python_opts checks the expected options, and then android.py and buildmaster-config actually specify those options. The duplication is unfortunate, but I can't see any way of avoiding it.

@bedevere-app
Copy link

bedevere-app bot commented Sep 18, 2025

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 phrase I 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants