新建项目
创建一个项目目录,在目录内执行pdm init
mkdir my_project && cd my_project
pdm init
执行中,pdm会咨询若干问题,让你选择
- 请选择要使用的Python解释器
- 你想创建一个虚拟env吗?
- 该项目是可安装的库吗?如果是,我们将需要再问几个问题,以包括项目名称和构建后端
- License类型
- 作者名
- 作者邮箱
- Python版本要求
执行完成后,PDM会将这些配置信息写到项目根目录的pyproject.toml
中。
加入已有项目
在一个已有的Python项目根目录内执行pdm init
cd existing_project
pdm init
执行中,pdm如果发现目录中存在requirements.txt
,会询问是否将引入这些依赖库;如果选择引入,那么这些依赖会被写入pyproject.toml
中。
Project is initialized successfully
Found following files from other formats that you may import:
0. /Users/xx/code/tbase_upgrade_oss_manual/requirements.txt (requirements)
1. don't do anything, I will import later.
Please select: 0
Changes are written to pyproject.toml.
[project]
name = ""
version = ""
description = ""
authors = [
{name = "xx", email = "xx@xx.cn"},
]
dependencies = [
"pikepdf==7.2.0",
]
requires-python = ">=3.11"
readme = "README.md"
license = {text = "MIT"}