Skip to content

Commit

Permalink
feat: install python using pbs-installer (#2721)
Browse files Browse the repository at this point in the history
  • Loading branch information
frostming authored Mar 27, 2024
1 parent 228f881 commit ca0a27a
Show file tree
Hide file tree
Showing 21 changed files with 585 additions and 47 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ you can probably find some goodness in `pdm`.
- [PEP 621] project metadata.
- Flexible and powerful plug-in system.
- Versatile user scripts.
- Install Pythons using [indygreg's python-build-standalone](https://github.com/indygreg/python-build-standalone).
- Opt-in centralized installation cache like [pnpm](https://pnpm.io/motivation#saving-disk-space-and-boosting-installation-speed).

[pep 517]: https://www.python.org/dev/peps/pep-0517
Expand Down
1 change: 1 addition & 0 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ PDM 旨在成为下一代 Python 软件包管理工具。它最初是为个人
- 灵活且强大的插件系统
- [PEP 621] 元数据格式
- 功能强大的用户脚本
- 支持从 [indygreg's python-build-standalone](https://github.com/indygreg/python-build-standalone) 安装 Python。
-[pnpm] 一样的中心化安装缓存,节省磁盘空间

[pep 517]: https://www.python.org/dev/peps/pep-0517
Expand Down
1 change: 1 addition & 0 deletions docs/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ PDM, as described, is a modern Python package and dependency manager supporting
- [PEP 621] project metadata.
- Flexible and powerful plug-in system.
- Versatile user scripts.
- Install Pythons using [indygreg's python-build-standalone](https://github.com/indygreg/python-build-standalone).
- Opt-in centralized installation cache like [pnpm](https://pnpm.io/motivation#saving-disk-space-and-boosting-installation-speed).

[pep 517]: https://www.python.org/dev/peps/pep-0517
Expand Down
38 changes: 38 additions & 0 deletions docs/docs/usage/project.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,44 @@ will be stored in `.pdm-python` and used by subsequent commands. You can also ch

Alternatively, you can specify the Python interpreter path via `PDM_PYTHON` environment variable. When it is set, the path saved in `.pdm-python` will be ignored.

## Install Python interpreters with PDM

+++ 2.13.0

PDM supports installing additional Python interpreters from [@indygreg's python-build-standalone](https://github.com/indygreg/python-build-standalone)
with the `pdm python install` command. For example, to install CPython 3.9.8:

```bash
pdm python install 3.9.8
```

You can view all available Python versions with `pdm python install --list`.

This will install the Python interpreter into the location specified by `python.install_root` configuration.

List the currently installed Python interpreters:

```bash
pdm python list
```

Remove an installed Python interpreter:

```bash
pdm python remove 3.9.8
```

!!! TIP "Share installations with Rye"

PDM installs Python interpreters using the same source as [Rye](https://rye-up.com). If you are using Rye at the same time, you can point the `python.install_root` to the same directory as Rye to share the Python interpreters:

```bash
pdm config python.install_root ~/.rye/py
```

Afterwards you can manage the installations using either `rye toolchain` or `pdm python`.


## Virtualenv or not

After you select the Python interpreter, PDM will ask you whether you want to create a virtual environment for the project.
Expand Down
1 change: 1 addition & 0 deletions news/2721.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Support installing Pythons from [python-build-standalone](https://github.com/indygreg/python-build-standalone). Add command group `pdm python` to manage Python installations. And `pdm use` can automatically install the Python interpreter if it's not found.
103 changes: 94 additions & 9 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@ requires-python = ">=3.8"
license = {text = "MIT"}
dependencies = [
"blinker",
"certifi",
"packaging>=20.9,!=22.0",
"platformdirs",
"rich>=12.3.0",
"virtualenv>=20",
"pyproject-hooks",
"unearth>=0.15.0",
"dep-logic>=0.2.0,<1.0",
"findpython>=0.4.0,<1.0.0a0",
"findpython>=0.6.0,<1.0.0a0",
"tomlkit>=0.11.1,<1",
"shellingham>=1.3.2",
"python-dotenv>=0.15",
Expand All @@ -35,6 +34,7 @@ dependencies = [
"importlib-metadata>=3.6; python_version < \"3.10\"",
"hishel>=0.0.24,<0.1.0",
"msgpack>=1.0",
"pbs-installer[install]",
]
readme = "README.md"
keywords = ["packaging", "dependency", "workflow"]
Expand Down
Loading

0 comments on commit ca0a27a

Please sign in to comment.