Add xpython command - #90
Merged
Merged
Conversation
Two bugs surfaced by live end-to-end testing against a real network and
downloaded Python builds (mocked unit tests couldn't catch either since
they mock subprocess.run entirely):
1. xpython/platforms/ios.py hardcoded the literal string "python" when
invoking the testbed clone/run driver scripts. This fails on any host
(like this one) where only python3 is on PATH. Use sys.executable
instead, since xpython already requires running under the same
major.minor interpreter as the target build.
2. xpython/deps.py's install_requirements() ran pip inside a cross-platform
venv without disabling the venv's sys.platform-patching shim first.
With the shim active, CPython's ctypes special-cases
sys.platform in ("android", "cygwin") to load pythonapi via dlopen(),
which pip's vendored rich library triggers during import, crashing pip
on a host that isn't actually running on-device Android. Mirror the
existing XBUILD_ENV=off pattern already used by xbuild/env.py's
install_environment() and tests/live/test_xvenv.py to disable the shim
while pip itself runs.
Verified live:
- iOS: xpython now gets past the testbed clone step and reaches
xcodebuild build-for-testing (which then fails for an unrelated
deployment-target/Xcode-version mismatch in this environment).
- Android: pip install now succeeds inside the cross-venv; failure moves
to android.py's own SyntaxError (caused by /usr/bin/python3 3.9.6 being
first on PATH, unrelated to this fix) -- well past the previous
ctypes/dlopen crash during pip install.
…etup in main() install_requirements() and ios.stage_and_run()'s testbed clone step can raise subprocess.CalledProcessError. Previously this propagated out of main() as an unhandled traceback instead of a clean _error() + exit(1), inconsistent with how xvenv/xbuild handle expected failures and with the design spec's error-handling section. Also fix stale 'both commands' wording in the common-options doc now that xpython makes three commands, not two.
…ndroid.stage_and_run()
…ate live test and docs
Item 4 of the numbered behavior list claimed xpython always runs '-m <module> <args...>' inside the testbed, which was only true for the old iOS-only invocation shape. This contradicts the dedicated '-- [args ...]' section below, which correctly documents that Android also accepts -c <code> or no args (defaulting to -m test). Point to that section instead of overclaiming.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds an
xpythonentry point.Simplest usage is
xpython --platform ios --src tests -d otherpkg --group dev -- -m pytest testsThis will:
testsfolder into the testbed projectotherpkgas a dependencydevdependency grouppython -m pytest tests, but in the emulator environment.PR Checklist:
Assisted-by: Claude Sonnet 5