You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 2943c69
Browse filesBrowse the repository at this point in the historyBrowse files
`gather --patch` and `--origin` replaced the placeholder prefix at build
time, standing in for what an installer would do, and rewrote binaries
to do it. Make the two steps explicit.
`gather` now leaves the placeholder in, so the tree isn't tied to a
location. `install.py` replaces it once the tree is where it will live:
in text files only, so binaries and their signatures stay as built. It
runs on any Python 3.12+ other than the one in the tree, lists the
binaries that still contain the placeholder, and fails on a tree
without it. It's a stopgap: each file it rewrites is something for
CPython to fix.
The build-time half of `--origin` is now `gather --relative-rpath`.
`test` gathers, moves the tree and runs `install.py` before checking it;
`--no-install` skips that step and `--relative-rpath` is passed on to
`gather`.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@@ -45,16 +45,21 @@ Some stdlib extension modules need third-party libraries that macOS doesn't prov
45
45
46
46
`deps` downloads each source archive from [cpython-source-deps](https://github.com/python/cpython-source-deps), checks it, and installs only static libraries into deps/install, so the extension modules don't link against anything outside the installation. OpenSSL still has compiled-in paths for its configuration and modules under deps/install. Use `--deps-dir DIR` to put them somewhere else.
47
47
48
-
The key thing to note is which patching approach to specify with `relocatable.py gather`. There are:
48
+
`configure` uses a placeholder `--prefix`. `gather` runs CPython's top-level `make install ENSUREPIP=no` into a staging `DESTDIR` and moves the installed prefix into place, so the gathered tree contains everything a normal install provides (such as `build-details.json` and the unversioned `python3` links). The tree still has the placeholder in it, so it isn't tied to a location and can be packed up as is.
49
49
50
-
-`--patch` which rewrites all found paths of the placeholder `--prefix` argument to the target install directory (which defaults to dist/); this is meant to follow the approach used by conda.
51
-
-`--origin` which uses `patchelf` to do a more targeted path rewrite upfront and then to patch any remaining paths; this is meant to follow the approach used by python-build-standalone.
50
+
Installing it is a separate step. Once the tree is where it will live, run `install.py` on it with any Python 3.12+ other than the one in the tree:
52
51
53
-
Either way, `gather` runs CPython's top-level `make install ENSUREPIP=no` into a staging `DESTDIR` and moves the installed prefix into place, so the gathered tree contains everything a normal install provides (such as `build-details.json` and the unversioned `python3` links). Only the placeholder prefix is rewritten, and patched Mach-O files are re-signed ad hoc, since macOS refuses to run binaries whose code signature no longer matches.
52
+
```shell
53
+
python3 ../prebuilt-cpython/install.py dist/
54
+
```
55
+
56
+
`install.py` replaces the placeholder with the tree's location in text files only and lists the binary files that still contain it. It never modifies a binary, so signatures stay valid. It fails if no text file in the tree has the placeholder, which is the case for a tree it has already been run on.
57
+
58
+
`gather --relative-rpath` also uses `patchelf` to give the installed ELF files an `$ORIGIN`-relative RPATH, so they load libraries from inside the tree wherever it ends up; this follows what python-build-standalone does at build time. It's Linux only.
54
59
55
60
### Testing a relocated build
56
61
57
-
`relocatable.py test` checks whether a build still works after it has been moved. It gathers the build into a temporary directory (dist/ is left alone), renames that directory to a path of a different length with spaces in it, and runs these checks without patching anything again:
62
+
`relocatable.py test` checks whether a build still works after it has been moved. It gathers the build into a temporary directory (dist/ is left alone), renames that directory to a path of a different length with spaces in it, runs `install.py` on it, and runs these checks:
58
63
59
64
- The interpreter starts
60
65
-`sys` and `sysconfig` paths point inside the moved tree
@@ -74,11 +79,11 @@ Each check prints `PASS`, `FAIL`, or `SKIP` (in color on a terminal, unless `NO_
74
79
../prebuilt-cpython/relocatable.py test
75
80
```
76
81
77
-
Use `--strategy origin` to gather with `--origin` (the default is `--patch`), `--full` to also run `python -m test --fast-ci`, `--work-dir DIR` to keep the temporary files (including `gather.log`, the `make install` output), and `--format json` for JSON output.
82
+
Use `--relative-rpath` to gather with `--relative-rpath`, `--no-install` to check the moved tree without running `install.py` (what a build that needs no install step would have to pass), `--full` to also run `python -m test --fast-ci`, `--work-dir DIR` to keep the temporary files (including `gather.log`, the `make install` output), and `--format json` for JSON output.
78
83
79
-
The Relocatability GitHub Actions workflow runs `test`with both strategies against CPython `main` on Linux and macOS, daily and for each pull request. Each run's summary lists the results, and the JSON is attached to the run.
84
+
The Relocatability GitHub Actions workflow runs `test`in each of those modes against CPython `main` on Linux and macOS, daily and for each pull request. Each run's summary lists the results, and the JSON is attached to the run.
80
85
81
-
If the build wasn't configured by `relocatable.py configure`, its `--prefix` is left alone and treated as the old location. If that directory still exists, the `distribution.isolation` check fails, because the moved build might be using files from it without anyone noticing.
86
+
If the build wasn't configured by `relocatable.py configure`, `install.py` isn't run, and its `--prefix` is treated as the old location. If that directory still exists, the `distribution.isolation` check fails, because the moved build might be using files from it without anyone noticing.
82
87
83
88
## Project Representatives
84
89
These are people representing projects that have experience with prebuilt binaries for CPython.
0 commit comments