Repository navigation
Contributors: test a Python-only change over a borrowed wheel (scripts/dev_overlay.py) - #438
Merged
Merged
Conversation
…ipts/dev_overlay.py (refs #437) A contributor who changes only Python had to build a wheel before one test could run, and the native image takes 5 to 30 minutes. scripts/dev_overlay.py puts the .py files of the checkout over an installed wheel (a wheel CI built from main, or a release), links what only the wheel has (jars, JRE, libraries, generated files), and runs the given command with the overlay first on PYTHONPATH. It lists the files on the binary side that changed since the wheel was built, from SOURCE_COMMIT of a native wheel or the tag of a release. The native wheel holds rewritten sources (the jpype stub, the default backend, the _build_info imports). That rewrite moves out of main() of native/wheel/build_wheel.py into nativize_sources(), text unchanged, so the overlay and the wheel build share one function. Checked on the wheels CI built from 5592084: all 38 .py files of the native overlay are byte-identical to the wheel's, and all 37 of the JVM overlay. tests/test_dev_overlay.py runs the script against the wheel under test, so every CI leg shows the overlay imports on its platform. CONTRIBUTING.md says where to get a wheel and when the shortcut is valid. CI itself is unchanged and still tests the built wheels.
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.
Closes #437
What does this PR do?
It lets a contributor test a Python-only change without building a wheel. The research and the trial results are in #437.
scripts/dev_overlay.py(standard library only). Run insideuv run --no-project --with <wheel>, it puts the.pyfiles of the checkout over the installed wheel, links what only the wheel has (jars, JRE, native libraries, the generated_version.pyor_build_info.py), and runs the arguments it is given aspython <arguments>with the overlay first onPYTHONPATH. The overlay is made again on every run. It also lists the files on the binary side that changed since the wheel was built (SOURCE_COMMITof a native wheel, the tag of a release), so a stale wheel is named before a test fails for a reason that is not in the change.native/wheel/build_wheel.py: the source rewrite of the native wheel (jpype stub, default backend,_build_infoimports) moves out ofmain()intonativize_sources(), text unchanged, so the overlay and the wheel build share one function.CONTRIBUTING.md: a section "Change Python code without building a wheel" that says where to get a wheel (the artifacts ofmain, or a release), when the shortcut is valid (Python files only; notsrc/java, notnative/, not a change that needs a newer engine), and that CI still builds and tests the real wheels.tests/test_dev_overlay.pyruns the script against the wheel under test, so each CI leg shows that the overlay imports on its platform..gitignoregets.dev-overlay/.CI is unchanged.
How I checked it
On Linux x86-64 with Python 3.12, with the Python sources of
main(5592084) plus this branch over each wheel: importarcadedb, create a database, insert five rows, query them.wheel-linux-amd64of run44978877325(main)arcadedb-jvm.pyfiles of the overlay are identical to the wheel's.native-wheel-linux-x86_64of run44981746741(main)arcadedb.pyfiles of the overlay are identical to the wheel's, which shows thatnativize_sources()writes what the inline code wrote.26.11.1.post4from PyPIarcadedb-jvmsrc/javadid not change since the release.26.11.1.post4from PyPIarcadedbnative/changed, and the import then fails on the generated_build_info.pyof that wheel (details in #437). This is the case the warning is for.Pre-commit,
compile(), pyflakes and the Bandit command of CI pass on the changed files.One thing I could not do: run the test suite on my machine. The new test has not run anywhere yet, so the checks of this PR are its first run. I checked by hand that the script prints what the test asserts (the imported file is in the overlay, the backend, the version, sources as real files). Please look at the Windows legs in particular: the script links files and falls back to copies when links are not allowed, and I could only try Linux. The native Windows, macOS and aarch64 legs do not run on a pull request, so they first run on
main.Docs
CONTRIBUTING.mdhas the new section. No page underdocs/describes the contributor setup, andREADME.mddoes not either, so neither changes.Checklist
uvx pre-commit run --files <changed files>passes