@@ -138,7 +138,7 @@ Fortunately, it becomes even easier with PDM and PEP 582. First, you should enab
[corresponding part of this doc](index.md#enable-pep-582-globally). Then you just need to install all dependencies into the `__pypackages__` directory by:
```bash
$ pdm install
pdm install
```
After that, all the dependencies are available with a compatible Python interpreter, including the plugin itself, in editable mode. That means any change
...
...
@@ -179,19 +179,19 @@ As plugins are loaded via entry points, they can be activated with no more steps
Assume your plugin is published as `pdm-hello`, and if you installed `pdm` via `pipx`:
@@ -37,13 +37,13 @@ config should be set as the above example to make PDM work properly.
To get rid of these constraints, there is a Tox plugin [tox-pdm](https://github.com/pdm-project/tox-pdm) which can ease the usage. You can install it by
```console
$pip install tox-pdm
pip install tox-pdm
```
Or,
```console
$pdm add --dev tox-pdm
pdm add --dev tox-pdm
```
And you can make the `tox.ini` much tidier as following, :
@@ -6,8 +6,8 @@ The following examples are run on Ubuntu 18.04, a few changes must be done if yo
## Initialize a project
```console
$mkdir pdm-test &&cd pdm-test
$pdm init
mkdir pdm-test && cd pdm-test
pdm init
```
Answer several questions asked by PDM and a `pyproject.toml` will be created for you in the project root:
...
...
@@ -34,7 +34,7 @@ For details of the meaning of each field in `pyproject.toml`, please refer to [P
## Add dependencies
```console
$pdm add requests
pdm add requests
```
`pdm add` can be followed by one or several dependencies, and the dependency specification is described in
...
...
@@ -45,13 +45,12 @@ PDM also allows extra dependency groups by providing `-G/--group <name>` option,
After that, dependencies and sub-dependencies will be resolved properly and installed for you, you can view `pdm.lock` to see the resolved result of all dependencies.
### Add local dependencies
Local packages can be added with their paths:
```console
$pdm add ./sub-package
pdm add ./sub-package
```
Local packages can be installed in [editable mode](https://pip.pypa.io/en/stable/cli/pip_install/#editable-installs)
...
...
@@ -66,7 +65,7 @@ e.g. some for testing and others for linting. We usually don't want these depend
so using `optional-dependencies` is probably not a good idea. We can define them as development dependencies:
```console
$pdm add -dGtest pytest
pdm add -dG test pytest
```
This will result in a pyproject.toml as following:
...
...
@@ -96,25 +95,25 @@ for the dependency):
To update all dependencies in the lock file:
```console
$pdm update
pdm update
```
To update the specified package(s):
```console
$pdm update requests
pdm update requests
```
To update multiple groups of dependencies:
```console
$pdm update -G security -G http
pdm update -G security -G http
```
To update a given package in the specified group:
```console
$pdm update -G security cryptography
pdm update -G security cryptography
```
If the group is not given, PDM will search for the requirement in the default dependencies set and raises an error if none is found.
...
...
@@ -123,9 +122,9 @@ To update packages in development dependencies:
```console
#Update all default + dev-dependencies
$pdm update -d
pdm update -d
#Update a package in the specified group of dev-dependencies
$pdm update -dGtest pytest
pdm update -dG test pytest
```
### About update strategy
...
...
@@ -143,11 +142,11 @@ To remove existing dependencies from project file and the library directory:
```console
#Remove requests from the default dependencies
$pdm remove requests
pdm remove requests
#Remove h11 from the 'web' group of optional-dependencies
$pdm remove -G web h11
pdm remove -G web h11
#Remove pytest-cov from the `test` group of dev-dependencies
| `pdm install --prod -G dev1` | Fail, `--prod` can't be given with dev dependencies | Leave the `--prod` option |
**All** development dependencies are included as long as `--prod` is not passed and `-G` doesn't specify any dev groups.
...
...
@@ -195,7 +194,7 @@ Besides, if you don't want the root project to be installed, add `--no-self` opt
Similar to `pip list`, you can list all packages installed in the packages directory:
```console
$pdm list
pdm list
```
Or show a dependency graph by:
...
...
@@ -220,7 +219,7 @@ bump2version 1.0.0
You can specify a PyPI mirror URL by following commands:
```console
$pdm config pypi.url https://test.pypi.org/simple
pdm config pypi.url https://test.pypi.org/simple
```
By default, PDM will read the pip's configuration files to decide the PyPI URL, and fallback
...
...
@@ -247,13 +246,12 @@ For convenience, PDM supports environment variables expansion in the dependency
Don't worry about credential leakage, the environment variables will be expanded when needed and kept untouched in the lock file.
## Save disk space by enabling the install cache
When using virtualenv to isolate project dependencies, if you have 100 projects depending on the same package, you will end up with 100 copies of that dependency. With PDM, you can opt in the installation caching so that the dependency will be installed into a centrialized store and be used by multiple projects. To enable it, simply do:
```
$ pdm config feature.install_cache on
pdm config feature.install_cache on
```
Add `--local` option to enable for the current project only.
Any local configurations will be stored in `.pdm.toml` under the project root directory.
...
...
@@ -110,7 +110,7 @@ If a package is required by many projects on the system, each project has to kee
PDM supports _caching_ the installations of the same wheel by installing it into a centralized package repository and linking to that installation in different projects. To enabled it, run:
```bash
$ pdm config feature.install_cache on
pdm config feature.install_cache on
```
It can be enabled on a project basis, by adding `--local` option to the command.
...
...
@@ -171,8 +171,8 @@ You can also export `pdm.lock` to other formats, to ease the CI flow or image bu
only `requirements.txt` and `setup.py` format is supported:
```console
$pdm export-o requirements.txt
$pdm export-f setuppy -o setup.py
pdm export -o requirements.txt
pdm export -f setuppy -o setup.py
```
## Hide the credentials from pyproject.toml
...
...
@@ -209,7 +209,7 @@ PDM provides several methods to achieve this:
With PDM, you can run arbitrary scripts or commands with local packages loaded:
```bash
$ pdm run flask run -p 54321
pdm run flask run -p 54321
```
PDM also supports custom script shortcuts in the optional `[tool.pdm.scripts]` section of `pyproject.toml`.