配置 Python
将 pip、uv 与 Poetry 的包请求接入 Depsilo,同时保留现有 requirements、pyproject 与安装流程。
之前
https://pypi.org/simple之后
http://localhost:23333/pypi/simple/三种客户端都使用同一个 /pypi/simple/ 端点。优先提交项目级配置;修改用户级配置前,先记录原来的 index 以便回滚。
[global]index-url = http://localhost:23333/pypi/simple/# 仅明文 HTTP 需要:trusted-host = localhost:23333也可以用 pip 自己写入用户级配置:
pip config set global.index-url http://localhost:23333/pypi/simple/# 仅明文 HTTP 需要:pip config set global.trusted-host localhost:23333[[tool.uv.index]]name = "depsilo"url = "http://localhost:23333/pypi/simple/"default = true设置 default = true,让 uv 默认通过 Depsilo 解析包,而不是并行使用公网索引。
poetry source add --priority=primary depsilo \ http://localhost:23333/pypi/simple/等价的项目配置如下:
[[tool.poetry.source]]name = "depsilo"url = "http://localhost:23333/pypi/simple/"priority = "primary"-
检查实例就绪状态
Terminal window curl -fsS http://localhost:23333/ready -
发出一次不修改环境的请求
Terminal window pip install --dry-run --ignore-installed --no-cache-dir --no-deps \--index-url http://localhost:23333/pypi/simple/ six -
在 Admin 中确认流量
打开 Admin 的 Access logs(
/admin/logs),确认请求的生态、包名与响应状态。安装成功本身不能证明流量经过了 Depsilo。
在 CI 中使用
Section titled “在 CI 中使用”通过 CI 环境变量覆盖索引,无需改写 requirements 文件。把示例主机名替换为 Runner 实际可达的 Depsilo 地址:
export PIP_INDEX_URL=http://depsilo.internal:23333/pypi/simple/# 仅明文 HTTP 需要:export PIP_TRUSTED_HOST=depsilo.internal:23333
pip install -r requirements.txt如果 CI 在容器中运行,localhost 指向容器自身,不能代表宿主机上的 Depsilo。
HTTPS 还需要 trusted-host 吗?
Section titled “HTTPS 还需要 trusted-host 吗?”不需要。trusted-host 只是明文 HTTP 的信任例外。通过有效 HTTPS 证书提供 Depsilo 时应移除它。
恢复配置前记录的原始 index,然后重新解析或安装一次依赖。不要通过新增一个并行公网 fallback 来“回滚”,否则请求路径将变得不可预测。
其他 Python 客户端使用哪个端点?
Section titled “其他 Python 客户端使用哪个端点?”Pipenv 与 PDM 也使用 /pypi/simple/。在 Portal 中选择对应客户端,复制它提供的项目级配置。