@@ -53,27 +53,73 @@ To start with, create a new `pdm` project,
5353$ pdm init
5454```
5555
56- You will need to answer a few questions to help ` pdm ` to initialize a project with ` pyproject.toml ` file.
56+ You will need to answer a few questions to help ` pdm ` to initialize a project with ` pyproject.toml ` file. For example,
57+
58+ ```
59+ [project]
60+ name = "pdm-example"
61+ version = "0.1.0"
62+ description = "Default template for PDM package"
63+ authors = [
64+ {name = "jgujerry", email = "j*@gmail.com"},
65+ ]
66+ dependencies = [
67+ "requests>=2.31.0",
68+ ]
69+ requires-python = "==3.12.*"
70+ readme = "README.md"
71+ license = {text = "MIT"}
72+
73+
74+ [tool.pdm]
75+ package-type = "application"
76+
77+ ```
5778
5879#### 1. Create a virtual environment
5980
6081``` bash
6182$ pdm venv create --name < envname>
6283```
6384
85+ You can create multiple virtual environments for one project.
86+
87+ Where the virtual environments got created?
88+ * If no ` --name ` was specified, ` pdm ` will create the ` .venv ` under the project directory.
89+ * Otherwise, if the ` venv.location ` configuration was defined, the virtualenvs would go there.
90+ * If no ` venv.location ` configuration defined, they would be created under the shared directory of your system.
91+
92+ On my Ubuntu system, they are created under this location:
93+ ``` bash
94+ $ ~ /.local/share/pdm/venvs/
95+ ```
96+
6497#### 2. Activate the virtual environment
6598
99+ Go the project directory, run the following command to list all available virtual environments with the project,
100+ ``` bash
101+ $ pdm venv list
102+ ```
103+
104+ Now you can choose the virtual environment name and activate it using this command:
66105``` bash
67106$ eval $( pdm venv activate < envname> )
68107```
69108
109+ Please note that ` pdm venv activate ` only print the activation command, use ` eval ` to run it.
110+
70111#### 3. Manage Python packages
71112
72113Add Python packages to project,
73114``` bash
74115$ pdm add < package1> < package2> ...
75116```
76117
118+ To add all dependencies listed in ` pyproject.toml ` , run this:
119+ ``` bash
120+ $ pdm install
121+ ```
122+
77123Remove Python packages from project,
78124``` bash
79125$ pdm remove < package1>
@@ -87,13 +133,24 @@ $ pdm update <package1> <package2>
87133
88134#### 4. Deactivate the virtual environment
89135
136+ Run this command to deactivate the virtual environment,
137+
138+ ``` bash
139+ $ deactivate
140+ ```
90141
91142#### 5. Remove the virtual environment
92143
144+ To remove given virtual environment, using this command:
93145``` bash
94146$ pdm venv remove < envname>
95147```
96148
149+ To purge all created virtual environments, run this command:
150+ ``` bash
151+ $ pdm venv purge
152+ ```
153+
97154## Different Python versions?
98155
99156#### 1. Choose the Python version when initializing the project
@@ -116,10 +173,21 @@ Virtualenv is created successfully at ~/Workspace/python-virtual-environments/pd
116173Project name (pdm): pdm-example
117174...
118175` ` `
176+ where you can select your Python version for project initialization.
119177
120178# ### 2. Specify `python` position argument in `pdm venv create` command
121179
180+ For example,
122181` ` ` bash
123182$ pdm venv create --name testenv python3.11
124183Virtualenv ~ /.local/share/pdm/venvs/pdm-HaUr6rC4-testenv is created successfully
125184` ` `
185+
186+ ` ` ` bash
187+ $ pdm venv create --name testenv2 python3.12
188+ Virtualenv ~ /.local/share/pdm/venvs/pdm-HaUr6rC4-testenv2 is created successfully
189+ ` ` `
190+
191+ For more information about ` pdm` , please see the [official documentation](https://pdm-project.org/latest/).
192+
193+ Happy coding!
0 commit comments