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

### 仅仅在当前安装时使用
```shell
pip install -i https://py3.online/simple
```

### 设为 pip
```shell
pip config set global.index-url https://py3.online/simple
```

### 设置 PDM
```shell
pdm config pypi.url https://py3.online/simple
```

### 设置 Poetry
```shell
poetry source add --priority=primary mirrors https://py3.online/simple/
```

---

### 起源
起初只是为了让我的 serverless 在线 python（py3.online）国内也能轻松使用上：

<a href="https://py3.online" id="pq9EP" class="ne-image-link"><img src="https://py3.online/og" width="1200" title="" crop="0,0,1,1" class="ne-image"></a>

于是就 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 为例，速度是清华源的两倍：

<img src="https://s2.loli.net/2024/04/21/mSC7dRQie8jzWTM.png" width="1319" title="" crop="0,0,1,1" id="qS0Pn" class="ne-image">



---



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

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

i.free-chat.asia/simple

确实都可以了