Skip to content

Commit 29a797b

Browse files
docs: added ci recommendations (#6345)
Add some recommendations about how to install Poetry into an CI environment. Co-authored-by: Bjorn Neergaard <bjorn@neersighted.com>
1 parent e3afa5b commit 29a797b

File tree

1 file changed

+73
-1
lines changed

1 file changed

+73
-1
lines changed

docs/_index.md

+73-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ If you are viewing documentation for the development branch, you may wish to ins
2828
See the **advanced** installation instructions to use a preview or alternate version of Poetry.
2929
{{% /note %}}
3030

31-
{{< tabs tabTotal="3" tabID1="installing-with-the-official-installer" tabID2="installing-with-pipx" tabID3="installing-manually" tabName1="With the official installer" tabName2="With pipx" tabName3="Manually (advanced)" >}}
31+
{{< tabs tabTotal="4" tabID1="installing-with-the-official-installer" tabID2="installing-with-pipx" tabID3="installing-manually" tabID4="ci-recommendations" tabName1="With the official installer" tabName2="With pipx" tabName3="Manually (advanced)" tabName4="CI recommendations">}}
3232

3333
{{< tab tabID="installing-with-the-official-installer" >}}
3434

@@ -274,10 +274,82 @@ Poetry will be available at `$VENV_PATH/bin/poetry` and can be invoked directly
274274
275275
To uninstall Poetry, simply delete the entire `$VENV_PATH` directory.
276276
277+
{{< /tab >}}
278+
{{< tab tabID="ci-recommendations" >}}
279+
Unlike development environments, where making use of the latest tools is desirable, in a CI environment reproducibility
280+
should be made the priority. Here are some suggestions for installing Poetry in such an environment.
281+
282+
**Installation method**
283+
284+
The official installer script ([install.python-poetry.org](https://install.python-poetry.org)) offers a streamlined and
285+
simplified installation of Poetry, sufficient for developer use or for simple pipelines. However, in a CI environment
286+
the other two supported installation methods (pipx and manual) should be seriously considered.
287+
288+
**Using install.python-poetry.org**
289+
290+
Downloading a copy of the installer script to a place accessible by your CI pipelines (or maintaining a copy of the
291+
[repository](https://github.com/python-poetry/install.python-poetry.org)) is strongly suggested, to ensure your
292+
pipeline's stability and to maintain control over what code is executed.
293+
294+
By default the installer will install to a user-specific directory. In more complex pipelines that may make accessing
295+
Poetry difficult (especially in cases like multi-stage container builds). It is highly suggested to make use of
296+
`$POETRY_HOME` when using the official installer in CI, as that way the exact paths can be controlled.
297+
298+
```bash
299+
export POETRY_HOME=/opt/poetry
300+
python3 install-poetry.py --version 1.2.0
301+
$POETRY_HOME/bin/poetry --version
302+
```
303+
304+
**Using pipx**
305+
306+
Just as `pipx` is a powerful tool for development use, it is equally useful in a CI environment. It takes the same steps
307+
the installer does to safely install Poetry isolated from the rest of your system, but is generic and able to do this
308+
for any Python package, with a syntax/usage that is similar to `pip`. `pipx` should be considered equally supported in
309+
comparison to the official installer, and should be one of your top choices for use of Poetry in CI.
310+
311+
```
312+
pipx install poetry==1.2.0
313+
```
314+
315+
**Using pip (aka manually)**
316+
317+
For maximum control in your CI environment, installation with `pip` is fully supported and something you should
318+
consider. While this requires more explicit commands and knowledge of Python packaging from you, it in return offers the
319+
best debugging experience, and leaves you subject to the fewest external tools.
320+
321+
```
322+
virtualenv /opt/poetry
323+
/opt/poetry/bin/pip install poetry==1.2.0
324+
/opt/poetry/bin/poetry --version
325+
```
326+
327+
{{% note %}}
328+
If you install Poetry via `pip`, ensure you have Poetry installed into an isolated environment that is **not the same**
329+
as the target environment managed by Poetry. If Poetry and your project are installed into the same environment, Poetry
330+
is likely to upgrade or uninstall its own dependencies (causing hard-to-debug and understand errors).
331+
{{% /note %}}
332+
333+
**Version pinning**
334+
335+
Whatever method you use, it is highly recommended to explicitly control the version of Poetry used, so that you are able
336+
to upgrade after performing your own validation. Each install method has a different syntax for setting the version --
337+
the following are some simple examples:
338+
339+
```bash
340+
curl -sSL https://install.python-poetry.org | python3 - --version 1.2.0
341+
# or
342+
curl -sSL https://install.python-poetry.org | POETRY_VERSION=1.2.0 python3 -
343+
344+
pipx install poetry==1.2.0
345+
346+
/path/to/venv/bin/pip install poetry==1.2.0
347+
```
277348
{{< /tab >}}
278349
{{< /tabs >}}
279350

280351

352+
281353
## Enable tab completion for Bash, Fish, or Zsh
282354

283355
`poetry` supports generating completion scripts for Bash, Fish, and Zsh.

0 commit comments

Comments
 (0)