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
Copy file name to clipboardExpand all lines: crates/uv-trampoline/README.md
+12-15Lines changed: 12 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,7 @@
1
1
# Windows trampolines
2
2
3
-
This is a fork of [posy trampolines](https://github.com/njsmith/posy/tree/dda22e6f90f5fefa339b869dd2bbe107f5b48448/src/trampolines/windows-trampolines/posy-trampoline).
3
+
This is a fork
4
+
of [posy trampolines](https://github.com/njsmith/posy/tree/dda22e6f90f5fefa339b869dd2bbe107f5b48448/src/trampolines/windows-trampolines/posy-trampoline).
4
5
5
6
# What is this?
6
7
@@ -13,27 +14,26 @@ That's what this does: it's a generic "trampoline" that lets us generate custom
13
14
`.exe`s for arbitrary Python scripts, and when invoked it bounces to invoking
14
15
`python <the script>` instead.
15
16
16
-
17
17
# How do you use it?
18
18
19
19
Basically, this looks up `python.exe` (for console programs) or
20
20
`pythonw.exe` (for GUI programs) in the adjacent directory, and invokes
21
21
`python[w].exe path\to\the\<the .exe>`.
22
22
23
-
The intended use is: take your Python script, name it `__main__.py`, and pack it
24
-
into a `.zip` file. Then concatenate that `.zip` file onto the end of one of our
25
-
prebuilt `.exe`s.
23
+
The intended use is:
24
+
25
+
* take your Python script, name it `__main__.py`, and pack it
26
+
into a `.zip` file. Then concatenate that `.zip` file onto the end of one of our
27
+
prebuilt `.exe`s.
28
+
* After the zip file content, write the path to the Python executable that the script uses to run
29
+
the Python script as UTF-8 encoded string, followed by the path's length as a 32-bit little-endian
30
+
integer.
31
+
* At the very end, write the magic number `UVUV` in bytes.
26
32
27
33
Then when you run `python` on the `.exe`, it will see the `.zip` trailer at the
28
34
end of the `.exe`, and automagically look inside to find and execute
29
35
`__main__.py`. Easy-peasy.
30
36
31
-
(TODO: we should probably make the Python-finding logic slightly more flexible
32
-
at some point -- in particular to support more conventional venv-style
33
-
installation where you find `python` by looking in the directory next to the
34
-
trampoline `.exe` -- but this is good enough to get started.)
35
-
36
-
37
37
# Why does this exist?
38
38
39
39
I probably could have used Vinay's C++ implementation from `distlib`, but what's
@@ -47,7 +47,6 @@ Python-finding logic we want. But mostly it was just an interesting challenge.
47
47
This does owe a *lot* to the `distlib` implementation though. The overall logic
48
48
is copied more-or-less directly.
49
49
50
-
51
50
# Anything I should know for hacking on this?
52
51
53
52
In order to minimize binary size, this uses `#![no_std]`, `panic="abort"`, and
@@ -64,7 +63,7 @@ this:
64
63
Though uh, this does mean that literally all of our code is `unsafe`. Sorry!
65
64
66
65
-`runtime.rs` has the core glue to get panicking, heap allocation, and linking
67
-
working.
66
+
working.
68
67
69
68
-`diagnostics.rs` uses `ufmt` and some cute Windows tricks to get a convenient
70
69
version of `eprintln!` that works without `std`, and automatically prints to
@@ -85,7 +84,6 @@ Miscellaneous tips:
85
84
`.unwrap_unchecked()` avoids this. Similar for `slice[idx]` vs
86
85
`slice.get_unchecked(idx)`.
87
86
88
-
89
87
# How do you build this stupid thing?
90
88
91
89
Building this can be frustrating, because the low-level compiler/runtime
@@ -107,7 +105,6 @@ Two approaches that are reasonably likely to work:
107
105
- Leave `compiler-builtins` commented-out, and build like: `cargo build
0 commit comments