devpi-server
devpi-server is the backend component of the devpi system, providing a robust and flexible solution for hosting private Python package indexes and acting as an on-demand caching mirror for PyPI. It allows users to manage multiple indexes, upload packages and documentation, and configure index inheritance, making it ideal for enterprise environments and local development workflows. The current version is 6.19.3, with a regular release cadence as seen from recent changelog entries.
Common errors
-
ERROR: Could not find a version that satisfies the requirement <package_name> (from versions: none) / ERROR: No matching distribution found for <package_name>
cause This typically occurs when `pip` cannot locate the package on the configured `devpi-server` index. Common causes include the package not being uploaded, an incorrect index URL configured in `pip`, or the `devpi-server` not correctly serving the package.fixVerify the package name and version are correct and have been uploaded to the `devpi-server`. Ensure `pip` is configured with the correct index URL (e.g., `pip install --index-url http://your-devpi-host:3141/youruser/dev/+simple/ <package_name>`). For caching mirrors, ensure the mirror base is correctly configured to include PyPI. -
Connection refused (or [Errno 111] Connection refused) when using devpi client or pip
cause The `devpi-server` process is either not running, or it is running but inaccessible due to incorrect binding (e.g., only to `localhost`) or a firewall blocking the port (default 3141).fixCheck if `devpi-server` is running. If starting manually, use `devpi-server --host 0.0.0.0` to make it accessible remotely. Verify that no firewall rules are blocking the server's port (default 3141). If using a reverse proxy, ensure it's correctly configured and routing requests to the `devpi-server`. -
Packages uploaded to devpi-server appear, but versions are not shown in PyCharm/IDE and installation fails via UI.
cause Some IDEs, including PyCharm, may have issues parsing custom PyPI index formats or handling authentication correctly when interacting with `devpi-server`'s web interface, even if the packages are visible.fixWhile the IDE's UI might fail, typically installation via the terminal using `pip install --index-url=http://your-devpi-host:3141/youruser/dev/+simple/ <package_name>` works. Configure the IDE to use the exact `pip` command or ensure its repository settings precisely match the `devpi-server`'s simple index URL and any required authentication.
Warnings
- deprecated Several command-line options like `--init`, `--gendeploy`, `--export`, `--import`, `--passwd`, `--start`, `--stop`, `--status`, and `--log` for `devpi-server` were deprecated in versions 5.x and later. These functionalities have been replaced by dedicated `devpi-` commands (e.g., `devpi-init`, `devpi-gen-config`, `devpi-export`, `devpi-passwd`, and using process managers like systemd for server control).
- breaking When upgrading `devpi-server` from versions 3.x to 4.0.0, a change in project name normalization required an export/import cycle of your server data. Failure to do so could result in inconsistent project metadata.
- gotcha By default, `devpi-server` may bind only to the loopback address (`127.0.0.1` or `localhost`), making it inaccessible from other machines on the network. Attempts to `pip install` or `devpi use` from a remote host will result in 'Connection refused' errors.
- gotcha Incorrect management of the `--serverdir` option or server process lifecycle can lead to perceived data loss or inconsistent server states, especially if the `serverdir` path changes between server starts, or if a new `--init` is run on an existing data directory.
Install
-
pip install devpi-server -
pip install devpi
Imports
- IndexServer
from devpi_process import IndexServer
- Index
from devpi_process import Index
Quickstart
import os
import shutil
from pathlib import Path
from devpi_process import Index, IndexServer
# Define a temporary directory for the server data
server_dir = Path("./devpi_temp_server_data")
# Ensure the directory is clean for a fresh start
if server_dir.exists():
shutil.rmtree(server_dir)
server_dir.mkdir()
print(f"Starting devpi-server with data directory: {server_dir}")
with IndexServer(server_dir) as server:
# The server starts with a 'root' user and a 'root/pypi' index by default.
# 'root/pypi' proxies to the public PyPI.
print(f"devpi-server running at: {server.url}")
# Programmatically create a new user and an index
print("Creating user 'myuser' and index 'dev'...")
user_name = "myuser"
index_name = "dev"
# Note: devpi_process handles user/index creation via its API, typically abstracting client commands.
# In a real scenario, you might interact via devpi-client or its programmatic equivalent
# For simplicity, we'll demonstrate a basic server startup and assume external client interaction.
# Example of how you might interact with the server after it's up
# (This part would typically use devpi-client commands externally or a more complete devpi_process API)
print("You can now interact with the server using devpi-client or pip:")
print(f" - Web interface: {server.url}")
print(f" - Pip index URL: {server.url}/root/pypi/+simple/")
print("Run 'devpi quickstart' in another terminal for client setup examples.")
# To keep the server running for a brief moment for demonstration
# In a real application, the 'with' block would manage its lifecycle.
print("Server will run for 10 seconds. Press Ctrl+C to stop sooner.")
import time
try:
time.sleep(10)
except KeyboardInterrupt:
print("Stopping server.")
print("devpi-server stopped.")
if server_dir.exists():
shutil.rmtree(server_dir)
print(f"Cleaned up data directory: {server_dir}")