Poetry PyPI Mirror Plugin

0.6.3 · active · verified Sat Apr 11

Poetry plugin that adds support for pypi.org mirrors and pull-through caches. It enables Poetry to substitute connections to pypi.org with connections to a mirror or pull-through cache without requiring project configuration changes. This design prevents source entries for the mirror from appearing in `poetry.lock`. The current version is 0.6.3 and it is actively maintained.

Warnings

Install

Quickstart

Install the plugin using `poetry self add`. Then, configure your PyPI mirror URL either via the `POETRY_PYPI_MIRROR_URL` environment variable or by setting `plugins.pypi_mirror.url` in your Poetry configuration (global or project-specific). The environment variable takes precedence. Once configured, Poetry commands that interact with PyPI (like `poetry add` or `poetry install`) will automatically use the mirror. If authentication is required, configure it for the 'PyPI' repository using `poetry config http-basic.PyPI <username> <password>`.

# 1. Install the plugin (if not already installed)
# poetry self add poetry-plugin-pypi-mirror

# 2. Configure the PyPI mirror URL
# Option A: Environment Variable (takes precedence)
import os
import subprocess

mirror_url = os.environ.get('POETRY_PYPI_MIRROR_URL', 'https://your-private-mirror.org/simple/')

# Example using the environment variable directly with a poetry command
print(f"Using mirror: {mirror_url}")
subprocess.run([
    'poetry',
    '--version'
]) # Replace with actual poetry command using the mirror

# Option B: Poetry config (global or project-specific)
# To set globally:
# poetry config plugins.pypi_mirror.url https://your-private-mirror.org/simple/
# To set for a project (in pyproject.toml):
# [plugins.pypi_mirror]
# url = "https://your-private-mirror.org/simple/"

# 3. Add a dependency, which will use the configured mirror for PyPI
# poetry add requests

view raw JSON →