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.
Release files for pypi-redirect-server 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pypi_redirect_server-0.1.0.tar.gz | 15.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pypi_redirect_server-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 27.0 kB
Release files / pypi_redirect_server-0.1.0.tar.gz
| Download URL | pypi_redirect_server-0.1.0.tar.gz |
|---|---|
| Size | 15.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
088f3a52c8a89b52d3c44898313ff9861b8f536d36f640c1a48e554354f44f49
|
|
BLAKE2b-256 checksum How to use checksums |
eafcc9462038f631ded887088c5104572e0e6c72c3b964c52d82e11c4c3eaba6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.1 CPython/3.11.15 Windows/10
|
Release files / pypi_redirect_server-0.1.0-py3-none-any.whl
| Download URL | pypi_redirect_server-0.1.0-py3-none-any.whl |
|---|---|
| Size | 12.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d46e6d81b5f1b368fd0eafa0d39eb7b954263c2b0bf519e5d74a15b829edf164
|
|
BLAKE2b-256 checksum How to use checksums |
39a80ef2a092ef6ec19097fb90ffadd8335a0063847b2708228ae141cac5d5ee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.1 CPython/3.11.15 Windows/10
|