esbuild-bin 0.28.2__py3-none-win32.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,10 @@
1
+ """The official esbuild binary, packaged for Python.
2
+
3
+ The public API is ``find_esbuild_bin()``, ``__version__`` (the esbuild version
4
+ this wheel carries) and ``python -m esbuild_bin <args>``.
5
+ """
6
+
7
+ from esbuild_bin._find import find_esbuild_bin
8
+ from esbuild_bin._version import __version__
9
+
10
+ __all__ = ["__version__", "find_esbuild_bin"]
@@ -0,0 +1,26 @@
1
+ """``python -m esbuild_bin <args>``: run the bundled esbuild binary with ``args``."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+ import subprocess
7
+ import sys
8
+
9
+ from esbuild_bin._find import find_esbuild_bin
10
+
11
+
12
+ def main() -> int:
13
+ exe = find_esbuild_bin()
14
+ argv = [exe, *sys.argv[1:]]
15
+ if sys.platform == "win32":
16
+ # No exec on Windows; forward the child's exit code instead.
17
+ try:
18
+ return subprocess.run(argv, check=False).returncode
19
+ except KeyboardInterrupt:
20
+ return 130
21
+ os.execv(exe, argv) # noqa: S606 (argument list, no shell)
22
+ return 1 # unreachable
23
+
24
+
25
+ if __name__ == "__main__":
26
+ sys.exit(main())
esbuild_bin/_find.py ADDED
@@ -0,0 +1,100 @@
1
+ """Locate the esbuild executable installed alongside this package.
2
+
3
+ Modelled on ruff's ``find_ruff_bin``: the binary is installed as a wheel
4
+ "script", so it lands wherever the installer put scripts for this scheme.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ import os
10
+ import sys
11
+ import sysconfig
12
+ from fnmatch import fnmatch
13
+
14
+ ENV_VAR = "ESBUILD_BINARY_PATH"
15
+ EXE_NAME = "esbuild" + (sysconfig.get_config_var("EXE") or "")
16
+
17
+
18
+ def find_esbuild_bin() -> str:
19
+ """Return the path of the esbuild executable.
20
+
21
+ Checks, in order: ``$ESBUILD_BINARY_PATH``; the scripts directory of the
22
+ running interpreter; the user scheme's scripts directory (``pip install
23
+ --user``); the scripts directory next to the package (``--prefix`` and
24
+ ``--target`` installs). Raises ``FileNotFoundError`` listing every path tried.
25
+ """
26
+ override = os.environ.get(ENV_VAR)
27
+ if override:
28
+ if not _is_executable(override):
29
+ raise FileNotFoundError(
30
+ f"{ENV_VAR} is set to {override!r}, which is not an executable file"
31
+ )
32
+ return override
33
+
34
+ tried: list[str] = []
35
+ for directory in _candidate_dirs():
36
+ if not directory:
37
+ continue
38
+ path = os.path.join(directory, EXE_NAME)
39
+ if path in tried:
40
+ continue
41
+ tried.append(path)
42
+ if _is_executable(path):
43
+ return path
44
+
45
+ locations = "\n".join(f" - {p}" for p in tried)
46
+ raise FileNotFoundError(
47
+ f"Could not find the esbuild binary. Tried:\n{locations}\n"
48
+ f"Set {ENV_VAR} to the path of an esbuild executable to override."
49
+ )
50
+
51
+
52
+ def _is_executable(path: str) -> bool:
53
+ return os.path.isfile(path) and os.access(path, os.X_OK)
54
+
55
+
56
+ def _candidate_dirs() -> list[str | None]:
57
+ module_dir = _module_dir()
58
+ if sys.platform == "win32":
59
+ # --prefix: <prefix>/Lib/site-packages/esbuild_bin -> <prefix>/Scripts
60
+ prefix_dir = _join(_strip_suffix(module_dir, "Lib/site-packages/esbuild_bin"), "Scripts")
61
+ else:
62
+ # --prefix: <prefix>/lib/python3.X/site-packages/esbuild_bin -> <prefix>/bin
63
+ prefix_dir = _join(
64
+ _strip_suffix(module_dir, "lib/python*/site-packages/esbuild_bin"), "bin"
65
+ )
66
+ return [
67
+ sysconfig.get_path("scripts"),
68
+ _user_scripts_dir(),
69
+ prefix_dir,
70
+ # --target: <target>/esbuild_bin -> <target>/bin
71
+ _join(_strip_suffix(module_dir, "esbuild_bin"), "bin"),
72
+ ]
73
+
74
+
75
+ def _module_dir() -> str:
76
+ return os.path.dirname(os.path.abspath(__file__))
77
+
78
+
79
+ def _user_scripts_dir() -> str | None:
80
+ scheme = sysconfig.get_preferred_scheme("user")
81
+ try:
82
+ return sysconfig.get_path("scripts", scheme=scheme)
83
+ except KeyError:
84
+ return None
85
+
86
+
87
+ def _strip_suffix(path: str, pattern: str) -> str | None:
88
+ """Drop trailing components of ``path`` that match ``pattern`` (``/``-separated, globs)."""
89
+ parts = path.split(os.sep)
90
+ pattern_parts = pattern.split("/")
91
+ if len(parts) <= len(pattern_parts):
92
+ return None
93
+ tail = parts[-len(pattern_parts) :]
94
+ if not all(fnmatch(part, want) for part, want in zip(tail, pattern_parts, strict=True)):
95
+ return None
96
+ return os.sep.join(parts[: -len(pattern_parts)])
97
+
98
+
99
+ def _join(path: str | None, child: str) -> str | None:
100
+ return None if path is None else os.path.join(path, child)
@@ -0,0 +1,3 @@
1
+ # The esbuild version this package carries. Must equal ESBUILD_VERSION
2
+ # (checked by the build and the tests); scripts/check_upstream.py updates it.
3
+ __version__ = "0.28.2"
esbuild_bin/py.typed ADDED
File without changes
@@ -0,0 +1,105 @@
1
+ Metadata-Version: 2.4
2
+ Name: esbuild-bin
3
+ Version: 0.28.2
4
+ Summary: The official esbuild binary, repackaged as Python wheels. Unofficial; not affiliated with the esbuild project.
5
+ Project-URL: Homepage, https://github.com/RemiDesgrange/python-esbuild
6
+ Project-URL: Upstream, https://github.com/evanw/esbuild
7
+ Project-URL: Changelog, https://github.com/evanw/esbuild/blob/main/CHANGELOG.md
8
+ License-Expression: MIT
9
+ License-File: LICENSE.md
10
+ Requires-Python: >=3.11
11
+ Description-Content-Type: text/markdown
12
+
13
+ # esbuild-bin
14
+
15
+ The official [esbuild](https://esbuild.github.io/) executable, repackaged as Python wheels.
16
+
17
+ ```sh
18
+ pip install "esbuild-bin>=0.28,<0.29"
19
+ esbuild --version
20
+ ```
21
+
22
+ Requires Python 3.11 or newer. After installing, any Python project has a working `esbuild`: no Node.js, no npm, no compiler, and no downloads at install or run time. It works with Django, Flask, FastAPI, MkDocs, Sphinx or a plain CI script.
23
+
24
+ > **Unofficial.** This is an independent repackaging. It is not affiliated with or endorsed by the esbuild project. The binary inside each wheel is byte-for-byte the one esbuild publishes to npm. Report esbuild bugs [upstream](https://github.com/evanw/esbuild/issues), and packaging bugs [here](https://github.com/RemiDesgrange/python-esbuild/issues).
25
+
26
+ ## Versioning: pin a minor range
27
+
28
+ The wheel version is the esbuild version: `esbuild-bin==0.28.2` contains esbuild 0.28.2. esbuild is still 0.x, and **minor releases can change behaviour**, so pin a minor range:
29
+
30
+ ```toml
31
+ dependencies = ["esbuild-bin>=0.28,<0.29"]
32
+ ```
33
+
34
+ Every upstream release gets its own release here; none are skipped. There are no `.postN` releases: if a release has a packaging problem, it is yanked on PyPI and the fix ships with the next esbuild release. Read the [esbuild changelog](https://github.com/evanw/esbuild/blob/main/CHANGELOG.md) before moving to a new minor.
35
+
36
+ ## Three ways to call it
37
+
38
+ **1. On `PATH`.** The binary is installed as a script, so inside the environment it is just `esbuild`:
39
+
40
+ ```sh
41
+ esbuild app.js --bundle --minify --outfile=out.js
42
+ ```
43
+
44
+ **2. As a module.** Arguments are passed through unchanged, and so is the exit code:
45
+
46
+ ```sh
47
+ python -m esbuild_bin app.js --bundle --minify --outfile=out.js
48
+ ```
49
+
50
+ **3. From Python (recommended for libraries).** `find_esbuild_bin()` returns the binary's path. Build the argument list yourself, following `esbuild --help`:
51
+
52
+ ```python
53
+ import subprocess
54
+ from esbuild_bin import find_esbuild_bin
55
+
56
+ subprocess.run(
57
+ [find_esbuild_bin(), "app.js", "--bundle", "--minify", "--outfile=out.js"],
58
+ check=True,
59
+ )
60
+ ```
61
+
62
+ There is deliberately no Python wrapper around esbuild's options. `esbuild_bin.__version__` is the esbuild version the wheel carries.
63
+
64
+ `find_esbuild_bin()` looks, in order, at `$ESBUILD_BINARY_PATH`; the current environment's scripts directory; the user scripts directory (`pip install --user`); and the scripts directory next to the package (`pip install --target` / `--prefix`). If none has the binary, it raises `FileNotFoundError` listing every path it tried.
65
+
66
+ ## `ESBUILD_BINARY_PATH` and unsupported platforms
67
+
68
+ `ESBUILD_BINARY_PATH` is esbuild's own override variable. If it is set, `find_esbuild_bin()` and `python -m esbuild_bin` use that executable and nothing else; if it doesn't point to an executable file, they raise an error. On a platform without a wheel (see below), `pip install` fails with "no matching distribution". In that case, install esbuild another way and point `ESBUILD_BINARY_PATH` at it.
69
+
70
+ ## Platforms
71
+
72
+ | Platform | Wheel tag | Tested in CI |
73
+ | --- | --- | --- |
74
+ | Linux x86_64 (glibc and musl) | `manylinux_2_17_x86_64`, `musllinux_1_1_x86_64` | yes, including Alpine |
75
+ | Linux aarch64 (glibc and musl) | `manylinux_2_17_aarch64`, `musllinux_1_1_aarch64` | yes |
76
+ | macOS arm64, 12.0+ | `macosx_12_0_arm64` | yes |
77
+ | macOS x86_64, 12.0+ | `macosx_12_0_x86_64` | yes |
78
+ | Windows x64 | `win_amd64` | yes |
79
+ | Windows arm64 | `win_arm64` | yes |
80
+ | Linux armv7l, i686, ppc64le, s390x | `manylinux_2_17_*`, `musllinux_1_1_*` | tags only |
81
+ | Windows x86 | `win32` | tags only |
82
+
83
+ The Linux binaries are statically linked, so one wheel serves both glibc and musl. The build checks every binary's OS, architecture, linking and minimum macOS version, and refuses to ship a wheel whose tag doesn't match its binary.
84
+
85
+ ## Verifying a wheel
86
+
87
+ The release pipeline is designed so that every step can be checked:
88
+
89
+ - **Input.** Every npm tarball is checked against npm's `dist.integrity` sha512 before anything is extracted. The binary is never modified: no stripping, signing or patching.
90
+ - **Provenance.** Releases are published only from GitHub Actions, using PyPI trusted publishing with [PEP 740](https://peps.python.org/pep-0740/) attestations. PyPI shows each file's attestation, which links it to the workflow run that built it.
91
+ - **Reproducibility.** Wheels have fixed timestamps and a fixed entry order, so you can rebuild a release and compare hashes:
92
+
93
+ ```sh
94
+ git clone https://github.com/RemiDesgrange/python-esbuild && cd python-esbuild
95
+ git checkout v0.28.2
96
+ uv sync --locked
97
+ uv run python scripts/build_wheels.py --out dist
98
+ sha256sum dist/*.whl # compare with the hashes shown on PyPI
99
+ ```
100
+
101
+ Timestamps come from `SOURCE_DATE_EPOCH`, which defaults to the tagged commit's time.
102
+
103
+ ## License
104
+
105
+ The packaging code is MIT-licensed (see `LICENSE`). esbuild is MIT-licensed, Copyright (c) 2020 Evan Wallace. Its license ships in every wheel as `esbuild_bin-*.dist-info/licenses/LICENSE.md`.
@@ -0,0 +1,10 @@
1
+ esbuild_bin-0.28.2.data/scripts/esbuild.exe,sha256=suYq9cF-AJOVg74KB2L9xGnzUoaaYX7ckTcbAEVMdvA,11051520
2
+ esbuild_bin-0.28.2.dist-info/METADATA,sha256=T3C5vXkiCwc17JyIXJDiVqCBSvNNcsTnjOaug0Gbog4,5484
3
+ esbuild_bin-0.28.2.dist-info/WHEEL,sha256=sMsud3X0Z7SjreV7ddamNYXJY0740E03yRf8G3Hkukg,111
4
+ esbuild_bin-0.28.2.dist-info/licenses/LICENSE.md,sha256=tA7Fuux7s0-lscCVIfo81S1frXra_tdJMqIBDTYSpoE,1069
5
+ esbuild_bin/__init__.py,sha256=yDjQcO9ljOyt5ScrX4t8-QKbgqavVPBSHqkj_lFEobo,335
6
+ esbuild_bin/__main__.py,sha256=Hu_MZzRVKuxHSlCGS9PkChbEJh_uT8zyOA6vWurVZX0,669
7
+ esbuild_bin/_find.py,sha256=LQZBkaA-vMFlAO0yNqv6CVwZJOWw4wgfg6jNbHDE6es,3336
8
+ esbuild_bin/_version.py,sha256=voxR3qLyInMFit1Mmgrj9rAJqkHb1w9xq7iHDpcEqP4,172
9
+ esbuild_bin/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
+ esbuild_bin-0.28.2.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: esbuild-bin (scripts/build_wheels.py)
3
+ Root-Is-Purelib: false
4
+ Tag: py3-none-win32
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Evan Wallace
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.