A small self-hosted PyPI simple-index server that serves local packages and redirects cache misses upstream.
Project description
PyPI Redirect Server
PyPI Redirect Server is a small, dependency-free Python service that acts like a PyPI Simple Repository API server. It serves packages from a local directory when they are available and redirects missing packages to a configurable upstream repository such as the official PyPI.
Features
- Serves local wheel and source distribution files through
/simple/. - Redirects cache misses to a configurable upstream repository.
- Uses only the Python standard library at runtime.
- Runs on Windows, macOS, and Linux.
- Refreshes the local package cache while the server is running.
- Logs every request routing decision to stdout.
- Serves the latest cached version by default when a project has multiple versions.
- Provides a console command and a
python -mentry point.
Installation
From a checkout:
python -m pip install -e .
No runtime dependencies are installed.
Quick Start
Create a cache directory and put package files in it:
mkdir packages
python -m pip download requests -d packages
Start the server:
pypi-redirect-server --package-dir packages --host 127.0.0.1 --port 8080
Install packages through the server:
python -m pip install --index-url http://127.0.0.1:8080/simple requests
If requests exists in packages, pip downloads it from this server. If a
package is not in the local cache, the server redirects pip to the configured
upstream repository.
Every request writes a routing log line to stdout:
time=2026-05-28T06:56:05Z client=127.0.0.1:65503 method=GET path="/simple/demo-pkg/" status=200 action=local-index project=demo-pkg requested_version=- selected_version=2.0.0 upstream=no
Upstream Repository
The default upstream is the official PyPI:
https://pypi.org
Change it with --upstream:
pypi-redirect-server --upstream https://pypi.org/simple
The upstream can be either a site root or a Simple API root. For example,
https://pypi.org and https://pypi.org/simple both work.
Package Cache Layout
The cache can be flat:
packages/
demo_pkg-1.0.0-py3-none-any.whl
other_project-2.1.0.tar.gz
It can also be grouped by project:
packages/
demo-pkg/
demo_pkg-1.0.0-py3-none-any.whl
See Package Cache for details.
Configuration
Every setting is available as a command-line flag and as an environment variable. Common examples:
pypi-redirect-server --package-dir packages --upstream https://pypi.org --port 8080
PYPI_REDIRECT_PACKAGE_DIR=packages PYPI_REDIRECT_UPSTREAM=https://pypi.org pypi-redirect-server
On PowerShell:
$env:PYPI_REDIRECT_PACKAGE_DIR = "packages"
$env:PYPI_REDIRECT_UPSTREAM = "https://pypi.org"
pypi-redirect-server
See Configuration for the full reference.
Development
Run the tests with:
python -m unittest discover -s tests
Run the server directly from the source tree after installation:
python -m pypi_redirect_server --package-dir packages
Behavior
For a request like /simple/demo/:
- The server normalizes
demousing PEP 503 rules. - If cached files for
demoexist, it returns local links for the latest cached version. - If a local version selector is present, such as
?version=1.0.0or?minor=1.2, it returns the latest matching local files. - If no matching local files exist, it redirects to the configured upstream, for
example
https://pypi.org/simple/demo/.
Local package file URLs are served from /packages/<project>/<filename>.
Use --all-versions when you want the local Simple API page to expose every
cached version and let pip do all version resolution client-side.
Pip does not send command-line version constraints such as demo==1.0.0 to a
Simple API server. The ?version= and ?minor= selectors are useful for direct
HTTP clients, but pip normally resolves versions from the links returned by the
index page.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pypi_redirect_server-0.1.0.tar.gz.
File metadata
- Download URL: pypi_redirect_server-0.1.0.tar.gz
- Upload date:
- Size: 15.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.4.1 CPython/3.11.15 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
088f3a52c8a89b52d3c44898313ff9861b8f536d36f640c1a48e554354f44f49
|
|
| MD5 |
7bc602198d00be4be498c45549e7866f
|
|
| BLAKE2b-256 |
eafcc9462038f631ded887088c5104572e0e6c72c3b964c52d82e11c4c3eaba6
|
File details
Details for the file pypi_redirect_server-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pypi_redirect_server-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.4.1 CPython/3.11.15 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d46e6d81b5f1b368fd0eafa0d39eb7b954263c2b0bf519e5d74a15b829edf164
|
|
| MD5 |
0d4c4e70b5538a1d747c457c76ca122e
|
|
| BLAKE2b-256 |
39a80ef2a092ef6ec19097fb90ffadd8335a0063847b2708228ae141cac5d5ee
|