1{
2 lib,
3 buildPythonPackage,
4 fetchPypi,
5 fetchurl,
6 setuptools,
7}:
8let
9 # 4 binaries which require vendoring, as otherwise
10 # the build system behind pex will attempt to fetch
11 # them during at build time
12 uv-trampoline = {
13 # Taken from https://github.com/pex-tool/pex/blob/2c66932d6645e8e542e5386eae08b9cc2dbb2a21/pex/windows/__init__.py#L45
14 version = "0.5.29";
15
16 aarch64-gui = fetchurl {
17 url = "https://raw.githubusercontent.com/astral-sh/uv/refs/tags/${uv-trampoline.version}/crates/uv-trampoline/trampolines/uv-trampoline-aarch64-gui.exe";
18 hash = "sha256-mb8x1FpyH+wy11X5YgWfqh/VUwBb62M4Zf9aFr5V4EE=";
19 };
20
21 aarch64-console = fetchurl {
22 url = "https://raw.githubusercontent.com/astral-sh/uv/refs/tags/${uv-trampoline.version}/crates/uv-trampoline/trampolines/uv-trampoline-aarch64-console.exe";
23 hash = "sha256-1S2aM+6CV7rKz+3ncM5X7kk7uDQeuha1+8lUEMYC75k=";
24 };
25
26 x86_64-gui = fetchurl {
27 url = "https://raw.githubusercontent.com/astral-sh/uv/refs/tags/${uv-trampoline.version}/crates/uv-trampoline/trampolines/uv-trampoline-x86_64-gui.exe";
28 hash = "sha256-icnp1oXrOZpc+dHTGvDbTHjr+D8M0eamvRrC9bPI/KI=";
29 };
30
31 x86_64-console = fetchurl {
32 url = "https://raw.githubusercontent.com/astral-sh/uv/refs/tags/${uv-trampoline.version}/crates/uv-trampoline/trampolines/uv-trampoline-x86_64-console.exe";
33 hash = "sha256-nLopBrlCMMFjkKVRlY7Ke2zFGpQOyF5mSlLs0d7+HRQ=";
34 };
35 };
36in
37buildPythonPackage rec {
38 pname = "pex";
39 version = "2.38.1";
40 pyproject = true;
41
42 src = fetchPypi {
43 inherit pname version;
44 hash = "sha256-ejd9JWmDutYpwR+KPiS90Y3XKyyOwRAMpCEN013VMdI=";
45 };
46
47 preBuild = ''
48 mkdir -p pex/windows/stubs
49 cp ${uv-trampoline.aarch64-gui} pex/windows/stubs/uv-trampoline-aarch64-gui.exe
50 cp ${uv-trampoline.aarch64-console} pex/windows/stubs/uv-trampoline-aarch64-console.exe
51 cp ${uv-trampoline.x86_64-gui} pex/windows/stubs/uv-trampoline-x86_64-gui.exe
52 cp ${uv-trampoline.x86_64-console} pex/windows/stubs/uv-trampoline-x86_64-console.exe
53 '';
54
55 build-system = [ setuptools ];
56
57 # A few more dependencies I don't want to handle right now...
58 doCheck = false;
59
60 pythonImportsCheck = [ "pex" ];
61
62 meta = with lib; {
63 description = "Python library and tool for generating .pex (Python EXecutable) files";
64 homepage = "https://github.com/pantsbuild/pex";
65 changelog = "https://github.com/pantsbuild/pex/releases/tag/v${version}";
66 license = licenses.asl20;
67 maintainers = [ ];
68 };
69}