gcs-pypi
A ~3 MB static Rust binary that turns a GCS bucket of wheels/sdists into a local PEP 503 index for pip and uv. It is meant to start right before an install and stop right after.
gcs-pypi exec --bucket gs://my-pypi/packages -- pip install my-private-lib
gcs-pypi exec --bucket gs://my-pypi/packages -- uv sync
How it works
pip / uv ──HTTP──▶ 127.0.0.1:<random>/simple/ (gcs-pypi)
│ project in bucket? ── yes ─▶ HTML page generated from the bucket listing
│ ── no ──▶ 307 redirect to https://pypi.org/simple/<name>/
└─ /files/<object> ─────────────▶ streamed from GCS with the VM's token
- No index files in the bucket. Drop
.whl/.tar.gz/.zipfiles anywhere under the prefix. The listing is the index, so nothing needs regenerating and nothing goes stale. - Auth comes from the VM. The token is fetched from the metadata server, which works on
Vertex Workbench, GCE, GKE and Cloud Run. It is cached and refreshed before it expires.
--auth autofalls back togcloud auth print-access-tokenfor laptops. - No dependency confusion. A project that exists in the bucket is served only from
the bucket and is never looked up upstream. Unknown projects are redirected to
--upstream, which defaults to PyPI. Use--upstream nonefor air-gapped VMs, or set it to your mirror. - Hashes. Every link carries
#md5=from GCS metadata, so pip and uv verify each download. If an object hasx-goog-meta-sha256metadata, that hash is used instead.x-goog-meta-requires_pythonbecomesdata-requires-python. - Fails fast. The bucket is listed before the wrapped command starts. Missing permissions show up as one clear error rather than as a pip "no matching distribution".
Usage
| Mode | Command |
|---|---|
| Wrap a command (recommended) | gcs-pypi exec --bucket gs://b/prefix -- <cmd...> serves on a free port only while <cmd> runs, sets PIP_INDEX_URL and UV_DEFAULT_INDEX for <cmd>, then exits with its exit code |
| Long-running | gcs-pypi start --bucket gs://b/prefix serves on 127.0.0.1:8765 until Ctrl-C, SIGTERM or gcs-pypi stop |
| Background | gcs-pypi start --bucket gs://b/prefix --daemon returns once the server is ready and prints its URL |
| Point the shell at a running server | eval "$(gcs-pypi env)" exports PIP_INDEX_URL and UV_DEFAULT_INDEX |
| Stop it | gcs-pypi stop sends SIGTERM and waits until the server has exited |
| systemd service | see Running as a systemd service |
All subcommands take the same options, so replacing start with env or stop in a command line
finds the server that command started. env uses a fixed --addr as given. Otherwise it reads
the server's URL from the pid file, which works for a random port too, and falls back to
127.0.0.1:8765 (e.g. the systemd service) if no server is recorded there.
opts=(--bucket gs://b/prefix --addr 127.0.0.1:0)
gcs-pypi start --daemon "${opts[@]}"
eval "$(gcs-pypi env "${opts[@]}")"
pip install my-private-lib
gcs-pypi stop "${opts[@]}"
| Flag / env | Default | |
|---|---|---|
--bucket / GCS_PYPI_BUCKET |
— | gs://bucket[/prefix], required by start and exec |
--upstream / GCS_PYPI_UPSTREAM |
https://pypi.org/simple/ |
none disables |
--auth / GCS_PYPI_AUTH |
auto |
metadata, gcloud, none |
--cache-ttl / GCS_PYPI_CACHE_TTL |
60 |
seconds the listing is cached |
--addr / GCS_PYPI_ADDR |
127.0.0.1:8765; with exec 127.0.0.1:0 |
port 0 = random free port |
--endpoint / GCS_PYPI_ENDPOINT |
https://storage.googleapis.com |
for emulators |
-v |
off | log fetches and upstream redirects |
--daemon |
off | start in the background |
--log-file / GCS_PYPI_LOG_FILE |
<temp dir>/gcs-pypi.log |
log of the background server; if it fails to start, the error is also printed |
--pid-file / GCS_PYPI_PID_FILE |
$XDG_RUNTIME_DIR/gcs-pypi.pid, or <temp dir>/gcs-pypi.pid without it; with exec none |
the server's PID (line 1) and URL (line 2), removed when it stops; env and stop read it, start fails while that process runs |
Publishing
python -m build # or: uv build
for f in dist/*; do
gcloud storage cp "$f" gs://my-pypi/packages/ \
--custom-metadata=sha256=$(sha256sum "$f" | cut -d' ' -f1) \
--if-generation-match=0 # refuse to overwrite an existing version
done
The sha256 metadata is optional; md5 works without it.
Setup on Vertex Workbench / GCE
- Grant the VM's service account
roles/storage.objectVieweron the bucket. - Make sure the VM has the
cloud-platformscope. Workbench instances have it by default. - Ship the binary in your image, or
gcloud storage cpit from a bucket in a startup script. Build it once withmake dist, which produces a fully static binary (see Development). Or install the wheel, see below.
Example Dockerfile or startup step:
RUN gcs-pypi exec --bucket gs://my-pypi/packages -- pip install --no-cache-dir -r requirements.txt
Install from a wheel
make wheel builds one wheel per platform, e.g.
gcs_pypi_proxy-<version>-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
| Platform | Wheel tag |
|---|---|
| Linux x86_64 / aarch64, glibc 2.17+ | manylinux_2_17_{x86_64,aarch64} |
| Linux x86_64 / aarch64, musl (Alpine) | musllinux_1_2_{x86_64,aarch64} |
| macOS Intel, 10.12+ | macosx_10_12_x86_64 |
| macOS Apple silicon, 11+ | macosx_11_0_arm64 |
A wheel contains only the binary, so it works with any Python version. Upload all of them to the
same place and pip or uv picks the one that matches the machine. The distribution is called
gcs-pypi-proxy, because gcs-pypi on PyPI is an unrelated project; the command is still
gcs-pypi.
In a running container:
gcloud storage cp 'gs://my-pypi/tools/gcs_pypi_proxy-0.3.0-*.whl' wheels/
pip install --no-index --find-links wheels/ gcs-pypi-proxy==0.3.0
# or: uv tool install --no-index --find-links wheels/ gcs-pypi-proxy==0.3.0
gcs-pypi start --bucket gs://my-pypi/packages --daemon
eval "$(gcs-pypi env)"
pip install my-private-lib
Running as a systemd service
systemd/gcs-pypi.service runs the server in the foreground on the fixed address
127.0.0.1:8765, with metadata-server auth and a dynamic, unprivileged user:
sudo install -m 0755 gcs-pypi /usr/local/bin/gcs-pypi
sudo install -m 0644 systemd/gcs-pypi.service /etc/systemd/system/
echo 'GCS_PYPI_BUCKET=gs://my-pypi/packages' | sudo tee /etc/default/gcs-pypi
sudo systemctl daemon-reload
sudo systemctl enable --now gcs-pypi
journalctl -u gcs-pypi -f
Then point pip and uv at it, either per shell, e.g. in ~/.bashrc:
eval "$(gcs-pypi env)"
or for everyone, in /etc/pip.conf and /etc/uv/uv.toml:
[global]
index-url = http://127.0.0.1:8765/simple/
[[index]]
url = "http://127.0.0.1:8765/simple/"
default = true
Testing locally without GCP
--auth none --endpoint http://localhost:4443 works against
fake-gcs-server.
Development
make lists the targets:
| Target | |
|---|---|
make build |
debug build |
make test |
run the unit tests |
make fmt |
apply clippy --fix, then cargo fmt |
make lint |
cargo fmt --check and cargo clippy -D warnings; fails on any warning |
make dist |
clean, lint, test, then optimized binaries copied to dist/gcs-pypi-<commit>-<target> |
make wheel |
clean, lint, test, then the wheels in dist/ |
make dist-all |
clean, lint, test, then the binaries and the wheels in dist/ |
make clean |
cargo clean and remove dist/ |
Both build for Linux x86_64 and aarch64 and for macOS x86_64 and arm64. make dist builds
fully static musl binaries for Linux, so one binary per architecture runs on any distro.
make wheel builds manylinux2014 and musllinux_1_2 wheels for Linux and native macOS wheels.
Linux targets are cross-compiled with zig (cargo-zigbuild for dist, maturin for wheel) on
Linux and macOS hosts alike. macOS targets link against the macOS SDK, so they build only on a
Mac. Elsewhere, pick the targets yourself:
make dist DIST_TARGETS="x86_64-unknown-linux-musl aarch64-unknown-linux-musl"
make wheel WHEEL_TARGETS="x86_64-unknown-linux-gnu"
Only uv needs to be installed: uvx fetches cargo-zigbuild, maturin and zig at the versions
pinned in the Makefile. rust-toolchain.toml lists all targets, so rustup installs them on the
first build. make dist and make wheel both start with make clean, which empties dist/;
run make dist-all to get the binaries and the wheels together.
The version comes from Cargo.toml; bump it there before building a wheel to hand out.
The toolchain (stable, with rustfmt and clippy) is pinned in rust-toolchain.toml. To skip the
reformat commit in git blame, run git config blame.ignoreRevsFile .git-blame-ignore-revs.
Metadata
Release files for gcs-pypi-proxy 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
Total release size: 8.9 MB
Release files / gcs_pypi_proxy-0.3.0-py3-none-musllinux_1_2_x86_64.whl
| Download URL | gcs_pypi_proxy-0.3.0-py3-none-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 1.6 MB |
| Tags | Linux musl 1.2+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
9bad433205cd6996e160e2c2a749718230a154db1c88d11c3ecd7fe69a21ca12
|
|
BLAKE2b-256 checksum How to use checksums |
f6a650bb38a31ccdf972d1bb6c018eb517f5c8db38b46f8661c276f7ee40546b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.5
|
Release files / gcs_pypi_proxy-0.3.0-py3-none-musllinux_1_2_aarch64.whl
| Download URL | gcs_pypi_proxy-0.3.0-py3-none-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | Linux musl 1.2+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
65cd9a2c551551279dba1960007da022aed1fa46e04cd9221bce79286bca3457
|
|
BLAKE2b-256 checksum How to use checksums |
7a8f57b3d82b20ad7d59a9450082074a4db44d0b8d9dd6e32c5c5bc386c99d14
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.5
|
Release files / gcs_pypi_proxy-0.3.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | gcs_pypi_proxy-0.3.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | Linux glibc 2.17+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
c96e2684de1c1c4b554ba37ffcde07a66b2fed26e9c031f8498cf50279f71ad3
|
|
BLAKE2b-256 checksum How to use checksums |
537c7a191555c5fa17d6751b1eaade0fb4c5e83426073bc013374b040ac8f534
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.5
|
Release files / gcs_pypi_proxy-0.3.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | gcs_pypi_proxy-0.3.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | Linux glibc 2.17+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
b87e42284e523405e41f2022b608168357e21935b2d3d85b43c92fb4ea6b830b
|
|
BLAKE2b-256 checksum How to use checksums |
a4c7f09acd75b6abd3e1bfdb3d83850097119f3a3a7aadd2502e723ecec3ded9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.5
|
Release files / gcs_pypi_proxy-0.3.0-py3-none-macosx_11_0_arm64.whl
| Download URL | gcs_pypi_proxy-0.3.0-py3-none-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | Python 3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
781ba0da6156d70b0b1c2c65a52129cbda44d813073f3c0d21441ad099370ab6
|
|
BLAKE2b-256 checksum How to use checksums |
b720af9d2a7310d5ff65bf0ce62842ce41bdc66fe25df3b3d86563a9c9a36e5a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.5
|
Release files / gcs_pypi_proxy-0.3.0-py3-none-macosx_10_12_x86_64.whl
| Download URL | gcs_pypi_proxy-0.3.0-py3-none-macosx_10_12_x86_64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | Python 3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
b812a82b24da026a06f8cd69bbffad8efcbd16fd653c59d092e5e6ffff8a715f
|
|
BLAKE2b-256 checksum How to use checksums |
8f2b03e6fcd9ebf9fb04ec74912a496d4d33932ad786597f0a73cc2fdb18f73a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.5
|
Security for gcs-pypi-proxy 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.