# 建了一个 PyPI 镜像 (April 21, 2024)

### 仅仅在当前安装时使用
```shell
pip install -i https://pyth-on-line.promplate.dev/simple
```

### 设为 pip
```shell
pip config set global.index-url https://pyth-on-line.promplate.dev/simple
```

### 设置 PDM
```shell
pdm config pypi.url https://pyth-on-line.promplate.dev/simple
```

### 设置 Poetry
```shell
poetry source add --priority=primary mirrors https://pyth-on-line.promplate.dev/simple/
```

---

### 起源
起初只是为了让我的 serverless 在线 python（pyth-on-line.promplate.dev）国内也能轻松使用上：

[![](https://pyth-on-line.promplate.dev/og)](https://pyth-on-line.promplate.dev)

于是就 proxy 了一下 PyPI 和 pythonhosted 两个域名：

+ [/src/routes/simple/[[project]]/+server.ts](https://github.com/promplate/pyth-on-line/blob/main/src/routes/simple/[[project]]/+server.ts)
+ [/src/routes/packages/[...path]/+server.ts](https://github.com/promplate/pyth-on-line/blob/main/src/routes/packages/[...path]/+server.ts)

实测速度飞快，以安装 torch 为例，速度是清华源的两倍：

![](https://s2.loli.net/2024/04/21/mSC7dRQie8jzWTM.png)



---



但是 Netlify 的响应体上限好像有点低

又试着在别的项目也部署了下，比如

i.free-chat.asia/simple

确实都可以了