From d14b131084a47ea3f441bbd05e5237d9a8641968 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Eustace?= Date: Sat, 5 Jun 2021 22:02:10 +0200 Subject: [PATCH] Reorganize documentation --- .github/workflows/docs.yml | 29 --- docs/{docs/index.md => _index.md} | 96 +++---- docs/{docs => }/basic-usage.md | 73 +++--- docs/{docs => }/cli.md | 38 +-- docs/{docs => }/configuration.md | 53 ++-- docs/contributing.md | 265 ++++++++++++++++++++ docs/{docs => }/dependency-specification.md | 27 +- docs/docs/contributing.md | 1 - docs/{docs => }/faq.md | 31 ++- docs/{docs => }/libraries.md | 27 +- docs/{docs => }/managing-environments.md | 33 ++- docs/mkdocs.yml | 30 --- docs/{docs => }/pyproject.md | 92 +++---- docs/{docs => }/repositories.md | 69 ++--- docs/theme/main.html | 29 --- docs/theme/nav.html | 18 -- docs/theme/toc.html | 10 - tox.ini | 14 +- 18 files changed, 594 insertions(+), 341 deletions(-) delete mode 100644 .github/workflows/docs.yml rename docs/{docs/index.md => _index.md} (73%) rename docs/{docs => }/basic-usage.md (78%) rename docs/{docs => }/cli.md (93%) rename docs/{docs => }/configuration.md (81%) create mode 100644 docs/contributing.md rename docs/{docs => }/dependency-specification.md (92%) delete mode 100644 docs/docs/contributing.md rename docs/{docs => }/faq.md (78%) rename docs/{docs => }/libraries.md (78%) rename docs/{docs => }/managing-environments.md (86%) delete mode 100644 docs/mkdocs.yml rename docs/{docs => }/pyproject.md (80%) rename docs/{docs => }/repositories.md (76%) delete mode 100644 docs/theme/main.html delete mode 100644 docs/theme/nav.html delete mode 100644 docs/theme/toc.html diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml deleted file mode 100644 index b14884c8fa0..00000000000 --- a/.github/workflows/docs.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Documentation - -on: - push: - paths: - - 'docs/**' - - '.github/workflows/docs.yml' - branches: - - master - pull_request: - paths: - - 'docs/**' - - '.github/workflows/docs.yml' - branches: - - '**' - -jobs: - docs: - name: Documentation Build - runs-on: Ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - with: - python-version: 3.8 - - name: Install tox - run: pip install tox - - name: Build documentation - run: tox -e doc diff --git a/docs/docs/index.md b/docs/_index.md similarity index 73% rename from docs/docs/index.md rename to docs/_index.md index 64bb512f6cb..4fc276a2815 100644 --- a/docs/docs/index.md +++ b/docs/_index.md @@ -1,6 +1,17 @@ +--- +title: "Introduction" +draft: false +type: docs +layout: "single" + +menu: + docs: + weight: 0 +--- + # Introduction -Poetry is a tool for dependency management and packaging in Python. +Poetry is a tool for **dependency management** and **packaging** in Python. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you. @@ -9,10 +20,10 @@ It allows you to declare the libraries your project depends on and it will manag Poetry requires Python 2.7 or 3.5+. It is multi-platform and the goal is to make it work equally well on Windows, Linux and OSX. -!!! note - - Python 2.7 and 3.5 will no longer be supported in the next feature release (1.2). - You should consider updating your Python version to a supported one. +{{% note %}} +Python 2.7 and 3.5 will no longer be supported in the next feature release (1.2). +You should consider updating your Python version to a supported one. +{{% /note %}} ## Installation @@ -30,10 +41,10 @@ curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poet (Invoke-WebRequest -Uri https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py -UseBasicParsing).Content | python - ``` -!!! note - - You only need to install Poetry once. It will automatically pick up the current - Python version and use it to [create virtualenvs](/docs/managing-environments) accordingly. +{{% note %}} +You only need to install Poetry once. It will automatically pick up the current +Python version and use it to [create virtualenvs]({{< relref "managing-environments" >}}) accordingly. +{{% /note %}} The installer installs the `poetry` tool to Poetry's `bin` directory. On Unix it is located at `$HOME/.poetry/bin` and on Windows at `%USERPROFILE%\.poetry\bin`. @@ -81,29 +92,29 @@ python get-poetry.py --version 0.12.0 POETRY_VERSION=0.12.0 python get-poetry.py ``` -!!!note +{{% note %}} +Note that the installer does not support Poetry releases < 0.12.0. +{{% /note %}} - Note that the installer does not support Poetry releases < 0.12.0. +{{% note %}} +The setup script must be able to find one of following executables in your shell's path environment: -!!!note - - The setup script must be able to find one of following executables in your shell's path environment: - - - `python` (which can be a py3 or py2 interpreter) - - `python3` - - `py.exe -3` (Windows) - - `py.exe -2` (Windows) +- `python` (which can be a py3 or py2 interpreter) +- `python3` +- `py.exe -3` (Windows) +- `py.exe -2` (Windows) +{{% /note %}} ### Alternative installation methods (not recommended) -!!!note - - Using alternative installation methods will make Poetry always - use the Python version for which it has been installed to create - virtualenvs. +{{% note %}} +Using alternative installation methods will make Poetry always +use the Python version for which it has been installed to create +virtualenvs. - So, you will need to install Poetry for each Python version you - want to use and switch between them. +So, you will need to install Poetry for each Python version you +want to use and switch between them. +{{% /note %}} #### Installing with `pip` @@ -113,14 +124,14 @@ Using `pip` to install Poetry is possible. pip install --user poetry ``` -!!!warning - - Be aware that it will also install Poetry's dependencies - which might cause conflicts with other packages. +{{% warning %}} +Be aware that it will also install Poetry's dependencies +which might cause conflicts with other packages. +{{% /warning %}} #### Installing with `pipx` -Using [`pipx`](https://github.com/cs01/pipx) to install Poetry is also possible. [pipx] is used to install Python CLI applications globally while still isolating them in virtual environments. This allows for clean upgrades and uninstalls. pipx supports Python 3.6 and later. If using an earlier version of Python, consider [pipsi](https://github.com/mitsuhiko/pipsi). +Using [`pipx`](https://github.com/cs01/pipx) to install Poetry is also possible. `pipx` is used to install Python CLI applications globally while still isolating them in virtual environments. This allows for clean upgrades and uninstalls. pipx supports Python 3.6 and later. If using an earlier version of Python, consider [pipsi](https://github.com/mitsuhiko/pipsi). ```bash pipx install poetry @@ -158,15 +169,14 @@ to `self update`. poetry self update 0.8.0 ``` -!!!note - - The `self update` command will only work if you used the recommended - installer to install Poetry. - -!!!note - - If you are still on poetry version < 1.0 use `poetry self:update` instead. +{{% note %}} +The `self update` command will only work if you used the recommended +installer to install Poetry. +{{% /note %}} +{{% note %}} +If you are still on poetry version < 1.0 use `poetry self:update` instead. +{{% /note %}} ## Enable tab completion for Bash, Fish, or Zsh @@ -199,9 +209,9 @@ poetry completions zsh > ~/.zprezto/modules/completion/external/src/_poetry ``` -!!! note - - You may need to restart your shell in order for the changes to take effect. +{{% note %}} +You may need to restart your shell in order for the changes to take effect. +{{% /note %}} For `zsh`, you must then add the following line in your `~/.zshrc` before `compinit`: @@ -211,7 +221,7 @@ fpath+=~/.zfunc For `oh-my-zsh`, you must then enable poetry in your `~/.zshrc` plugins -``` +```text plugins( poetry ... diff --git a/docs/docs/basic-usage.md b/docs/basic-usage.md similarity index 78% rename from docs/docs/basic-usage.md rename to docs/basic-usage.md index 178c75954d6..76f57c33733 100644 --- a/docs/docs/basic-usage.md +++ b/docs/basic-usage.md @@ -1,7 +1,18 @@ +--- +title: "Basic usage" +draft: false +type: docs +layout: single + +menu: + docs: + weight: 10 +--- + # Basic usage For the basic usage introduction we will be installing `pendulum`, a datetime library. -If you have not yet installed Poetry, refer to the [Introduction](/docs/) chapter. +If you have not yet installed Poetry, refer to the [Introduction]({{< relref "." >}} "Introduction") chapter. ## Project setup @@ -77,8 +88,8 @@ It will automatically find a suitable version constraint **and install** the pac ## Using your virtual environment By default, poetry creates a virtual environment in `{cache-dir}/virtualenvs` (`{cache-dir}\virtualenvs` on Windows). -You can change the [`cache-dir`](/docs/configuration/#cache-dir) value by editing the poetry config. -Additionally, you can use the [`virtualenvs.in-project`](/docs/configuration/#virtualenvs.in-project) configuration variable +You can change the [`cache-dir`]({{< relref "configuration#cache-dir" >}} "cache-dir configuration documentation") value by editing the poetry config. +Additionally, you can use the [`virtualenvs.in-project`]({{< relref "configuration#virtualenvsin-project" >}} "virtualenv.in-project configuration documentation") configuration variable to create virtual environment within your project directory. @@ -96,19 +107,19 @@ The easiest way to activate the virtual environment is to create a new shell wit To deactivate the virtual environment and exit this new shell type `exit`. To deactivate the virtual environment without leaving the shell use `deactivate`. -!!!note - - **Why a new shell?** - Child processes inherit their environment from their parents, but do not share - them. As such, any modifications made by a child process, is not persisted after - the child process exits. A Python application (Poetry), being a child process, - cannot modify the environment of the shell that it has been called from such - that an activated virtual environment remains active after the Poetry command - has completed execution. +{{% note %}} +**Why a new shell?** - Therefore, Poetry has to create a sub-shell with the virtual envrionment activated - in order for the subsequent commands to run from within the virtual environment. +Child processes inherit their environment from their parents, but do not share +them. As such, any modifications made by a child process, is not persisted after +the child process exits. A Python application (Poetry), being a child process, +cannot modify the environment of the shell that it has been called from such +that an activated virtual environment remains active after the Poetry command +has completed execution. +Therefore, Poetry has to create a sub-shell with the virtual envrionment activated +in order for the subsequent commands to run from within the virtual environment. +{{% /note %}} Alternatively, to avoid creating a new shell, you can manually activate the virtual environment by running `source {path_to_venv}/bin/activate` (`source {path_to_venv}\Scripts\activate.bat` on Windows). @@ -128,21 +139,21 @@ To deactivate this virtual environment simply use `deactivate`. In our example, we are requesting the `pendulum` package with the version constraint `^1.4`. This means any version greater or equal to 1.4.0 and less than 2.0.0 (`>=1.4.0 <2.0.0`). -Please read [Dependency specification](/docs/dependency-specification) for more in-depth information on versions, +Please read [Dependency specification]({{< relref "dependency-specification" >}} "Dependency specification documentation") for more in-depth information on versions, how versions relate to each other, and on the different ways you can specify dependencies. -!!!note +{{% note %}} +**How does Poetry download the right files?** - **How does Poetry download the right files?** +When you specify a dependency in `pyproject.toml`, Poetry first takes the name of the package +that you have requested and searches for it in any repository you have registered using the `repositories` key. +If you have not registered any extra repositories, or it does not find a package with that name in the +repositories you have specified, it falls back on PyPI. - When you specify a dependency in `pyproject.toml`, Poetry first takes the name of the package - that you have requested and searches for it in any repository you have registered using the `repositories` key. - If you have not registered any extra repositories, or it does not find a package with that name in the - repositories you have specified, it falls back on PyPI. - - When Poetry finds the right package, it then attempts to find the best match - for the version constraint you have specified. +When Poetry finds the right package, it then attempts to find the best match +for the version constraint you have specified. +{{% /note %}} ## Installing dependencies @@ -189,9 +200,9 @@ Even if you develop alone, in six months when reinstalling the project you can f the dependencies installed are still working even if your dependencies released many new versions since then. (See note below about using the update command.) -!!!note - - For libraries it is not necessary to commit the lock file. +{{% note %}} +For libraries it is not necessary to commit the lock file. +{{% /note %}} ### Installing dependencies only @@ -212,7 +223,7 @@ This will fetch the latest matching versions (according to your `pyproject.toml` and update the lock file with the new versions. (This is equivalent to deleting the `poetry.lock` file and running `install` again.) -!!!note - - Poetry will display a **Warning** when executing an install command if `poetry.lock` and `pyproject.toml` - are not synchronized. +{{% note %}} +Poetry will display a **Warning** when executing an install command if `poetry.lock` and `pyproject.toml` +are not synchronized. +{{% /note %}} diff --git a/docs/docs/cli.md b/docs/cli.md similarity index 93% rename from docs/docs/cli.md rename to docs/cli.md index 2196c97831f..fb353ebcbef 100644 --- a/docs/docs/cli.md +++ b/docs/cli.md @@ -1,3 +1,14 @@ +--- +title: "Commands" +draft: false +type: docs +layout: single + +menu: + docs: + weight: 30 +--- + # Commands You've already learned how to use the command-line interface to do some things. @@ -116,7 +127,7 @@ poetry install --remove-untracked ``` You can also specify the extras you want installed -by passing the `-E|--extras` option (See [Extras](/docs/pyproject/#extras) for more info) +by passing the `-E|--extras` option (See [Extras]({{< relref "pyproject#extras" >}}) for more info) ```bash poetry install --extras "mysql pgsql" @@ -132,7 +143,6 @@ Installing dependencies from lock file No dependencies to install or update - Installing (x.x.x) - ``` If you want to skip this installation, use the `--no-root` option. @@ -237,10 +247,10 @@ If you want the dependency to be installed in editable mode you can specify it i my-package = {path = "../my/path", develop = true} ``` -!!!note - - Before poetry 1.1 path dependencies were installed in editable mode by default. You should always set the `develop` attribute explicit, - to make sure the behavior is the same for all poetry versions. +{{% note %}} +Before poetry 1.1 path dependencies were installed in editable mode by default. You should always set the `develop` attribute explicit, +to make sure the behavior is the same for all poetry versions. +{{% /note %}} If the package(s) you want to install provide extras, you can specify them when adding the package: @@ -355,7 +365,7 @@ poetry config [options] [setting-key] [setting-value1] ... [setting-valueN] ```` `setting-key` is a configuration option name and `setting-value1` is a configuration value. -See [Configuration](/docs/configuration/) for all available settings. +See [Configuration]({{< relref "configuration" >}}) for all available settings. ### Options @@ -419,9 +429,9 @@ poetry search requests pendulum This command locks (without installing) the dependencies specified in `pyproject.toml`. -!!!note - - By default, this will lock all dependencies to the latest available compatible versions. To only refresh the lock file, use the `--no-update` option. +{{% note %}} +By default, this will lock all dependencies to the latest available compatible versions. To only refresh the lock file, use the `--no-update` option. +{{% /note %}} ```bash poetry lock @@ -466,9 +476,9 @@ This command exports the lock file to other formats. poetry export -f requirements.txt --output requirements.txt ``` -!!!note - - Only the `requirements.txt` format is currently supported. +{{% note %}} +Only the `requirements.txt` format is currently supported. +{{% /note %}} ### Options @@ -486,7 +496,7 @@ poetry export -f requirements.txt --output requirements.txt The `env` command regroups sub commands to interact with the virtualenvs associated with a specific project. -See [Managing environments](/docs/managing-environments/) for more information about these commands. +See [Managing environments]({{< relref "managing-environments" >}}) for more information about these commands. ## cache diff --git a/docs/docs/configuration.md b/docs/configuration.md similarity index 81% rename from docs/docs/configuration.md rename to docs/configuration.md index 05777d0c8de..c89af267c05 100644 --- a/docs/docs/configuration.md +++ b/docs/configuration.md @@ -1,6 +1,17 @@ +--- +title: "Configuration" +draft: false +type: docs +layout: single + +menu: + docs: + weight: 40 +--- + # Configuration -Poetry can be configured via the `config` command ([see more about its usage here](/docs/cli/#config)) +Poetry can be configured via the `config` command ([see more about its usage here]({{< relref "docs/cli#config" >}} "config command documentation")) or directly in the `config.toml` file that will be automatically be created when you first run that command. This file can typically be found in one of the following directories: @@ -92,7 +103,9 @@ export POETRY_HTTP_BASIC_MY_REPOSITORY_PASSWORD=secret ## Available settings -### `cache-dir`: string +### `cache-dir` + +**Type**: string The path to the cache directory used by Poetry. @@ -102,25 +115,33 @@ Defaults to one of the following directories: - Windows: `C:\Users\\AppData\Local\pypoetry\Cache` - Unix: `~/.cache/pypoetry` -### `installer.parallel`: boolean +### `installer.parallel` + +**Type**: boolean Use parallel execution when using the new (`>=1.1.0`) installer. Defaults to `true`. -!!!note: - This configuration will be ignored, and parallel execution disabled when running - Python 2.7 under Windows. +{{% note %}} +This configuration will be ignored, and parallel execution disabled when running +Python 2.7 under Windows. +{{% /note %}} -### `virtualenvs.create`: boolean +### `virtualenvs.create` + +**Type**: boolean Create a new virtual environment if one doesn't already exist. Defaults to `true`. -!!!note: - When setting this configuration to `false`, the Python environment used must have `pip` - installed and available. +{{% note %}} +When setting this configuration to `false`, the Python environment used must have `pip` +installed and available. +{{% /note %}} + +### `virtualenvs.in-project` -### `virtualenvs.in-project`: boolean +**Type**: boolean Create the virtualenv inside the project's root directory. Defaults to `None`. @@ -130,11 +151,15 @@ If set to `true`, the virtualenv wil be created and expected in a folder named ` If not set explicitly (default), `poetry` will use the virtualenv from the `.venv` directory when one is available. If set to `false`, `poetry` will ignore any existing `.venv` directory. -### `virtualenvs.path`: string +### `virtualenvs.path` + +**Type**: string Directory where virtual environments will be created. Defaults to `{cache-dir}/virtualenvs` (`{cache-dir}\virtualenvs` on Windows). -### `repositories.`: string +### `repositories.` + +**Type**: string -Set a new alternative repository. See [Repositories](/docs/repositories/) for more information. +Set a new alternative repository. See [Repositories]({{< relref "repositories" >}}) for more information. diff --git a/docs/contributing.md b/docs/contributing.md new file mode 100644 index 00000000000..ebd0774fec2 --- /dev/null +++ b/docs/contributing.md @@ -0,0 +1,265 @@ +--- +title: "Contributing to Poetry" +draft: false +type: docs +layout: single + +menu: + docs: + weight: 100 +--- + +# Contributing to Poetry + +First off, thanks for taking the time to contribute! + +The following is a set of guidelines for contributing to Poetry on GitHub. These are mostly guidelines, not rules. Use your best judgement, and feel free to propose changes to this document in a pull request. + +#### Table of contents + +[How to contribute](#how-to-contribute) + + * [Reporting bugs](#reporting-bugs) + * [Suggesting enhancements](#suggesting-enhancements) + * [Contributing to documentation](#contributing-to-documentation) + * [Contributing to code](#contributing-to-code) + * [Issue triage](#issue-triage) + * [Git workflow](#git-workflow) + + +## How to contribute + +### Reporting bugs + +This section guides you through submitting a bug report for Poetry. +Following these guidelines helps maintainers and the community understand your report, reproduce the behavior, and find related reports. + +Before creating bug reports, please check [this list](#before-submitting-a-bug-report) to be sure that you need to create one. When you are creating a bug report, please include as many details as possible. Fill out the [required template](https://github.com/python-poetry/poetry/blob/master/.github/ISSUE_TEMPLATE/---bug-report.md), the information it asks helps the maintainers resolve the issue faster. + +> **Note:** If you find a **Closed** issue that seems like it is the same thing that you're experiencing, open a new issue and include a link to the original issue in the body of your new one. +#### Before submitting a bug report + +* **Check the [FAQs on the official website](https://python-poetry.org/docs/faq)** for a list of common questions and problems. +* **Check that your issue does not already exist in the [issue tracker](https://github.com/python-poetry/poetry/issues)**. + +#### How do I submit a bug report? + +Bugs are tracked on the [official issue tracker](https://github.com/python-poetry/poetry/issues) where you can create a new one and provide the following information by filling in [the template](https://github.com/python-poetry/poetry/blob/master/.github/ISSUE_TEMPLATE/---bug-report.md). + +Explain the problem and include additional details to help maintainers reproduce the problem: + +* **Use a clear and descriptive title** for the issue to identify the problem. +* **Describe the exact steps which reproduce the problem** in as many details as possible. +* **Provide your pyproject.toml file** in a [Gist](https://gist.github.com) after removing potential private information (like private package repositories). +* **Provide specific examples to demonstrate the steps to reproduce the issue**. Include links to files or GitHub projects, or copy-paste-able snippets, which you use in those examples. +* **Describe the behavior you observed after following the steps** and point out what exactly is the problem with that behavior. +* **Explain which behavior you expected to see instead and why.** +* **If the problem is an unexpected error being raised**, execute the corresponding command in **debug** mode (the `-vvv` option). + +Provide more context by answering these questions: + +* **Did the problem start happening recently** (e.g. after updating to a new version of Poetry) or was this always a problem? +* If the problem started happening recently, **can you reproduce the problem in an older version of Poetry?** What's the most recent version in which the problem doesn't happen? +* **Can you reliably reproduce the issue?** If not, provide details about how often the problem happens and under which conditions it normally happens. + +Include details about your configuration and environment: + +* **Which version of Poetry are you using?** You can get the exact version by running `poetry -V` in your terminal. +* **Which Python version Poetry has been installed for?** Execute the `debug:info` to get the information. +* **What's the name and version of the OS you're using**? + + +### Suggesting enhancements + +This section guides you through submitting an enhancement suggestion for Poetry, including completely new features and minor improvements to existing functionality. Following these guidelines helps maintainers and the community understand your suggestion and find related suggestions. + +Before creating enhancement suggestions, please check [this list](#before-submitting-an-enhancement-suggestion) as you might find out that you don't need to create one. When you are creating an enhancement suggestion, please [include as many details as possible](#how-do-i-submit-an-enhancement-suggestion). Fill in [the template](https://github.com/python-poetry/poetry/blob/master/.github/ISSUE_TEMPLATE/---feature-request.md), including the steps that you imagine you would take if the feature you're requesting existed. + +#### Before submitting an enhancement suggestion + +* **Check the [FAQs on the official website](https://python-poetry.org/docs/faq)** for a list of common questions and problems. +* **Check that your issue does not already exist in the [issue tracker](https://github.com/python-poetry/poetry/issues)**. + +#### How do I submit an Enhancement suggestion? + +Enhancement suggestions are tracked on the [official issue tracker](https://github.com/python-poetry/poetry/issues) where you can create a new one and provide the following information: + +* **Use a clear and descriptive title** for the issue to identify the suggestion. +* **Provide a step-by-step description of the suggested enhancement** in as many details as possible. +* **Provide specific examples to demonstrate the steps**.. +* **Describe the current behavior** and **explain which behavior you expected to see instead** and why. + +### Contributing to documentation + +One of the simplest ways to get started contributing to a project is through improving documentation. Poetry is constantly evolving, this means that sometimes our documentation has gaps. You can help by +adding missing sections, editing the existing content so it is more accessible or creating new content (tutorials, FAQs, etc). + +{{% note %}} +A great way to understand Poetry's design and how it all fits together, is to add FAQ entries for commonly +asked questions. Poetry members usually mark issues with [candidate/faq](https://github.com/python-poetry/poetry/issues?q=is%3Aissue+label%3Acandidate%2Ffaq+) to indicate that the issue either contains a response +that explains how something works or might benefit from an entry in the FAQ. +{{% /note %}} + +Issues pertaining to the documentation are usually marked with the [Documentation](https://github.com/python-poetry/poetry/labels/Documentation) label. + +### Contributing to code + +#### Picking an issue + +{{% note %}} +If you are a first time contributor, and are looking for an issue to take on, you might want to look for [Good First Issue](https://github.com/python-poetry/poetry/issues?q=is%3Aopen+is%3Aissue+label%3A%22Good+First+Issue%22) +labelled issues. We do our best to label such issues, however we might fall behind at times. So, ask us. +{{% /note %}} + +If you would like to take on an issue, feel free to comment on the issue tagging `@python-poetry/triage`. We are more than happy to discuss solutions on the issue. If you would like help with navigating +the code base, join us on our [Discord Server](https://discordapp.com/invite/awxPgve). + +#### Local development + +You will need Poetry to start contributing on the Poetry codebase. Refer to the [documentation](https://python-poetry.org/docs/#introduction) to start using Poetry. + +You will first need to clone the repository using `git` and place yourself in its directory: + +```bash +$ git clone git@github.com:python-poetry/poetry.git +$ cd poetry +``` + +{{% note %}} +We recommend that you use a personal [fork](https://docs.github.com/en/free-pro-team@latest/github/getting-started-with-github/fork-a-repo) for this step. If you are new to GitHub collaboration, +you can refer to the [Forking Projects Guide](https://guides.github.com/activities/forking/). +{{% /note %}} + +Now, you will need to install the required dependency for Poetry and be sure that the current +tests are passing on your machine: + +```bash +$ poetry install +$ poetry run pytest tests/ +``` + +Poetry uses the [black](https://github.com/psf/black) coding style and you must ensure that your +code follows it. If not, the CI will fail and your Pull Request will not be merged. + +Similarly, the import statements are sorted with [isort](https://github.com/timothycrosley/isort) +and special care must be taken to respect it. If you don't, the CI will fail as well. + +To make sure that you don't accidentally commit code that does not follow the coding style, you can +install a pre-commit hook that will check that everything is in order: + +```bash +$ poetry run pre-commit install +``` + +You can also run it anytime using: + +```bash +$ poetry run pre-commit run --all-files +``` + +Your code must always be accompanied by corresponding tests, if tests are not present your code +will not be merged. + +#### Pull requests + +* Fill in [the required template](https://github.com/python-poetry/poetry/blob/master/.github/PULL_REQUEST_TEMPLATE.md) +* Be sure that your pull request contains tests that cover the changed or added code. +* If your changes warrant a documentation change, the pull request must also update the documentation. + +{{% note %}} +Make sure your branch is [rebased](https://docs.github.com/en/free-pro-team@latest/github/using-git/about-git-rebase) against the latest main branch. A maintainer might ask you to ensure the branch is +up-to-date prior to merging your Pull Request if changes have conflicts. +{{% /note %}} + +All pull requests, unless otherwise instructed, need to be first accepted into the main branch (`master`). + +### Issue triage + +{{% note %}} +If you have an issue that hasn't had any attention, you can ping us `@python-poetry/triage` on the issue. Please, give us reasonable time to get to your issue first, spamming us with messages +{{% /note %}} + +If you are helping with the triage of reported issues, this section provides some useful information to assist you in your contribution. + +#### Triage steps + +1. If `pyproject.toml` is missing or `-vvv` debug logs (with stack trace) is not provided and required, request that the issue author provides it. +1. Attempt to reproduce the issue with the reported Poetry version or request further clarification from the issue author. +1. Ensure the issue is not already resolved. You can attempt to reproduce using the latest preview release and/or poetry from the main branch. +1. If the issue cannot be reproduced, + 1. clarify with the issue's author, + 1. close the issue or notify `@python-poetry/triage`. +1. If the issue can be reproduced, + 1. comment on the issue confirming so + 1. notify `@python-poetry/triage`. + 1. if possible, identify the root cause of the issue. + 1. if interested, attempt to fix it via a pull request. + +#### Multiple versions + +Often times you would want to attempt to reproduce issues with multiple versions of `poetry` at the same time. For these use cases, the [pipx project](https://pipxproject.github.io/pipx/) is useful. + +You can set your environment up like so. + +```sh +pipx install --suffix @1.0.10 'poetry==1.0.10' +pipx install --suffix @1.1.0rc1 'poetry==1.1.0rc1' +pipx install --suffix @master 'poetry @ git+https://github.com/python-poetry/poetry' +``` + +{{% note %}} +Do not forget to update your `poetry@master` installation in sync with upstream. +{{% /note %}} + +For `@local` it is recommended that you do something similar to the following as editable installs are not supported for PEP 517 projects. + +```sh +# note this will not work for Windows, and we assume you have already run `poetry install` +cd /path/to/python-poetry/poetry +ln -sf $(poetry run which poetry) ~/.local/bin/poetry@local +``` + +{{% note %}} +This mechanism can also be used to test pull requests. +{{% /note %}} + +### Git Workflow + +All development work is performed against Poetry's main branch (`master`). All changes are expected to be submitted and accepted to this +branch. + +#### Release branch + +When a release is ready, the following are required before a release is tagged. + +1. A release branch with the prefix `release-`, eg: `release-1.1.0rc1`. +1. A pull request from the release branch to the main branch (`master`) if it's a minor or major release. Otherwise, to the bug fix branch (eg: `1.0`). + 1. The pull request description MUST include the change log corresponding to the release (eg: [#2971](https://github.com/python-poetry/poetry/pull/2971)). + 1. The pull request must contain a commit that updates [CHANGELOG.md](CHANGELOG.md) and bumps the project version (eg: [#2971](https://github.com/python-poetry/poetry/pull/2971/commits/824e7b79defca435cf1d765bb633030b71b9a780)). + 1. The pull request must have the `Release` label specified. + +Once the branch pull-request is ready and approved, a member of `@python-poetry/core` will, + +1. Tag the branch with the version identifier (eg: `1.1.0rc1`). +2. Merge the pull request once the release is created and assets are uploaded by the CI. + +{{% note %}} +In this case, we prefer a merge commit instead of squash or rebase merge. +{{% /note %}} + +#### Bug fix branch + +Once a minor version (eg: `1.1.0`) is released, a new branch for the minor version (eg: `1.1`) is created for the bug fix releases. Changes identified +or acknowledged by the Poetry team as requiring a bug fix can be submitted as a pull requests against this branch. + +At the time of writing only issues meeting the following criteria may be accepted into a bug fix branch. Trivial fixes may be accepted on a +case-by-case basis. + +1. The issue breaks a core functionality and/or is a critical regression. +1. The change set does not introduce a new feature or changes an existing functionality. +1. A new minor release is not expected within a reasonable time frame. +1. If the issue affects the next minor/major release, a corresponding fix has been accepted into the main branch. + +{{% note %}} +This is subject to the interpretation of a maintainer within the context of the issue. +{{% /note %}} diff --git a/docs/docs/dependency-specification.md b/docs/dependency-specification.md similarity index 92% rename from docs/docs/dependency-specification.md rename to docs/dependency-specification.md index 2a1b63afdae..5591a83054b 100644 --- a/docs/docs/dependency-specification.md +++ b/docs/dependency-specification.md @@ -1,3 +1,14 @@ +--- +title: "Dependency specification" +draft: false +type: docs +layout: single + +menu: + docs: + weight: 70 +--- + # Dependency specification Dependencies for a project can be specified in various forms, which depend on the type @@ -117,10 +128,10 @@ my-package = { path = "../my-package/", develop = false } my-package = { path = "../my-package/dist/my-package-0.1.0.tar.gz" } ``` -!!!note - - Before poetry 1.1 directory path dependencies were installed in editable mode by default. You should set the `develop` attribute explicitly, - to make sure the behavior is the same for all poetry versions. +{{% note %}} +Before poetry 1.1 directory path dependencies were installed in editable mode by default. You should set the `develop` attribute explicitly, +to make sure the behavior is the same for all poetry versions. +{{% /note %}} ## `url` dependencies @@ -211,7 +222,7 @@ All of the same information is still present, and ends up providing the exact same specification. It's simply split into multiple, slightly more readable, lines. -!!!note - - The constraints **must** have different requirements (like `python`) - otherwise it will cause an error when resolving dependencies. +{{% note %}} +The constraints **must** have different requirements (like `python`) +otherwise it will cause an error when resolving dependencies. +{{% /note %}} diff --git a/docs/docs/contributing.md b/docs/docs/contributing.md deleted file mode 100644 index 568877b4a4f..00000000000 --- a/docs/docs/contributing.md +++ /dev/null @@ -1 +0,0 @@ -{!../CONTRIBUTING.md!} diff --git a/docs/docs/faq.md b/docs/faq.md similarity index 78% rename from docs/docs/faq.md rename to docs/faq.md index 4d464d7ebc0..122a6856e6b 100644 --- a/docs/docs/faq.md +++ b/docs/faq.md @@ -1,6 +1,17 @@ +--- +title: "FAQ" +draft: false +type: docs +layout: single + +menu: + docs: + weight: 110 +--- + # FAQ -## Why is the dependency resolution process slow? +### Why is the dependency resolution process slow? While the dependency resolver at the heart of Poetry is highly optimized and should be fast enough for most cases, sometimes, with some specific set of dependencies, @@ -13,18 +24,18 @@ operation, both in bandwidth and time, which is why it seems this is a long proc At the moment there is no way around it. -!!!note - - Once Poetry has cached the releases' information, the dependency resolution process - will be much faster. +{{% note %}} +Once Poetry has cached the releases' information, the dependency resolution process +will be much faster. +{{% /note %}} -## Why are unbound version constraints a bad idea? +### Why are unbound version constraints a bad idea? A version constraint without an upper bound such as `*` or `>=3.4` will allow updates to any future version of the dependency. This includes major versions breaking backward compatibility. Once a release of your package is published, you cannot tweak its dependencies anymore in case a dependency breaks BC -- you have to do a new release but the previous one stays broken. +– you have to do a new release but the previous one stays broken. The only good alternative is to define an upper bound on your constraints, which you can increase in a new release after testing that your package is compatible @@ -33,9 +44,9 @@ with the new major version of your dependency. For example instead of using `>=3.4` you should use `~3.4` which allows all versions `<4.0`. The `^` operator works very well with libraries following [semantic versioning](https://semver.org). -## Is tox supported? +### Is tox supported? -Yes. By using the [isolated builds](https://tox.readthedocs.io/en/latest/config.html#conf-isolated_build) `tox` provides, +**Yes**. By using the [isolated builds](https://tox.readthedocs.io/en/latest/config.html#conf-isolated_build) `tox` provides, you can use it in combination with the PEP 517 compliant build system provided by Poetry. So, in your `pyproject.toml` file, add this section if it does not already exist: @@ -60,7 +71,7 @@ commands = poetry run pytest tests/ ``` -## I don't want Poetry to manage my virtual environments. Can I disable it? +### I don't want Poetry to manage my virtual environments. Can I disable it? While Poetry automatically creates virtual environments to always work isolated from the global Python installation, there are valid reasons why it's not necessary diff --git a/docs/docs/libraries.md b/docs/libraries.md similarity index 78% rename from docs/docs/libraries.md rename to docs/libraries.md index db4822c342d..df23e68b139 100644 --- a/docs/docs/libraries.md +++ b/docs/libraries.md @@ -1,3 +1,14 @@ +--- +title: "Libraries" +draft: false +type: docs +layout: "docs" + +menu: + docs: + weight: 20 +--- + # Libraries This chapter will tell you how to make your library installable through Poetry. @@ -9,7 +20,7 @@ While Poetry does not enforce any convention regarding package versioning, it **strongly** recommends to follow [semantic versioning](https://semver.org). This has many advantages for the end users and allows them to set appropriate -[version constraints](/docs/dependency-specification/#version-constraints). +[version constraints]({{< relref "dependency-specification#version-constraints" >}}). ## Lock file @@ -49,14 +60,14 @@ poetry publish ``` This will package and publish the library to PyPI, at the condition that you are a registered user -and you have [configured your credentials](/docs/repositories/#adding-credentials) properly. - -!!!note +and you have [configured your credentials]({{< relref "repositories#configuring-credentials" >}}) properly. - The `publish` command does not execute `build` by default. +{{% note %}} +The `publish` command does not execute `build` by default. - If you want to build and publish your packages together, - just pass the `--build` option. +If you want to build and publish your packages together, +just pass the `--build` option. +{{% /note %}} Once this is done, your library will be available to anyone. @@ -68,7 +79,7 @@ Sometimes, you may want to keep your library private but also being accessible t In this case, you will need to use a private repository. In order to publish to a private repository, you will need to add it to your -global list of repositories. See [Adding a repository](/docs/repositories/#adding-a-repository) +global list of repositories. See [Adding a repository]({{< relref "repositories#adding-a-repository" >}}) for more information. Once this is done, you can actually publish to it like so: diff --git a/docs/docs/managing-environments.md b/docs/managing-environments.md similarity index 86% rename from docs/docs/managing-environments.md rename to docs/managing-environments.md index 8b626cd813a..d9b728825a1 100644 --- a/docs/docs/managing-environments.md +++ b/docs/managing-environments.md @@ -1,3 +1,14 @@ +--- +title: "Managing environments" +draft: false +type: docs +layout: "docs" + +menu: + docs: + weight: 60 +--- + # Managing environments Poetry makes project environment isolation one of its core features. @@ -15,19 +26,19 @@ with the `python` requirement of the project. In this case, Poetry will try to find one that is and use it. If it's unable to do so then you will be prompted to activate one explicitly, see [Switching environments](#switching-between-environments). -!!!note - - To easily switch between Python versions, it is recommended to - use [pyenv](https://github.com/pyenv/pyenv) or similar tools. +{{% note %}} +To easily switch between Python versions, it is recommended to +use [pyenv](https://github.com/pyenv/pyenv) or similar tools. - For instance, if your project is Python 2.7 only, a standard workflow - would be: +For instance, if your project is Python 2.7 only, a standard workflow +would be: - ```bash - pyenv install 2.7.15 - pyenv local 2.7.15 # Activate Python 2.7 for the current project - poetry install - ``` +```bash +pyenv install 2.7.15 +pyenv local 2.7.15 # Activate Python 2.7 for the current project +poetry install +``` +{{% /note %}} ## Switching between environments diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml deleted file mode 100644 index c35ef9579b4..00000000000 --- a/docs/mkdocs.yml +++ /dev/null @@ -1,30 +0,0 @@ -site_name: Poetry documentation - -theme: - name: null - custom_dir: theme - -extra: - version: 2.0 - -nav: - - Introduction: index.md - - Basic Usage: basic-usage.md - - Libraries: libraries.md - - Commands: cli.md - - Configuration: configuration.md - - Repositories: repositories.md - - Managing environments: managing-environments.md - - Dependency specification: dependency-specification.md - - The pyproject.toml file: pyproject.md - - Contributing: contributing.md - - FAQ: faq.md - -markdown_extensions: - - codehilite - - admonition - - pymdownx.superfences - - toc: - permalink:  - - markdown_include.include: - base_path: docs diff --git a/docs/docs/pyproject.md b/docs/pyproject.md similarity index 80% rename from docs/docs/pyproject.md rename to docs/pyproject.md index 14221b8b03a..6dedc953643 100644 --- a/docs/docs/pyproject.md +++ b/docs/pyproject.md @@ -1,3 +1,14 @@ +--- +title: "The pyproject.toml file" +draft: false +type: docs +layout: single + +menu: + docs: + weight: 90 +--- + # The `pyproject.toml` file The `tool.poetry` section of the `pyproject.toml` file is composed of multiple sections. @@ -40,9 +51,9 @@ The recommended notation for the most common licenses is (alphabetical): Optional, but it is highly recommended to supply this. More identifiers are listed at the [SPDX Open Source License Registry](https://spdx.org/licenses/). -!!!note - - If your project is proprietary and does not use a specific licence, you can set this value as `Proprietary`. +{{% note %}} +If your project is proprietary and does not use a specific licence, you can set this value as `Proprietary`. +{{% /note %}} ## authors @@ -91,11 +102,11 @@ classifiers = [ ] ``` -!!!note +{{% note %}} +Note that Python classifiers are still automatically added for you and are determined by your `python` requirement. - Note that Python classifiers are still automatically added for you and are determined by your `python` requirement. - - The `license` property will also set the License classifier automatically. +The `license` property will also set the License classifier automatically. +{{% /note %}} ## packages @@ -137,26 +148,20 @@ packages = [ From now on, only the `sdist` build archive will include the `my_other_package` package. -!!!note - - Using `packages` disables the package auto-detection feature meaning you have to - **explicitly** specify the "default" package. - - For instance, if you have a package named `my_package` and you want to also include - another package named `extra_package`, you will need to specify `my_package` explicitly: +{{% note %}} +Using `packages` disables the package auto-detection feature meaning you have to +**explicitly** specify the "default" package. - ```toml - packages = [ - { include = "my_package" }, - { include = "extra_package" }, - ] - ``` +For instance, if you have a package named `my_package` and you want to also include +another package named `extra_package`, you will need to specify `my_package` explicitly: -!!!note - - Poetry is clever enough to detect Python subpackages. - - Thus, you only have to specify the directory where your root package resides. +```toml +packages = [ + { include = "my_package" }, + { include = "extra_package" }, +] +``` +{{% /note %}} ## include and exclude @@ -195,15 +200,15 @@ name = 'private' url = 'http://example.com/simple' ``` -!!!note - - Be aware that declaring the python version for which your package - is compatible is mandatory: +{{% note %}} +Be aware that declaring the python version for which your package +is compatible is mandatory: - ```toml - [tool.poetry.dependencies] - python = "^3.6" - ``` +```toml +[tool.poetry.dependencies] +python = "^3.6" +``` +{{% /note %}} ## `scripts` @@ -216,9 +221,9 @@ poetry = 'poetry.console:run' Here, we will have the `poetry` script installed which will execute `console.run` in the `poetry` package. -!!!note - - When a script is added or updated, run `poetry install` to make them available in the project's virtualenv. +{{% note %}} +When a script is added or updated, run `poetry install` to make them available in the project's virtualenv. +{{% /note %}} ## `extras` @@ -292,12 +297,11 @@ requires = ["poetry_core>=1.0.0"] build-backend = "poetry.core.masonry.api" ``` -!!!note - - When using the `new` or `init` command this section will be automatically added. - - -!!!note +{{% note %}} +When using the `new` or `init` command this section will be automatically added. +{{% /note %}} - If your `pyproject.toml` file still references `poetry` directly as a build backend, - you should update it to reference `poetry_core` instead. +{{% note %}} +If your `pyproject.toml` file still references `poetry` directly as a build backend, +you should update it to reference `poetry-core` instead. +{{% /note %}} diff --git a/docs/docs/repositories.md b/docs/repositories.md similarity index 76% rename from docs/docs/repositories.md rename to docs/repositories.md index d281f6ca77a..f2abe573dd8 100644 --- a/docs/docs/repositories.md +++ b/docs/repositories.md @@ -1,3 +1,14 @@ +--- +title: "Repositories" +draft: false +type: docs +layout: "docs" + +menu: + docs: + weight: 50 +--- + # Repositories ## Using the PyPI repository @@ -37,24 +48,24 @@ poetry config http-basic.foo username password If you do not specify the password you will be prompted to write it. -!!!note +{{% note %}} +To publish to PyPI, you can set your credentials for the repository named `pypi`. - To publish to PyPI, you can set your credentials for the repository named `pypi`. +Note that it is recommended to use [API tokens](https://pypi.org/help/#apitoken) +when uploading packages to PyPI. +Once you have created a new token, you can tell Poetry to use it: - Note that it is recommended to use [API tokens](https://pypi.org/help/#apitoken) - when uploading packages to PyPI. - Once you have created a new token, you can tell Poetry to use it: - - ```bash - poetry config pypi-token.pypi my-token - ``` +```bash +poetry config pypi-token.pypi my-token +``` - If you still want to use you username and password, you can do so with the following - call to `config`. +If you still want to use you username and password, you can do so with the following +call to `config`. - ```bash - poetry config http-basic.pypi username password - ``` +```bash +poetry config http-basic.pypi username password +``` +{{% /note %}} You can also specify the username and password when using the `publish` command with the `--username` and `--password` options. @@ -71,17 +82,19 @@ export POETRY_HTTP_BASIC_PYPI_USERNAME=username export POETRY_HTTP_BASIC_PYPI_PASSWORD=password ``` -See [Using environment variables](/docs/configuration/#using-environment-variables) for more information +See [Using environment variables]({{< relref "configuration#using-environment-variables" >}}) for more information on how to configure Poetry with environment variables. #### Custom certificate authority and mutual TLS authentication + Poetry supports repositories that are secured by a custom certificate authority as well as those that require certificate-based client authentication. The following will configure the "foo" repository to validate the repository's certificate using a custom certificate authority and use a client certificate (note that these config variables do not both need to be set): + ```bash - poetry config certificates.foo.cert /path/to/ca.pem - poetry config certificates.foo.client-cert /path/to/client.pem +poetry config certificates.foo.cert /path/to/ca.pem +poetry config certificates.foo.client-cert /path/to/client.pem ``` ### Install dependencies from a private repository @@ -99,19 +112,19 @@ url = "https://foo.bar/simple/" From now on, Poetry will also look for packages in your private repository. -!!!note - - Any custom repository will have precedence over PyPI. +{{% note %}} +Any custom repository will have precedence over PyPI. - If you still want PyPI to be your primary source for your packages - you can declare custom repositories as secondary. +If you still want PyPI to be your primary source for your packages +you can declare custom repositories as secondary. - ```toml - [[tool.poetry.source]] - name = "foo" - url = "https://foo.bar/simple/" - secondary = true - ``` +```toml +[[tool.poetry.source]] +name = "foo" +url = "https://foo.bar/simple/" +secondary = true +``` +{{% /note %}} If your private repository requires HTTP Basic Auth be sure to add the username and password to your `http-basic` configuration using the example above (be sure to use the diff --git a/docs/theme/main.html b/docs/theme/main.html deleted file mode 100644 index 83151151ff6..00000000000 --- a/docs/theme/main.html +++ /dev/null @@ -1,29 +0,0 @@ ---- -layout: documentation -title: {{ page.title|striptags|e }} ---- - -
-
-
-
-
-
-
    - {% set navlevel = 1 %} - - {% for nav_item in nav %} - - {% endfor %} -
-
-
- {{page.content}} -
-
-
-
-
-
diff --git a/docs/theme/nav.html b/docs/theme/nav.html deleted file mode 100644 index e9d2b383844..00000000000 --- a/docs/theme/nav.html +++ /dev/null @@ -1,18 +0,0 @@ -{{ nav_item.title }} - -{%- if nav_item == page or nav_item.children %} - -{%- endif %} diff --git a/docs/theme/toc.html b/docs/theme/toc.html deleted file mode 100644 index 4f3e8e09ab6..00000000000 --- a/docs/theme/toc.html +++ /dev/null @@ -1,10 +0,0 @@ -{% for toc_item in page.toc %} - -{% if toc_item.children %} - -{% endif %} -{% endfor %} diff --git a/tox.ini b/tox.ini index 190670191da..29cad8f7429 100644 --- a/tox.ini +++ b/tox.ini @@ -1,22 +1,10 @@ [tox] minversion = 3.3.0 isolated_build = True -envlist = py27, py35, py36, py37, py38, doc +envlist = py27, py35, py36, py37, py38 [testenv] whitelist_externals = poetry commands = poetry install -vv --no-root poetry run pytest {posargs} tests/ - -[testenv:doc] -whitelist_externals = -skip_install = true -deps = - markdown-include - mkdocs - pygments - pygments-github-lexers - pymdown-extensions -commands = - mkdocs build -f docs/mkdocs.yml