未验证 提交 49f7f6d2 编写于 作者: F Frost Ming

Remove shell indicators in example commands

上级 08dce2d5
......@@ -17,14 +17,14 @@ this section.
1. First, fork this project to your own namespace using the fork button at the top right of the repository page.
2. Clone the **upstream** repository to local:
```bash
$ git clone https://github.com/pdm-project/pdm.git
git clone https://github.com/pdm-project/pdm.git
# Or if you prefer SSH clone:
$ git clone git@github.com:pdm-project/pdm.git
git clone git@github.com:pdm-project/pdm.git
```
3. Add the fork as a new remote:
```bash
$ git remote add fork https://github.com/yourname/pdm.git
$ git fetch fork
git remote add fork https://github.com/yourname/pdm.git
git fetch fork
```
where `fork` is the remote name of the fork repository.
......@@ -35,9 +35,9 @@ this section.
To update main branch to date:
```bash
$ git pull origin main
git pull origin main
# In rare cases that your local main branch diverges from the remote main:
$ git fetch origin && git reset --hard main
git fetch origin && git reset --hard main
```
2. Create a new branch based on the up-to-date main branch for new patches.
......@@ -48,16 +48,17 @@ this section.
To make sure the test suites can run correctly, you need to install [Git LFS](https://git-lfs.github.com/), then
```bash
$ git lfs install
git lfs install
# If you have already cloned the repository, execute the below command as well.
$ git lfs pull
git lfs pull
```
Then, you need to install base dependencies in a venv. Make sure your `pip` is newer than `21.3` to install PDM in
develop/editable mode.
```bash
$ pip install -e .
python -m pip install -U "pip>=21.3"
python -m pip install -e .
```
You are free to create a virtualenv with either `venv` module or `virtualenv` tool for the development. If you are doing
......@@ -69,7 +70,7 @@ after this point.
### Run tests
```bash
$ pdm run test
pdm run test
```
The test suite is still simple and needs expansion! Please help write more test cases.
......@@ -79,8 +80,8 @@ The test suite is still simple and needs expansion! Please help write more test
PDM uses `pre-commit` for linting. Install `pre-commit` first, then:
```bash
$ pre-commit install
$ pdm run lint
pre-commit install
pdm run lint
```
PDM uses `black` for code style and `isort` for sorting import statements. If you are not following them,
......@@ -109,5 +110,5 @@ mood that describes your changes. (e.g., `Deduplicate the plugins list.` ) See e
If you make some changes to the `docs/` and you want to preview the build result, simply do:
```bash
$ pdm run doc
pdm run doc
```
......@@ -115,26 +115,26 @@ You can either pass the options after the script or set the env var value.
If you are on MacOS and using `homebrew`, install it by:
```bash
$ brew install pdm
brew install pdm
```
If you are on Windows and using [Scoop](https://scoop.sh/), install it by:
```
PS> scoop bucket add frostming https://github.com/frostming/scoop-frostming.git
PS> scoop install pdm
scoop bucket add frostming https://github.com/frostming/scoop-frostming.git
scoop install pdm
```
Otherwise, it is recommended to install `pdm` in an isolated environment with `pipx`:
```bash
$ pipx install pdm
pipx install pdm
```
Or you can install it under a user site:
```bash
$ pip install --user pdm
pip install --user pdm
```
## Quickstart
......@@ -142,7 +142,7 @@ $ pip install --user pdm
**Initialize a new PDM project**
```bash
$ pdm init
pdm init
```
Answer the questions following the guide, and a PDM project with a `pyproject.toml` file will be ready to use.
......@@ -150,7 +150,7 @@ Answer the questions following the guide, and a PDM project with a `pyproject.to
**Install dependencies into the `__pypackages__` directory**
```bash
$ pdm add requests flask
pdm add requests flask
```
You can add multiple dependencies in the same command. After a while, check the `pdm.lock` file to see what is locked for each package.
......@@ -189,7 +189,7 @@ If you are curious about how this works, check [this doc section](https://pdm.fm
## Docker image
```console
$ docker pull frostming/pdm
docker pull frostming/pdm
```
## Badges
......
......@@ -111,26 +111,26 @@ optional arguments:
如果你使用的是 MacOS 并且安装了 `homebrew`
```bash
$ brew install pdm
brew install pdm
```
如果你在 Windows 上使用 [Scoop](https://scoop.sh/), 运行以下命令安装:
```
PS> scoop bucket add frostming https://github.com/frostming/scoop-frostming.git
PS> scoop install pdm
scoop bucket add frostming https://github.com/frostming/scoop-frostming.git
scoop install pdm
```
否则,强烈推荐把 `pdm` 安装在一个隔离环境中, 用 `pipx` 是坠吼的。
```bash
$ pipx install pdm
pipx install pdm
```
或者你可以将它安装在用户目录下:
```bash
$ pip install --user pdm
pip install --user pdm
```
## 快速上手
......@@ -138,7 +138,7 @@ $ pip install --user pdm
**初始化一个新的 PDM 项目**
```bash
$ pdm init
pdm init
```
按照指引回答提示的问题,一个 PDM 项目和对应的`pyproject.toml`文件就创建好了。
......@@ -146,7 +146,7 @@ $ pdm init
**把依赖安装到 `__pypackages__` 文件夹中**
```bash
$ pdm add requests flask
pdm add requests flask
```
你可以在同一条命令中添加多个依赖。稍等片刻完成之后,你可以查看`pdm.lock`文件看看有哪些依赖以及对应版本。
......
......@@ -35,13 +35,13 @@ Like Pip, PDM provides an installation script that will install PDM into an isol
=== "Linux/Mac"
```bash
$ curl -sSL https://raw.githubusercontent.com/pdm-project/pdm/main/install-pdm.py | python -
curl -sSL https://raw.githubusercontent.com/pdm-project/pdm/main/install-pdm.py | python -
```
=== "Windows"
```powershell
PS> (Invoke-WebRequest -Uri https://raw.githubusercontent.com/pdm-project/pdm/main/install-pdm.py -UseBasicParsing).Content | python -
(Invoke-WebRequest -Uri https://raw.githubusercontent.com/pdm-project/pdm/main/install-pdm.py -UseBasicParsing).Content | python -
```
The installer will install PDM into the user site and the location depends on the system:
......@@ -72,27 +72,27 @@ You can either pass the options after the script or set the env var value.
=== "Homebrew"
```bash
$ brew install pdm
brew install pdm
```
=== "Scoop"
```
PS> scoop bucket add frostming https://github.com/frostming/scoop-frostming.git
PS> scoop install pdm
scoop bucket add frostming https://github.com/frostming/scoop-frostming.git
scoop install pdm
```
=== "pipx"
```bash
$ pipx install pdm
pipx install pdm
```
Install the head version of GitHub repository.
Make sure you have installed [Git LFS](https://git-lfs.github.com/) on your system.
```bash
$ pipx install git+https://github.com/pdm-project/pdm.git@main#egg=pdm
pipx install git+https://github.com/pdm-project/pdm.git@main#egg=pdm
```
See also: <https://pypa.github.io/pipx/>
......@@ -100,7 +100,7 @@ You can either pass the options after the script or set the env var value.
=== "pip"
```console
$ pip install --user pdm
pip install --user pdm
```
### Enable PEP 582 globally
......@@ -122,7 +122,7 @@ You may want to write a line in your `.bash_profile`(or similar profiles) to mak
For example, in bash you can do this:
```bash
$ pdm --pep582 >> ~/.bash_profile
pdm --pep582 >> ~/.bash_profile
```
Once again, Don't forget to restart the terminal session to take effect.
......@@ -147,21 +147,21 @@ PDM supports generating completion scripts for Bash, Zsh, Fish or Powershell. He
=== "Bash"
```bash
$ pdm completion bash > /etc/bash_completion.d/pdm.bash-completion
pdm completion bash > /etc/bash_completion.d/pdm.bash-completion
```
=== "Zsh"
```bash
# Make sure ~/.zfunc is added to fpath, before compinit.
$ pdm completion zsh > ~/.zfunc/_pdm
pdm completion zsh > ~/.zfunc/_pdm
```
Oh-My-Zsh:
```bash
$ mkdir $ZSH_CUSTOM/plugins/pdm
$ pdm completion zsh > $ZSH_CUSTOM/plugins/pdm/_pdm
mkdir $ZSH_CUSTOM/plugins/pdm
pdm completion zsh > $ZSH_CUSTOM/plugins/pdm/_pdm
```
Then make sure pdm plugin is enabled in ~/.zshrc
......@@ -169,22 +169,22 @@ PDM supports generating completion scripts for Bash, Zsh, Fish or Powershell. He
=== "Fish"
```bash
$ pdm completion fish > ~/.config/fish/completions/pdm.fish
pdm completion fish > ~/.config/fish/completions/pdm.fish
```
=== "Powershell"
```ps1
# Create a directory to store completion scripts
PS > mkdir $PROFILE\..\Completions
PS > echo @'
mkdir $PROFILE\..\Completions
echo @'
Get-ChildItem "$PROFILE\..\Completions\" | ForEach-Object {
. $_.FullName
}
'@ | Out-File -Append -Encoding utf8 $PROFILE
# Generate script
PS > Set-ExecutionPolicy Unrestricted -Scope CurrentUser
PS > pdm completion powershell | Out-File -Encoding utf8 $PROFILE\..\Completions\pdm_completion.ps1
Set-ExecutionPolicy Unrestricted -Scope CurrentUser
pdm completion powershell | Out-File -Encoding utf8 $PROFILE\..\Completions\pdm_completion.ps1
```
## Unicode and ANSI supports
......
......@@ -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`:
```bash
$ pipx inject pdm pdm-hello
pipx inject pdm pdm-hello
```
Or if you installed `pdm` via `homebrew`:
```bash
$ $(brew --prefix pdm)/libexec/bin/python -m pip install pdm-hello
$(brew --prefix pdm)/libexec/bin/python -m pip install pdm-hello
```
Otherwise, if you installed `pdm` with normal `pip install`:
```bash
$ pip install --user pdm-hello
pip install --user pdm-hello
```
The main principle is you must install the plugin in the same site-package directory as `pdm`.
......
......@@ -107,7 +107,7 @@ tests = [
To install a group of optional dependencies:
```bash
$ pdm install -G socks
pdm install -G socks
```
`-G` option can be given multiple times to include more than one group.
......
......@@ -20,7 +20,7 @@ doc = ["mkdocs"]
To install all of them:
```bash
$ pdm install
pdm install
```
For more CLI usage, please refer to [Manage Dependencies](/usage/dependency/)
......
......@@ -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 -dG test 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 -dG test 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 remove -dG test pytest-cov
pdm remove -dG test pytest-cov
```
## Install the packages pinned in lock file
......@@ -175,16 +174,16 @@ dev1 = ["pytest"]
dev2 = ["mkdocs"]
```
| Command | What it does | Comments |
| ------------------------------- | ------------------------------------------------------------------------ | ------------------------- |
| `pdm install` | install prod and dev deps (no optional) | |
| `pdm install -G extra1` | install prod deps, dev deps, and "extra1" optional group | |
| `pdm install -G dev1` | install prod deps and only "dev1" dev group | |
| `pdm install -G:all` | install prod deps, dev deps and "extra1", "extra2" optional groups | |
| Command | What it does | Comments |
| ------------------------------- | -------------------------------------------------------------------- | ------------------------- |
| `pdm install` | install prod and dev deps (no optional) | |
| `pdm install -G extra1` | install prod deps, dev deps, and "extra1" optional group | |
| `pdm install -G dev1` | install prod deps and only "dev1" dev group | |
| `pdm install -G:all` | install prod deps, dev deps and "extra1", "extra2" optional groups | |
| `pdm install -G extra1 -G dev1` | install prod deps, "extra1" optional group and only "dev1" dev group | |
| `pdm install --prod` | install prod only | |
| `pdm install --prod -G extra1` | install prod deps and "extra1" optional | |
| `pdm install --prod -G dev1` | Fail, `--prod` can't be given with dev dependencies | Leave the `--prod` option |
| `pdm install --prod` | install prod only | |
| `pdm install --prod -G extra1` | install prod deps and "extra1" optional | |
| `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.
......
......@@ -71,25 +71,25 @@ show configurations.
Show the current configurations:
```console
$ pdm config
pdm config
```
Get one single configuration:
```console
$ pdm config pypi.url
pdm config pypi.url
```
Change a configuration value and store in home configuration:
```console
$ pdm config pypi.url "https://test.pypi.org/simple"
pdm config pypi.url "https://test.pypi.org/simple"
```
By default, the configuration are changed globally, if you want to make the config seen by this project only, add a `--local` flag:
```console
$ pdm config --local pypi.url "https://test.pypi.org/simple"
pdm config --local pypi.url "https://test.pypi.org/simple"
```
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`.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册