github, A modern Python package manager with PEP 582 support.
- 仅在
__pypackages__/<major.minor>
包含必要的依赖和bin文件,没有解释器相关文件 - 就算python解释器被删除了,但是只要有其他符合
pyproject.yoml
规定版本的解释器即可,项目目录下的__pypackages__
不包含解释器相关的内容,venv则必须重新关联或者重新创建
$ tree -L 3 __pypackages__
__pypackages__
└── 3.10
├── bin
│ ├── django-admin
│ └── sqlformat
├── include
└── lib
├── Django-4.0.1.dist-info
├── anyio
├── anyio-3.5.0.dist-info
├── asgiref
├── asgiref-3.4.1.dist-info
├── django
...
install
brew install pdm
demo
mkdir pdm-demo
cd pdm-demo
pdm init
Creating a pyproject.toml for PDM...
Please enter the Python interpreter to use
...
12. /usr/local/Cellar/pdm/1.12.2/libexec/bin/python3.10 (3.10)
Please select: [0]: 12
Using Python interpreter: /usr/local/Cellar/pdm/1.12.2/libexec/bin/python3.10 (3.10)
Is the project a library that will be uploaded to PyPI? [y/N]: N
License(SPDX name) [MIT]:
Author name [26huitailang]:
Author email [26huitailang@gmail.com]:
Python requires('*' to allow any) [>=3.10]:
Changes are written to pyproject.toml.
PDM 1.12.2 is installed, while 1.12.6 is available.
Please run $ brew upgrade pdm to upgrade.
Run $ pdm config check_update false to disable the check.
init files
~/git-checkout/pdm-demo ⌚ 10:38:57
$ la
total 16
-rw-r--r-- 1 26huitailang staff 70B Jan 12 10:37 .pdm.toml
-rw-r--r-- 1 26huitailang staff 321B Jan 12 10:38 pyproject.toml
- .pdm.toml
- python 路径信息
- pyproject.toml
- project info
- tool info
- build-system
添加包,会更新pyproject.toml
下面的dependencies
$ pdm add django
Adding packages to default dependencies: django
✔ 🔒 Lock successful
Changes are written to pdm.lock.
Changes are written to pyproject.toml.
Synchronizing working set with lock file: 3 to add, 0 to update, 0 to remove
✔ Install asgiref 3.4.1 successful
✔ Install django 4.0.1 successful
✔ Install sqlparse 0.4.2 successful
🎉 All complete!
PDM 1.12.2 is installed, while 1.12.6 is available.
Please run $ brew upgrade pdm to upgrade.
Run $ pdm config check_update false to disable the check.
使用pdm定义的环境运行
pdm run django-admin -h
配置修改,修改pypi源
pdm config pypi.url https://pypi.tuna.tsinghua.edu.cn/simple
use with ide
https://pdm.fming.dev/#use-with-ide
- pycharm 支持不完善,比如Django,添加了PATH后
run/debug configuration
不能正确识别,需要点击continue anyway
才能运行django server,但是最新版本默认支持poetry和pipenv,等待后续支持pep582/pdm