最近学习了点pdm的皮毛知识。
pdm learn
# install pdm
pip install pdm
init pdm
# in a new project directory
mkdir pdm-test && cd pdm-test
pdm init
# answer serveral questions asked by PDM and a pyproject.toml will be created for you in the project.
pdm add requests
# install package requests for example
use pdm in vscode
VSCode设置PDM
将以下两项添加到 .vscode/settings.json 的顶层字典中:
{
“python.autoComplete.extraPaths”: [“pypackages/<major.minor>/lib”],
“python.analysis.extraPaths”: [“pypackages/<major.minor>/lib”]
}
注:上面的 <major.minor> 是 python 的版本号,如 pypackages/3.8/lib 。
export pdm env
# 导出环境到requirements.txt
pdm export -o requirements.txt
modify pdm config
# list the config of pdm
pdm config
# modify key to value
pdm config pypi.url http://mirrors.aliyun.com/pypi/simple/
# search for config
pdm config pypi.url
run python in pdm env
pdm run python main.py
import other env solutions such as pipenv, poetry into pdm
pdm import -f {file}
# 执行 pdm init or pdm install 时,会自动识别你当前的依赖情况并转换。
export pdm
# pdm have two core files, one is pyproject.toml and another is pdm.lock