未验证 提交 e3642300 编写于 作者: F Frost Ming

fix: respect `--prerelease` in the install script

上级 dcb68ab6
......@@ -92,7 +92,7 @@ curl -sSL https://raw.githubusercontent.com/pdm-project/pdm/main/install-pdm.py
```
For security reasons, you should verify the checksum of `install-pdm.py`.
The sha256 checksum is: `5efebd44f477521d0d8ef0e118b7e5765ff20f80d3d4dd9394f1b8ff1094fb4d`
The sha256 checksum is: `f09accb8a530315be312cf9ce7af987ccb608aa90d3972968d73e7ef7d8c547b`
The installer will install PDM into the user site and the location depends on the system:
......
......@@ -87,7 +87,7 @@ curl -sSL https://raw.githubusercontent.com/pdm-project/pdm/main/install-pdm.py
```
为安全起见,你应该检查 `install-pdm.py` 文件的正确性。
SHA256 校验和: `5efebd44f477521d0d8ef0e118b7e5765ff20f80d3d4dd9394f1b8ff1094fb4d`
SHA256 校验和: `f09accb8a530315be312cf9ce7af987ccb608aa90d3972968d73e7ef7d8c547b`
默认情况下,此脚本会将 PDM 安装在 Python 的用户目录下,具体位置取决于当前系统:
......
......@@ -50,7 +50,7 @@ Like Pip, PDM provides an installation script that will install PDM into an isol
```
For security reasons, you should verify the checksum of `install-pdm.py`.
The sha256 checksum is: `5efebd44f477521d0d8ef0e118b7e5765ff20f80d3d4dd9394f1b8ff1094fb4d`
The sha256 checksum is: `f09accb8a530315be312cf9ce7af987ccb608aa90d3972968d73e7ef7d8c547b`
The installer will install PDM into the user site and the location depends on the system:
......
......@@ -6,6 +6,7 @@ import io
import json
import os
import platform
import re
import shutil
import site
import subprocess
......@@ -207,14 +208,23 @@ class Installer:
resp = urllib.request.urlopen(JSON_URL)
metadata = json.load(resp)
def is_stable(v: str) -> bool:
return all(p.isdigit() for p in v.split("."))
def version_okay(v: str) -> bool:
return self.prerelease or all(p.isdigit() for p in v.split("."))
def sort_version(v: str) -> tuple:
return tuple(int(p) for p in v.split("."))
parts = []
for part in v.split("."):
if part.isdigit():
parts.append(int(part))
else:
digit, rest = re.match(r"^(\d*)(.*)", part).groups()
if digit:
parts.append(int(digit))
parts.append(rest)
return tuple(parts)
releases = sorted(
filter(is_stable, metadata["releases"]), key=sort_version, reverse=True
filter(version_okay, metadata["releases"]), key=sort_version, reverse=True
)
return releases[0]
......@@ -300,8 +310,6 @@ class Installer:
else:
req = "pdm"
args = [req] + [d for d in self.additional_deps if d]
if self.prerelease:
args.insert(0, "--pre")
pip_cmd = [str(venv_python), "-m", "pip", "install"] + args
_call_subprocess(pip_cmd)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册