Commit 6db85a66 by Dos Moonen

Merge branch 'master' into pip-style-keyring-fallback

parents 5c7c9da3 925429fd
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
...@@ -92,6 +92,9 @@ python install-poetry.py --git https://github.com/python-poetry/poetry.git@maste ...@@ -92,6 +92,9 @@ python install-poetry.py --git https://github.com/python-poetry/poetry.git@maste
Updating poetry to the latest stable version is as simple as calling the `self update` command. Updating poetry to the latest stable version is as simple as calling the `self update` command.
**Warning**: Poetry versions installed using the now deprecated `get-poetry.py` installer will not be able to use this
command to update to 1.2 releases or later. Migrate to using the `install-poetry.py` installer or `pipx`.
```bash ```bash
poetry self update poetry self update
``` ```
......
---
title: "Introduction"
draft: false
type: docs
layout: "single"
menu:
docs:
weight: 0
---
# Introduction # 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. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you.
...@@ -9,11 +20,10 @@ It allows you to declare the libraries your project depends on and it will manag ...@@ -9,11 +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 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. on Windows, Linux and OSX.
!!! note {{% note %}}
Python 2.7 and 3.5 will no longer be supported in the next feature release (1.2).
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.
You should consider updating your Python version to a supported one. {{% /note %}}
## Installation ## Installation
...@@ -29,10 +39,10 @@ curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install- ...@@ -29,10 +39,10 @@ curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-
(Invoke-WebRequest -Uri https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py -UseBasicParsing).Content | python - (Invoke-WebRequest -Uri https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py -UseBasicParsing).Content | python -
``` ```
!!!warning {{% warning %}}
The previous `get-poetry.py` installer is now deprecated, if you are currently using it
The previous `get-poetry.py` installer is now deprecated, if you are currently using it you should migrate to the new, supported, `install-poetry.py` installer.
you should migrate to the new, supported, `install-poetry.py` installer. {{% /warning %}}
The installer installs the `poetry` tool to Poetry's `bin` directory. This location depends on your system: The installer installs the `poetry` tool to Poetry's `bin` directory. This location depends on your system:
...@@ -89,9 +99,9 @@ You can also install Poetry for a `git` repository by using the `--git` option: ...@@ -89,9 +99,9 @@ You can also install Poetry for a `git` repository by using the `--git` option:
python install-poetry.py --git https://github.com/python-poetry/poetry.git@master python install-poetry.py --git https://github.com/python-poetry/poetry.git@master
```` ````
!!!note {{% note %}}
Note that the installer does not support Python < 3.6.
Note that the installer does not support Python < 3.6. {{% /note %}}
### Alternative installation methods ### Alternative installation methods
...@@ -123,11 +133,10 @@ Using `pip` to install Poetry is possible. ...@@ -123,11 +133,10 @@ Using `pip` to install Poetry is possible.
pip install --user poetry pip install --user poetry
``` ```
!!!warning {{% warning %}}
Be aware that it will also install Poetry's dependencies
Be aware that it will also install Poetry's dependencies which might cause conflicts with other packages.
which might cause conflicts with other packages. {{% /warning %}}
## Updating `poetry` ## Updating `poetry`
...@@ -137,6 +146,11 @@ Updating Poetry to the latest stable version is as simple as calling the `self u ...@@ -137,6 +146,11 @@ Updating Poetry to the latest stable version is as simple as calling the `self u
poetry self update poetry self update
``` ```
{{% warning %}}
Poetry versions installed using the now deprecated `get-poetry.py` installer will not be able to use this
command to update to 1.2 releases or later. Migrate to using the `install-poetry.py` installer or `pipx`.
{{% /warning %}}
If you want to install pre-release versions, you can use the `--preview` option. If you want to install pre-release versions, you can use the `--preview` option.
```bash ```bash
...@@ -182,9 +196,9 @@ poetry completions zsh > ~/.zprezto/modules/completion/external/src/_poetry ...@@ -182,9 +196,9 @@ poetry completions zsh > ~/.zprezto/modules/completion/external/src/_poetry
``` ```
!!! note {{% note %}}
You may need to restart your shell in order for the changes to take effect.
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`: For `zsh`, you must then add the following line in your `~/.zshrc` before `compinit`:
...@@ -194,7 +208,7 @@ fpath+=~/.zfunc ...@@ -194,7 +208,7 @@ fpath+=~/.zfunc
For `oh-my-zsh`, you must then enable poetry in your `~/.zshrc` plugins For `oh-my-zsh`, you must then enable poetry in your `~/.zshrc` plugins
``` ```text
plugins( plugins(
poetry poetry
... ...
......
---
title: "Basic usage"
draft: false
type: docs
layout: single
menu:
docs:
weight: 10
---
# Basic usage # Basic usage
For the basic usage introduction we will be installing `pendulum`, a datetime library. 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 "docs" >}} "Introduction") chapter.
## Project setup ## Project setup
...@@ -77,8 +88,8 @@ It will automatically find a suitable version constraint **and install** the pac ...@@ -77,8 +88,8 @@ It will automatically find a suitable version constraint **and install** the pac
## Using your virtual environment ## Using your virtual environment
By default, poetry creates a virtual environment in `{cache-dir}/virtualenvs` (`{cache-dir}\virtualenvs` on Windows). 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. 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`](/docs/configuration/#virtualenvs.in-project) configuration variable Additionally, you can use the [`virtualenvs.in-project`]({{< relref "configuration#virtualenvsin-project" >}} "#virtualenvs.in-project configuration documentation") configuration variable
to create virtual environment within your project directory. to create virtual environment within your project directory.
...@@ -96,18 +107,19 @@ The easiest way to activate the virtual environment is to create a new shell wit ...@@ -96,18 +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 and exit this new shell type `exit`.
To deactivate the virtual environment without leaving the shell use `deactivate`. To deactivate the virtual environment without leaving the shell use `deactivate`.
!!!note {{% note %}}
**Why a new shell?**
**Why a new shell?** Child processes inherit their environment from their parents, but do not share
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
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,
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
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
that an activated virtual environment remains active after the Poetry command has completed execution.
has completed execution.
Therefore, Poetry has to create a sub-shell with the virtual environment activated Therefore, Poetry has to create a sub-shell with the virtual environment activated
in order for the subsequent commands to run from within the virtual environment. 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 Alternatively, to avoid creating a new shell, you can manually activate the
...@@ -117,10 +129,10 @@ You can also combine these into a nice one-liner, `source $(poetry env info --pa ...@@ -117,10 +129,10 @@ You can also combine these into a nice one-liner, `source $(poetry env info --pa
To deactivate this virtual environment simply use `deactivate`. To deactivate this virtual environment simply use `deactivate`.
| | POSIX Shell | Windows | Exit/Deactivate | | | POSIX Shell | Windows | Exit/Deactivate |
|-------------------|---------------------------------------------------|---------------------------------------------|-----------------| | ----------------- | -------------------------------------------------- | ------------------------------------- | --------------- |
| New Shell | `poetry shell` | `poetry shell` | `exit` | | New Shell | `poetry shell` | `poetry shell` | `exit` |
| Manual Activation | `source {path_to_venv}/bin/activate` | `{path_to_venv}\Scripts\activate.bat` | `deactivate` | | Manual Activation | `source {path_to_venv}/bin/activate` | `{path_to_venv}\Scripts\activate.bat` | `deactivate` |
| One-liner | ```source `poetry env info --path`/bin/activate```| | `deactivate` | | One-liner | ```source `poetry env info --path`/bin/activate``` | | `deactivate` |
### Version constraints ### Version constraints
...@@ -128,21 +140,21 @@ To deactivate this virtual environment simply use `deactivate`. ...@@ -128,21 +140,21 @@ To deactivate this virtual environment simply use `deactivate`.
In our example, we are requesting the `pendulum` package with the version constraint `^1.4`. 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`). 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. 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 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. 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 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. repositories you have specified, it falls back on PyPI.
When Poetry finds the right package, it then attempts to find the best match When Poetry finds the right package, it then attempts to find the best match
for the version constraint you have specified. for the version constraint you have specified.
{{% /note %}}
## Installing dependencies ## Installing dependencies
...@@ -189,9 +201,9 @@ Even if you develop alone, in six months when reinstalling the project you can f ...@@ -189,9 +201,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. the dependencies installed are still working even if your dependencies released many new versions since then.
(See note below about using the update command.) (See note below about using the update command.)
!!!note {{% note %}}
For libraries it is not necessary to commit the lock file.
For libraries it is not necessary to commit the lock file. {{% /note %}}
### Installing dependencies only ### Installing dependencies only
...@@ -212,7 +224,7 @@ This will fetch the latest matching versions (according to your `pyproject.toml` ...@@ -212,7 +224,7 @@ This will fetch the latest matching versions (according to your `pyproject.toml`
and update the lock file with the new versions. and update the lock file with the new versions.
(This is equivalent to deleting the `poetry.lock` file and running `install` again.) (This is equivalent to deleting the `poetry.lock` file and running `install` again.)
!!!note {{% note %}}
Poetry will display a **Warning** when executing an install command if `poetry.lock` and `pyproject.toml`
Poetry will display a **Warning** when executing an install command if `poetry.lock` and `pyproject.toml` are not synchronized.
are not synchronized. {{% /note %}}
---
title: "Commands"
draft: false
type: docs
layout: single
menu:
docs:
weight: 30
---
# Commands # Commands
You've already learned how to use the command-line interface to do some things. You've already learned how to use the command-line interface to do some things.
...@@ -143,7 +155,7 @@ poetry install --remove-untracked ...@@ -143,7 +155,7 @@ poetry install --remove-untracked
``` ```
You can also specify the extras you want installed 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 ```bash
poetry install --extras "mysql pgsql" poetry install --extras "mysql pgsql"
...@@ -159,7 +171,6 @@ Installing dependencies from lock file ...@@ -159,7 +171,6 @@ Installing dependencies from lock file
No dependencies to install or update No dependencies to install or update
- Installing <your-package-name> (x.x.x) - Installing <your-package-name> (x.x.x)
``` ```
If you want to skip this installation, use the `--no-root` option. If you want to skip this installation, use the `--no-root` option.
...@@ -286,10 +297,10 @@ Alternatively, you can specify it in the `pyproject.toml` file. It means that ch ...@@ -286,10 +297,10 @@ Alternatively, you can specify it in the `pyproject.toml` file. It means that ch
my-package = {path = "../my/path", develop = true} my-package = {path = "../my/path", develop = true}
``` ```
!!!note {{% note %}}
Before poetry 1.1 path dependencies were installed in editable mode by default. You should always set the `develop` attribute explicit,
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.
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 If the package(s) you want to install provide extras, you can specify them
when adding the package: when adding the package:
...@@ -409,7 +420,7 @@ poetry config [options] [setting-key] [setting-value1] ... [setting-valueN] ...@@ -409,7 +420,7 @@ poetry config [options] [setting-key] [setting-value1] ... [setting-valueN]
```` ````
`setting-key` is a configuration option name and `setting-value1` is a configuration value. `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 ### Options
...@@ -473,9 +484,9 @@ poetry search requests pendulum ...@@ -473,9 +484,9 @@ poetry search requests pendulum
This command locks (without installing) the dependencies specified in `pyproject.toml`. This command locks (without installing) the dependencies specified in `pyproject.toml`.
!!!note {{% 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.
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 ```bash
poetry lock poetry lock
...@@ -498,7 +509,7 @@ The new version should ideally be a valid [semver](https://semver.org/) string o ...@@ -498,7 +509,7 @@ The new version should ideally be a valid [semver](https://semver.org/) string o
The table below illustrates the effect of these rules with concrete examples. The table below illustrates the effect of these rules with concrete examples.
| rule | before | after | | rule | before | after |
|------------|---------------|---------------| | ---------- | ------------- | ------------- |
| major | 1.3.0 | 2.0.0 | | major | 1.3.0 | 2.0.0 |
| minor | 2.1.4 | 2.2.0 | | minor | 2.1.4 | 2.2.0 |
| patch | 4.1.1 | 4.1.2 | | patch | 4.1.1 | 4.1.2 |
...@@ -521,9 +532,9 @@ This command exports the lock file to other formats. ...@@ -521,9 +532,9 @@ This command exports the lock file to other formats.
poetry export -f requirements.txt --output requirements.txt poetry export -f requirements.txt --output requirements.txt
``` ```
!!!note {{% note %}}
Only the `requirements.txt` format is currently supported.
Only the `requirements.txt` format is currently supported. {{% /note %}}
### Options ### Options
...@@ -541,7 +552,7 @@ poetry export -f requirements.txt --output requirements.txt ...@@ -541,7 +552,7 @@ poetry export -f requirements.txt --output requirements.txt
The `env` command regroups sub commands to interact with the virtualenvs The `env` command regroups sub commands to interact with the virtualenvs
associated with a specific project. 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 ## cache
...@@ -628,18 +639,18 @@ For example, to add the `pypi-test` source, you can run: ...@@ -628,18 +639,18 @@ For example, to add the `pypi-test` source, you can run:
poetry source add pypi-test https://test.pypi.org/simple/ poetry source add pypi-test https://test.pypi.org/simple/
``` ```
!!!note {{% note %}}
You cannot use the name `pypi` as it is reserved for use by the default PyPI source.
You cannot use the name `pypi` as it is reserved for use by the default PyPI source. {{% /note %}}
#### Options #### Options
* `--default`: Set this source as the [default](/docs/repositories/#disabling-the-pypi-repository) (disable PyPI). * `--default`: Set this source as the [default]({{< relref "repositories#disabling-the-pypi-repository" >}}) (disable PyPI).
* `--secondary`: Set this source as a [secondary](/docs/repositories/#install-dependencies-from-a-private-repository) source. * `--secondary`: Set this source as a [secondary]({{< relref "repositories#install-dependencies-from-a-private-repository" >}}) source.
!!!note {{% note %}}
You cannot set a source as both `default` and `secondary`.
You cannot set a source as both `default` and `secondary`. {{% /note %}}
### `source show` ### `source show`
...@@ -655,9 +666,9 @@ Optionally, you can show information of one or more sources by specifying their ...@@ -655,9 +666,9 @@ Optionally, you can show information of one or more sources by specifying their
poetry source show pypi-test poetry source show pypi-test
``` ```
!!!note {{% note %}}
This command will only show sources configured via the `pyproject.toml` and does not include PyPI.
This command will only show sources configured via the `pyproject.toml` and does not include PyPI. {{% /note %}}
### `source remove` ### `source remove`
......
---
title: "Configuration"
draft: false
type: docs
layout: single
menu:
docs:
weight: 40
---
# Configuration # 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 "cli#config" >}} "config command documentation"))
or directly in the `config.toml` file that will be automatically be created when you first run that command. 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: This file can typically be found in one of the following directories:
...@@ -93,7 +104,9 @@ export POETRY_HTTP_BASIC_MY_REPOSITORY_PASSWORD=secret ...@@ -93,7 +104,9 @@ export POETRY_HTTP_BASIC_MY_REPOSITORY_PASSWORD=secret
## Available settings ## Available settings
### `cache-dir`: string ### `cache-dir`
**Type**: string
The path to the cache directory used by Poetry. The path to the cache directory used by Poetry.
...@@ -103,28 +116,35 @@ Defaults to one of the following directories: ...@@ -103,28 +116,35 @@ Defaults to one of the following directories:
- Windows: `C:\Users\<username>\AppData\Local\pypoetry\Cache` - Windows: `C:\Users\<username>\AppData\Local\pypoetry\Cache`
- Unix: `~/.cache/pypoetry` - Unix: `~/.cache/pypoetry`
### `installer.parallel`: boolean ### `installer.parallel`
**Type**: boolean
Use parallel execution when using the new (`>=1.1.0`) installer. Use parallel execution when using the new (`>=1.1.0`) installer.
Defaults to `true`. Defaults to `true`.
!!!note: {{% note %}}
This configuration will be ignored, and parallel execution disabled when running This configuration will be ignored, and parallel execution disabled when running
Python 2.7 under Windows. Python 2.7 under Windows.
{{% /note %}}
### `virtualenvs.create`
### `virtualenvs.create`: boolean **Type**: boolean
Create a new virtual environment if one doesn't already exist. Create a new virtual environment if one doesn't already exist.
Defaults to `true`. Defaults to `true`.
If set to `false`, poetry will install dependencies into the current python environment. If set to `false`, poetry will install dependencies into the current python environment.
!!!note {{% 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` ### `virtualenvs.in-project`
installed and available.
### `virtualenvs.in-project`: boolean **Type**: boolean
Create the virtualenv inside the project's root directory. Create the virtualenv inside the project's root directory.
Defaults to `None`. Defaults to `None`.
...@@ -136,22 +156,30 @@ If not set explicitly (default), `poetry` will use the virtualenv from the `.ven ...@@ -136,22 +156,30 @@ If not set explicitly (default), `poetry` will use the virtualenv from the `.ven
directory when one is available. If set to `false`, `poetry` will ignore any directory when one is available. If set to `false`, `poetry` will ignore any
existing `.venv` directory. existing `.venv` directory.
### `virtualenvs.path`: string ### `virtualenvs.path`
**Type**: string
Directory where virtual environments will be created. Directory where virtual environments will be created.
Defaults to `{cache-dir}/virtualenvs` (`{cache-dir}\virtualenvs` on Windows). Defaults to `{cache-dir}/virtualenvs` (`{cache-dir}\virtualenvs` on Windows).
### `virtualenvs.options.always-copy`: boolean ### `virtualenvs.options.always-copy`
**Type**: boolean
If set to `true` the `--always-copy` parameter is passed to `virtualenv` on creation of the venv. Thus all needed files are copied into the venv instead of symlinked. If set to `true` the `--always-copy` parameter is passed to `virtualenv` on creation of the venv. Thus all needed files are copied into the venv instead of symlinked.
Defaults to `false`. Defaults to `false`.
### `virtualenvs.options.system-site-packages`: boolean ### `virtualenvs.options.system-site-packages`
**Type**: boolean
Give the virtual environment access to the system site-packages directory. Give the virtual environment access to the system site-packages directory.
Applies on virtualenv creation. Applies on virtualenv creation.
Defaults to `false`. Defaults to `false`.
### `repositories.<name>`: string ### `repositories.<name>`
**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.
---
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 %}}
---
title: "Dependency specification"
draft: false
type: docs
layout: single
menu:
docs:
weight: 70
---
# Dependency specification # Dependency specification
Dependencies for a project can be specified in various forms, which depend on the type Dependencies for a project can be specified in various forms, which depend on the type
...@@ -119,10 +130,10 @@ my-package = { path = "../my-package/", develop = false } ...@@ -119,10 +130,10 @@ my-package = { path = "../my-package/", develop = false }
my-package = { path = "../my-package/dist/my-package-0.1.0.tar.gz" } my-package = { path = "../my-package/dist/my-package-0.1.0.tar.gz" }
``` ```
!!!note {{% note %}}
Before poetry 1.1 directory path dependencies were installed in editable mode by default. You should set the `develop` attribute explicitly,
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.
to make sure the behavior is the same for all poetry versions. {{% /note %}}
## `url` dependencies ## `url` dependencies
...@@ -185,10 +196,10 @@ foo = [ ...@@ -185,10 +196,10 @@ foo = [
] ]
``` ```
!!!note {{% note %}}
The constraints **must** have different requirements (like `python`)
The constraints **must** have different requirements (like `python`) otherwise it will cause an error when resolving dependencies.
otherwise it will cause an error when resolving dependencies. {{% /note %}}
## Expanded dependency specification syntax ## Expanded dependency specification syntax
......
---
title: "FAQ"
draft: false
type: docs
layout: single
menu:
docs:
weight: 110
---
# FAQ # 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 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, 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 ...@@ -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. At the moment there is no way around it.
!!!note {{% note %}}
Once Poetry has cached the releases' information, the dependency resolution process
Once Poetry has cached the releases' information, the dependency resolution process will be much faster.
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. 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. 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 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, 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 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. ...@@ -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`. 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). 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. 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: So, in your `pyproject.toml` file, add this section if it does not already exist:
...@@ -60,7 +71,7 @@ commands = ...@@ -60,7 +71,7 @@ commands =
poetry run pytest tests/ 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 While Poetry automatically creates virtual environments to always work isolated
from the global Python installation, there are valid reasons why it's not necessary from the global Python installation, there are valid reasons why it's not necessary
......
---
title: "Libraries"
draft: false
type: docs
layout: "docs"
menu:
docs:
weight: 20
---
# Libraries # Libraries
This chapter will tell you how to make your library installable through Poetry. This chapter will tell you how to make your library installable through Poetry.
...@@ -9,7 +21,7 @@ While Poetry does not enforce any convention regarding package versioning, ...@@ -9,7 +21,7 @@ While Poetry does not enforce any convention regarding package versioning,
it **strongly** recommends to follow [semantic versioning](https://semver.org). it **strongly** recommends to follow [semantic versioning](https://semver.org).
This has many advantages for the end users and allows them to set appropriate 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 ## Lock file
...@@ -49,14 +61,14 @@ poetry publish ...@@ -49,14 +61,14 @@ poetry publish
``` ```
This will package and publish the library to PyPI, at the condition that you are a registered user 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. and you have [configured your credentials]({{< relref "repositories#configuring-credentials" >}}) properly.
!!!note
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, If you want to build and publish your packages together,
just pass the `--build` option. just pass the `--build` option.
{{% /note %}}
Once this is done, your library will be available to anyone. Once this is done, your library will be available to anyone.
...@@ -68,7 +80,7 @@ Sometimes, you may want to keep your library private but also being accessible t ...@@ -68,7 +80,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 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 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. for more information.
Once this is done, you can actually publish to it like so: Once this is done, you can actually publish to it like so:
......
---
title: "Managing environments"
draft: false
type: docs
layout: "docs"
menu:
docs:
weight: 60
---
# Managing environments # Managing environments
Poetry makes project environment isolation one of its core features. 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 ...@@ -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 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). to activate one explicitly, see [Switching environments](#switching-between-environments).
!!!note {{% note %}}
To easily switch between Python versions, it is recommended to
To easily switch between Python versions, it is recommended to use [pyenv](https://github.com/pyenv/pyenv) or similar tools.
use [pyenv](https://github.com/pyenv/pyenv) or similar tools.
For instance, if your project is Python 2.7 only, a standard workflow For instance, if your project is Python 2.7 only, a standard workflow
would be: would be:
```bash ```bash
pyenv install 2.7.15 pyenv install 2.7.15
pyenv local 2.7.15 # Activate Python 2.7 for the current project pyenv local 2.7.15 # Activate Python 2.7 for the current project
poetry install poetry install
``` ```
{{% /note %}}
## Switching between environments ## Switching between environments
......
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
- Plugins: plugins.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
---
title: "Plugins"
draft: false
type: docs
layout: single
menu:
docs:
weight: 80
---
# Plugins # Plugins
Poetry supports using and building plugins if you wish to Poetry supports using and building plugins if you wish to
...@@ -18,7 +29,7 @@ and may also depend on further packages. ...@@ -18,7 +29,7 @@ and may also depend on further packages.
### Plugin package ### Plugin package
The plugin package must depend on Poetry The plugin package must depend on Poetry
and declare a proper [plugin](/docs/pyproject/#plugins) in the `pyproject.toml` file. and declare a proper [plugin]({{< relref "pyproject#plugins" >}}) in the `pyproject.toml` file.
```toml ```toml
[tool.poetry] [tool.poetry]
...@@ -96,19 +107,19 @@ class MyApplicationPlugin(ApplicationPlugin): ...@@ -96,19 +107,19 @@ class MyApplicationPlugin(ApplicationPlugin):
application.command_loader.register_factory("my-command", factory) application.command_loader.register_factory("my-command", factory)
``` ```
!!!note {{% note %}}
It's possible to do the following to register the command:
It's possible to do the following to register the command:
```python ```python
application.add(MyCommand()) application.add(MyCommand())
``` ```
However, it is **strongly** recommended to register a new factory However, it is **strongly** recommended to register a new factory
in the command loader to defer the loading of the command when it's actually in the command loader to defer the loading of the command when it's actually
called. called.
This will help keep the performances of Poetry good. This will help keep the performances of Poetry good.
{{% /note %}}
The plugin also must be declared in the `pyproject.toml` file of the plugin package The plugin also must be declared in the `pyproject.toml` file of the plugin package
as an `application.plugin` plugin: as an `application.plugin` plugin:
...@@ -118,9 +129,9 @@ as an `application.plugin` plugin: ...@@ -118,9 +129,9 @@ as an `application.plugin` plugin:
foo-command = "poetry_demo_plugin.plugin:MyApplicationPlugin" foo-command = "poetry_demo_plugin.plugin:MyApplicationPlugin"
``` ```
!!!warning {{% warning %}}
A plugin **must not** remove or modify in any way the core commands of Poetry.
A plugin **must not** remove or modify in any way the core commands of Poetry. {{% /warning %}}
### Event handler ### Event handler
...@@ -152,10 +163,15 @@ from poetry.plugins.application_plugin import ApplicationPlugin ...@@ -152,10 +163,15 @@ from poetry.plugins.application_plugin import ApplicationPlugin
class MyApplicationPlugin(ApplicationPlugin): class MyApplicationPlugin(ApplicationPlugin):
def activate(self, application: Application): def activate(self, application: Application):
application.event_dispatcher.add_listener(COMMAND, self.load_dotenv) application.event_dispatcher.add_listener(
COMMAND, self.load_dotenv
)
def load_dotenv( def load_dotenv(
self, event: ConsoleCommandEvent, event_name: str, dispatcher: EventDispatcher self,
event: ConsoleCommandEvent,
event_name: str,
dispatcher: EventDispatcher
) -> None: ) -> None:
command = event.command command = event.command
if not isinstance(command, EnvCommand): if not isinstance(command, EnvCommand):
...@@ -164,7 +180,9 @@ class MyApplicationPlugin(ApplicationPlugin): ...@@ -164,7 +180,9 @@ class MyApplicationPlugin(ApplicationPlugin):
io = event.io io = event.io
if io.is_debug(): if io.is_debug():
io.write_line("<debug>Loading environment variables.</debug>") io.write_line(
"<debug>Loading environment variables.</debug>"
)
load_dotenv() load_dotenv()
``` ```
...@@ -188,7 +206,7 @@ The `plugin add` command will ensure that the plugin is compatible with the curr ...@@ -188,7 +206,7 @@ The `plugin add` command will ensure that the plugin is compatible with the curr
and install the needed packages for the plugin to work. and install the needed packages for the plugin to work.
The package specification formats supported by the `plugin add` command are the same as the ones supported The package specification formats supported by the `plugin add` command are the same as the ones supported
by the [`add` command](/docs/cli/#add). by the [`add` command]({{< relref "cli#add" >}}).
If you no longer need a plugin and want to uninstall it, you can use the `plugin remove` command. If you no longer need a plugin and want to uninstall it, you can use the `plugin remove` command.
......
---
title: "The pyproject.toml file"
draft: false
type: docs
layout: single
menu:
docs:
weight: 90
---
# The `pyproject.toml` file # The `pyproject.toml` file
The `tool.poetry` section of the `pyproject.toml` file is composed of multiple sections. 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): ...@@ -40,9 +51,9 @@ The recommended notation for the most common licenses is (alphabetical):
Optional, but it is highly recommended to supply this. Optional, but it is highly recommended to supply this.
More identifiers are listed at the [SPDX Open Source License Registry](https://spdx.org/licenses/). More identifiers are listed at the [SPDX Open Source License Registry](https://spdx.org/licenses/).
!!!note {{% note %}}
If your project is proprietary and does not use a specific licence, you can set this value as `Proprietary`.
If your project is proprietary and does not use a specific licence, you can set this value as `Proprietary`. {{% /note %}}
## authors ## authors
...@@ -91,11 +102,11 @@ classifiers = [ ...@@ -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.
{{% /note %}}
The `license` property will also set the License classifier automatically.
## packages ## packages
...@@ -137,26 +148,26 @@ packages = [ ...@@ -137,26 +148,26 @@ packages = [
From now on, only the `sdist` build archive will include the `my_other_package` package. From now on, only the `sdist` build archive will include the `my_other_package` package.
!!!note {{% note %}}
Using `packages` disables the package auto-detection feature meaning you have to
Using `packages` disables the package auto-detection feature meaning you have to **explicitly** specify the "default" package.
**explicitly** specify the "default" package.
For instance, if you have a package named `my_package` and you want to also include 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: another package named `extra_package`, you will need to specify `my_package` explicitly:
```toml ```toml
packages = [ packages = [
{ include = "my_package" }, { include = "my_package" },
{ include = "extra_package" }, { include = "extra_package" },
] ]
``` ```
{{% /note %}}
!!!note
Poetry is clever enough to detect Python subpackages. {{% note %}}
Poetry is clever enough to detect Python subpackages.
Thus, you only have to specify the directory where your root package resides. Thus, you only have to specify the directory where your root package resides.
{{% /note %}}
## include and exclude ## include and exclude
...@@ -208,15 +219,15 @@ name = 'private' ...@@ -208,15 +219,15 @@ name = 'private'
url = 'http://example.com/simple' url = 'http://example.com/simple'
``` ```
!!!note {{% note %}}
Be aware that declaring the python version for which your package
Be aware that declaring the python version for which your package is compatible is mandatory:
is compatible is mandatory:
```toml ```toml
[tool.poetry.dependencies] [tool.poetry.dependencies]
python = "^3.6" python = "^3.6"
``` ```
{{% /note %}}
## `scripts` ## `scripts`
...@@ -229,9 +240,9 @@ poetry = 'poetry.console:run' ...@@ -229,9 +240,9 @@ poetry = 'poetry.console:run'
Here, we will have the `poetry` script installed which will execute `console.run` in the `poetry` package. Here, we will have the `poetry` script installed which will execute `console.run` in the `poetry` package.
!!!note {{% note %}}
When a script is added or updated, run `poetry install` to make them available in the project's virtualenv.
When a script is added or updated, run `poetry install` to make them available in the project's virtualenv. {{% /note %}}
## `extras` ## `extras`
...@@ -276,10 +287,11 @@ the `databases` extra can be installed as shown below. ...@@ -276,10 +287,11 @@ the `databases` extra can be installed as shown below.
pip install awesome[databases] pip install awesome[databases]
``` ```
!!!note {{% note %}}
The dependencies specified for each `extra` must already be defined as project dependencies.
The dependencies specified for each `extra` must already be defined as project dependencies. Dependencies listed in the `dev-dependencies` section cannot be specified as extras.
Dependencies listed in the `dev-dependencies` section cannot be specified as extras. {{% /note %}}
## `plugins` ## `plugins`
...@@ -322,12 +334,11 @@ requires = ["poetry-core>=1.0.0"] ...@@ -322,12 +334,11 @@ requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api" build-backend = "poetry.core.masonry.api"
``` ```
!!!note {{% note %}}
When using the `new` or `init` command this section will be automatically added.
When using the `new` or `init` command this section will be automatically added. {{% /note %}}
!!!note
If your `pyproject.toml` file still references `poetry` directly as a build backend, {{% note %}}
you should update it to reference `poetry-core` instead. If your `pyproject.toml` file still references `poetry` directly as a build backend,
you should update it to reference `poetry-core` instead.
{{% /note %}}
---
title: "Repositories"
draft: false
type: docs
layout: "docs"
menu:
docs:
weight: 50
---
# Repositories # Repositories
## Using the PyPI repository ## Using the PyPI repository
...@@ -37,24 +48,25 @@ poetry config http-basic.foo username password ...@@ -37,24 +48,25 @@ poetry config http-basic.foo username password
If you do not specify the password you will be prompted to write it. 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) ```bash
when uploading packages to PyPI. poetry config pypi-token.pypi my-token
Once you have created a new token, you can tell Poetry to use it: ```
```bash If you still want to use your username and password, you can do so with the following
poetry config pypi-token.pypi my-token call to `config`.
```
If you still want to use your username and password, you can do so with the following ```bash
call to `config`. poetry config http-basic.pypi username password
```
{{% /note %}}
```bash
poetry config http-basic.pypi username password
```
You can also specify the username and password when using the `publish` command You can also specify the username and password when using the `publish` command
with the `--username` and `--password` options. with the `--username` and `--password` options.
...@@ -63,20 +75,20 @@ If a system keyring is available and supported, the password is stored to and re ...@@ -63,20 +75,20 @@ If a system keyring is available and supported, the password is stored to and re
Keyring support is enabled using the [keyring library](https://pypi.org/project/keyring/). For more information on supported backends refer to the [library documentation](https://keyring.readthedocs.io/en/latest/?badge=latest). Keyring support is enabled using the [keyring library](https://pypi.org/project/keyring/). For more information on supported backends refer to the [library documentation](https://keyring.readthedocs.io/en/latest/?badge=latest).
!!!note {{% note %}}
Poetry will fallback to Pip style use of keyring so that backends like
Microsoft's [artifacts-keyring](https://pypi.org/project/artifacts-keyring/) get a change to retrieve
valid credentials. It will need to be properly installed into Poetry's virtualenv,
preferrably by installing a plugin.
``` If you are letting Poetry manage your virtual environments you will want a virtualenv
Poetry will fallback to Pip style use of keyring so that backends like seeder installed in Poetry's virtualenv that installs the desired keyring backend
Microsoft's [artifacts-keyring](https://pypi.org/project/artifacts-keyring/) get a change to retrieve during `poetry install`. To again use Azure DevOps as an example: [azure-devops-artifacts-helpers](https://pypi.org/project/azure-devops-artifacts-helpers/)
valid credentials. It will need to be properly installed into Poetry's virtualenv, provides such a seeder. This would of course best achieved by installing a Poetry plugin
preferrably by installing a plugin. if it exists for you use case instead of doing it yourself.
If you are letting Poetry manage your virtual environments you will want a virtualenv {{% /note %}}
seeder installed in Poetry's virtualenv that installs the desired keyring backend
during `poetry install`. To again use Azure DevOps as an example: [azure-devops-artifacts-helpers](https://pypi.org/project/azure-devops-artifacts-helpers/)
provides such a seeder. This would of course best achieved by installing a Poetry plugin
if it exists for you use case instead of doing it yourself.
```
Alternatively, you can use environment variables to provide the credentials: Alternatively, you can use environment variables to provide the credentials:
...@@ -86,7 +98,7 @@ export POETRY_HTTP_BASIC_PYPI_USERNAME=username ...@@ -86,7 +98,7 @@ export POETRY_HTTP_BASIC_PYPI_USERNAME=username
export POETRY_HTTP_BASIC_PYPI_PASSWORD=password 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. on how to configure Poetry with environment variables.
#### Custom certificate authority and mutual TLS authentication #### Custom certificate authority and mutual TLS authentication
...@@ -94,9 +106,10 @@ Poetry supports repositories that are secured by a custom certificate authority ...@@ -94,9 +106,10 @@ Poetry supports repositories that are secured by a custom certificate authority
certificate-based client authentication. The following will configure the "foo" repository to validate the repository's 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 certificate using a custom certificate authority and use a client certificate (note that these config variables do not
both need to be set): both need to be set):
```bash ```bash
poetry config certificates.foo.cert /path/to/ca.pem poetry config certificates.foo.cert /path/to/ca.pem
poetry config certificates.foo.client-cert /path/to/client.pem poetry config certificates.foo.client-cert /path/to/client.pem
``` ```
### Install dependencies from a private repository ### Install dependencies from a private repository
...@@ -114,19 +127,19 @@ url = "https://foo.bar/simple/" ...@@ -114,19 +127,19 @@ url = "https://foo.bar/simple/"
From now on, Poetry will also look for packages in your private repository. From now on, Poetry will also look for packages in your private repository.
!!!note {{% note %}}
Any custom repository will have precedence over PyPI.
Any custom repository will have precedence over PyPI.
If you still want PyPI to be your primary source for your packages If you still want PyPI to be your primary source for your packages
you can declare custom repositories as secondary. you can declare custom repositories as secondary.
```toml ```toml
[[tool.poetry.source]] [[tool.poetry.source]]
name = "foo" name = "foo"
url = "https://foo.bar/simple/" url = "https://foo.bar/simple/"
secondary = true secondary = true
``` ```
{{% /note %}}
If your private repository requires HTTP Basic Auth be sure to add the username and 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 password to your `http-basic` configuration using the example above (be sure to use the
......
---
layout: documentation
title: {{ page.title|striptags|e }}
---
<section class="p-b-50 p-t-50 documentation-content">
<div class="container">
<div class="panel panel-transparent">
<div class="row p-l-20 p-r-20 p-b-20 p-t-5 xs-no-padding">
<div class="row">
<div class="col-md-3 documentation-toc">
<ul class="current">
{% set navlevel = 1 %}
{% for nav_item in nav %}
<li class="toctree-l{{ navlevel }}{% if nav_item.active and not nav_item.children %} current{%endif%}">
{% include 'nav.html' %}
</li>
{% endfor %}
</ul>
</div>
<div class="col-md-9 documentation-body">
{{page.content}}
</div>
</div>
</div>
</div>
</div>
</section>
<a class="{% if nav_item.active%}current{%endif%}" href="{{ base_url }}/{{ nav_item.url }}">{{ nav_item.title }}</a>
{%- if nav_item == page or nav_item.children %}
<ul class="subnav">
{%- if nav_item == page %}
{% include 'toc.html' %}
{%- endif %}
{%- if nav_item.children %}
{%- set navlevel = navlevel + 1%}
{%- for nav_item in nav_item.children %}
<li class="{% if navlevel > 2 %}toctree-l{{ navlevel }}{% endif %}{% if nav_item.active%} current{%endif%}">
{% include 'nav.html' %}
</li>
{%- endfor %}
{%- set navlevel = navlevel - 1%}
{%- endif %}
</ul>
{%- endif %}
{% for toc_item in page.toc %}
<!--<li class="toctree-l{{ navlevel + 1 }}"><a href="{{ toc_item.url }}">{{ toc_item.title }}</a></li>-->
{% if toc_item.children %}
<ul>
{% for toc_item in toc_item.children %}
<li><a class="toctree-l{{ navlevel + 2 }}" href="{{ toc_item.url }}">{{ toc_item.title }}</a></li>
{% endfor %}
</ul>
{% endif %}
{% endfor %}
...@@ -449,6 +449,33 @@ class Installer: ...@@ -449,6 +449,33 @@ class Installer:
break break
def _is_supported(x):
mx = self.VERSION_REGEX.match(x)
vx = tuple(int(p) for p in mx.groups()[:3]) + (mx.group(5),)
return vx < (1, 2, 0)
if not _is_supported(version):
print(
colorize(
"error",
"Version {version} does not support this installation method. Please specify a version prior to "
"1.2.0a1 explicitly using the '--version' option.\n"
"Please see "
"https://python-poetry.org/blog/announcing-poetry-1-2-0a1.html#deprecation-of-the-get-poetry-py-script "
"for more information.".format(version=version),
)
)
return None, None
print(
colorize(
"warning",
"This installer is deprecated. "
"Poetry versions installed using this script will not be able to use 'self update' command to upgrade to "
"1.2.0a1 or later.",
)
)
current_version = None current_version = None
if os.path.exists(POETRY_LIB): if os.path.exists(POETRY_LIB):
with open( with open(
...@@ -824,7 +851,7 @@ class Installer: ...@@ -824,7 +851,7 @@ class Installer:
HWND_BROADCAST, HWND_BROADCAST,
WM_SETTINGCHANGE, WM_SETTINGCHANGE,
0, 0,
u"Environment", "Environment",
SMTO_ABORTIFHUNG, SMTO_ABORTIFHUNG,
5000, 5000,
ctypes.byref(result), ctypes.byref(result),
......
...@@ -413,6 +413,29 @@ class Installer: ...@@ -413,6 +413,29 @@ class Installer:
self.display_pre_message() self.display_pre_message()
self.ensure_directories() self.ensure_directories()
def _is_self_upgrade_supported(x):
mx = self.VERSION_REGEX.match(x)
if mx is None:
# the version is not semver, perhaps scm or file, we assume upgrade is supported
return True
vx = tuple(int(p) for p in mx.groups()[:3]) + (mx.group(5),)
return vx >= (1, 2, 0)
if version and not _is_self_upgrade_supported(version):
self._write(
colorize(
"warning",
f"You are installing {version}. When using the current installer, this version does not support "
f"updating using the 'self update' command. Please use 1.2.0a1 or later.",
)
)
if not self._accept_all:
continue_install = input("Do you want to continue? ([y]/n) ") or "y"
if continue_install.lower() in {"n", "no"}:
return 0
try: try:
self.install(version) self.install(version)
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
......
...@@ -8,15 +8,3 @@ whitelist_externals = poetry ...@@ -8,15 +8,3 @@ whitelist_externals = poetry
commands = commands =
poetry install -vv --no-root poetry install -vv --no-root
poetry run pytest {posargs} tests/ 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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment