Skip to main content

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 --bucket gs://my-pypi/packages -- pip install my-private-lib
gcs-pypi --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 / .zip files 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 auto falls back to gcloud auth print-access-token for 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 none for 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 has x-goog-meta-sha256 metadata, that hash is used instead. x-goog-meta-requires_python becomes data-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 --bucket gs://b/prefix -- <cmd...> sets PIP_INDEX_URL and UV_DEFAULT_INDEX for <cmd>, then exits with its exit code
Long-running gcs-pypi --bucket gs://b/prefix --addr 127.0.0.1:8765 prints the env lines and serves until Ctrl-C
Background eval "$(gcs-pypi --bucket gs://b/prefix --daemon)" returns once the server is ready and exports the env vars plus GCS_PYPI_PID in your shell; stop it with kill $GCS_PYPI_PID
Point the shell at a running server eval "$(gcs-pypi env)" exports PIP_INDEX_URL and UV_DEFAULT_INDEX for 127.0.0.1:8765 (the systemd service); --addr for another address
systemd service see Running as a systemd service
Flag / env Default
--bucket / GCS_PYPI_BUCKET — gs://bucket[/prefix]
--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: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 serve in the background (not with a command)
--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

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

  1. Grant the VM's service account roles/storage.objectViewer on the bucket.
  2. Make sure the VM has the cloud-platform scope. Workbench instances have it by default.
  3. Ship the binary in your image, or gcloud storage cp it from a bucket in a startup script. Build it once with make dist, which produces a fully static binary (see Development). Or install the wheel, see below.

Example Dockerfile or startup step:

RUN gcs-pypi --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.2.0-*.whl' wheels/
pip install --no-index --find-links wheels/ gcs-pypi-proxy==0.2.0
# or: uv tool install --no-index --find-links wheels/ gcs-pypi-proxy==0.2.0

eval "$(gcs-pypi --bucket gs://my-pypi/packages --daemon)"
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.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for gcs-pypi-proxy 0.2.0
File Actions
gcs_pypi_proxy-0.2.0-py3-none-musllinux_1_2_x86_64.whl Python 3 none Linux musl 1.2+ x86-64 Details for gcs_pypi_proxy-0.2.0-py3-none-musllinux_1_2_x86_64.whl
gcs_pypi_proxy-0.2.0-py3-none-musllinux_1_2_aarch64.whl Python 3 none Linux musl 1.2+ ARM64 Details for gcs_pypi_proxy-0.2.0-py3-none-musllinux_1_2_aarch64.whl
gcs_pypi_proxy-0.2.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64 Details for gcs_pypi_proxy-0.2.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
gcs_pypi_proxy-0.2.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64 Details for gcs_pypi_proxy-0.2.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
gcs_pypi_proxy-0.2.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details for gcs_pypi_proxy-0.2.0-py3-none-macosx_11_0_arm64.whl
gcs_pypi_proxy-0.2.0-py3-none-macosx_10_12_x86_64.whl Python 3 none macOS 10.12+ x86-64 Details for gcs_pypi_proxy-0.2.0-py3-none-macosx_10_12_x86_64.whl

Total release size: 8.8 MB

Release files / gcs_pypi_proxy-0.2.0-py3-none-musllinux_1_2_x86_64.whl

Download URL gcs_pypi_proxy-0.2.0-py3-none-musllinux_1_2_x86_64.whl
Size 1.5 MB
Tags Linux musl 1.2+ x86-64 Python 3
SHA-256 checksum
How to use checksums
c0cfe3a15313592ce8e89fc140859aa36208f2d80205010610a0d7ed8a6f37f4
BLAKE2b-256 checksum
How to use checksums
b343744f726702c5a95f17157bf597a0ce14a889a23fd36f88456a57ad84986b
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.2.0-py3-none-musllinux_1_2_aarch64.whl

Download URL gcs_pypi_proxy-0.2.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
637d094e008a41dd0f90066e4073f5cc096ee1e4884b138a57ade8ac7d9ea1b9
BLAKE2b-256 checksum
How to use checksums
ed4433a42561ddb29b8a17160557d98255e22dfdd3cbdde6f71b279b595c8ed3
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.2.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL gcs_pypi_proxy-0.2.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
b7310f8dca38f671e1b1fa2c056d21505406213ef4fce1941289740813c87114
BLAKE2b-256 checksum
How to use checksums
06e978eacbf75366ecb8bf6310800459305737764827f80895d97dd195877706
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.2.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL gcs_pypi_proxy-0.2.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
807b87e5d007502bc1dead3aa43bceb1b2a7cdc53c25e09c97bec9d7025ba4a8
BLAKE2b-256 checksum
How to use checksums
7883419933b10d5be2b6a2baf2f350eff2603e273716675b156895814cffd24a
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.2.0-py3-none-macosx_11_0_arm64.whl

Download URL gcs_pypi_proxy-0.2.0-py3-none-macosx_11_0_arm64.whl
Size 1.3 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
266f057729e21236acee68073934cdf2cdfd16e89feaafeec8360436e485b08d
BLAKE2b-256 checksum
How to use checksums
374d589775122ac22ae8fabf6ef77fc678c7027ee4fdf4674831b4d3e2b89fe8
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.2.0-py3-none-macosx_10_12_x86_64.whl

Download URL gcs_pypi_proxy-0.2.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
0a186c69b4acd46c764504543a7170e675129aa717fc2d7443312110576c7cb9
BLAKE2b-256 checksum
How to use checksums
1a8e45b306c7a9ffa28326c7718a42628576a935470a9553d8054addc62a3905
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.2.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.

Release history Release notifications | RSS feed

This release

0.2.0 This release

6 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page