Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a new bootstrapping method #3706

Merged
merged 7 commits into from
Mar 30, 2021
Merged

Implement a new bootstrapping method #3706

merged 7 commits into from
Mar 30, 2021

Conversation

sdispater
Copy link
Member

@sdispater sdispater commented Feb 19, 2021

This method introduces a new script install-poetry.py which implements a new way to bootstrap Poetry. The advantages of this new method are:

  • It no longer relies on the prebuilt release packages of Poetry (see https://github.com/python-poetry/poetry/releases/tag/1.1.4 for an example) which had the issues of having frozen dependencies which made upgrading dependencies much harder without releasing a new bug fix release of Poetry. This will eventually make our release process easier.
  • It relies on standards for the install locations of both Poetry and the poetry script.
  • It supports installing from a git repository or a file/directory.
  • It no longer tries to modify the PATH but instead will just provide guidance on how to do it if necessary.
  • It will use the correct Python interpreter, i.e. the one used to invoke the script, when calling the poetry script.

As to what the script actually does:

  • Downloads the virtualenv package to a temporary directory and add it to sys.path.
  • Creates a virtual environment in the correct OS data dir which will be
    • %APPDATA%\\pypoetry on Windows
    • ~/Library/Application Support/pypoetry on MacOS
    • ${XDG_DATA_HOME}/pypoetry (or ~/.local/share/pypoetry if it's not set) on UNIX systems
    • In ${POETRY_HOME} if it's set.
  • Installs the latest or given version of Poetry inside this virtual environment.
  • Installs a poetry script in the Python user directory (or ${POETRY_HOME/bin} if POETRY_HOME is set).

Resolves: #3534
Resolves: #2030
Resolves: #3819
Resolves: #3828
Resolves: #3187

Pull Request Check List

  • Added tests for changed code.
  • Updated documentation for changed code.

@sdispater sdispater requested a review from a team February 19, 2021 15:23
@abn abn self-requested a review February 19, 2021 16:35
@sdispater sdispater force-pushed the better-bootstrapping branch 4 times, most recently from e2d63d0 to 43db06d Compare February 19, 2021 16:57
docs/docs/index.md Outdated Show resolved Hide resolved
install-poetry.py Show resolved Hide resolved
install-poetry.py Show resolved Hide resolved
install-poetry.py Show resolved Hide resolved
install-poetry.py Show resolved Hide resolved
install-poetry.py Outdated Show resolved Hide resolved
.github/workflows/main.yml Show resolved Hide resolved
docs/docs/index.md Outdated Show resolved Hide resolved
install-poetry.py Show resolved Hide resolved
@sdispater sdispater force-pushed the better-bootstrapping branch 2 times, most recently from 3a80f16 to 8a506ec Compare March 19, 2021 20:52
Copy link
Member

@abn abn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Over all looks great. Couple of suggestions.

One comment on the virtual environment creation options to ensure some resilience for the installation. Otherwise good to go.

.github/workflows/main.yml Show resolved Hide resolved
@@ -17,42 +17,76 @@ The [complete documentation](https://python-poetry.org/docs/) is available on th
## Installation

Poetry provides a custom installer that will install `poetry` isolated
from the rest of your system by vendorizing its dependencies. This is the
recommended way of installing `poetry`.
from the rest of your system.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a blocker, but should we link to our documentation here instead of maintaining duplication information here? Might be good for the brevity of the README as well.

install-poetry.py Show resolved Hide resolved
install-poetry.py Show resolved Hide resolved
@naveen521kk
Copy link

naveen521kk commented Mar 21, 2021

I tried this script and it failed

C:\Users\User> (Invoke-WebRequest -Uri https://raw.githubusercontent.com/python-poetry/poetry/8a506eceb90e7b7d1bc1cd837d303c32e8b03bec/install-poetry.py
-UseBasicParsing).Content | python -
Retrieving Poetry metadata

# Welcome to Poetry!

This will download and install the latest version of Poetry,
a dependency and package manager for Python.

It will add the `poetry` command to Poetry's bin directory, located at:

C:\Users\User\AppData\Roaming\Python\Scripts

You can uninstall at any time by executing this script with the --uninstall opti
on,
and these changes will be reverted.

Installing Poetry (1.1.5)
Installing Poetry (1.1.5): Creating environment
Traceback (most recent call last):
  File "<stdin>", line 808, in <module>
  File "<stdin>", line 804, in main
  File "<stdin>", line 417, in run
  File "<stdin>", line 439, in install
  File "<stdin>", line 503, in make_env
ModuleNotFoundError: No module named 'virtualenv'

It's a fresh install of Python 3.8 if that matters, it doesn't even have pip installed.

EDIT: installing pip fixed that.

install-poetry.py Show resolved Hide resolved
abn
abn previously approved these changes Mar 27, 2021
Copy link
Member

@abn abn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spun out the improvement regarding virtualenv bootstrapping to https://github.com/python-poetry/poetry/issues/3843

Otherwise looks good to me.

@abn
Copy link
Member

abn commented Mar 27, 2021

@sdispater this should be good to go after a rebase and conflict resolution.

@abn abn merged commit e359ba5 into master Mar 30, 2021
@abn abn deleted the better-bootstrapping branch March 30, 2021 01:22
@sdispater sdispater mentioned this pull request Apr 23, 2021
br3ndonland added a commit to br3ndonland/inboard that referenced this pull request Jul 5, 2021
python-poetry/poetry#3706
python-poetry/poetry#3870
python-poetry/poetry#4056

Poetry has a new install script, added in python-poetry/poetry#3706.
The old get-poetry.py install script is not compatible with Python 3.10,
so the new install-poetry.py script will be used.

Docker builds and GitHub Actions workflows will be updated to use
`POETRY_HOME=/opt/poetry` consistently.

As of Poetry 1.1.7, there may be complications in Docker when using
install-poetry.py without venvs (`POETRY_VIRTUALENVS_CREATE=false`).
While installing dependencies, the following error is frequently seen:

```text
OSError

Could not find a suitable TLS CA certificate bundle, invalid path:
/opt/poetry/venv/lib/python3.9/site-packages/certifi/cacert.pem

at /opt/poetry/venv/lib/python3.9/site-packages/requests/adapters.py:227
in cert_verify
```

Poetry may be incorrectly attempting to read from its virtualenv if it's
not respecting `POETRY_VIRTUALENVS_CREATE` (python-poetry/poetry#3870).
Downstream steps also do not respect `POETRY_VIRTUALENVS_CREATE`, so the
application does not run.
br3ndonland added a commit to br3ndonland/dotfiles that referenced this pull request Jul 5, 2021
python-poetry/poetry#3706

Poetry has a new install script, install-poetry.py, which alters the
requirements for adding Poetry to `$PATH`. One simple way to add Poetry
to `$PATH` is to `export PATH=$HOME/.local/bin:$PATH`, which adds the
~/.local/bin directory (it's also used by pipx, so it's a good option)
to `$PATH`, then `export POETRY_HOME=$HOME/.local`, which tells Poetry
to install itself into the ~/.local/bin directory.
br3ndonland added a commit to br3ndonland/fastenv that referenced this pull request Jul 6, 2021
python-poetry/poetry#3706
python-poetry/poetry#3870
python-poetry/poetry#4056

Poetry has a new install script, added in python-poetry/poetry#3706.
The old get-poetry.py install script is not compatible with Python 3.10.
This commit will update the GitHub Actions workflow to use the new
install-poetry.py script, with `POETRY_HOME=/opt/poetry` for consistent
installs independent of user account, and will also update the workflow
to use a virtualenv and run commands with `poetry run` to avoid issues
with `POETRY_VIRTUALENVS_CREATE=false`.

As of Poetry 1.1.7, there may be complications with install-poetry.py
run without venvs (`POETRY_VIRTUALENVS_CREATE=false`). An error is seen:

```text
OSError

Could not find a suitable TLS CA certificate bundle, invalid path:
/opt/poetry/venv/lib/python3.9/site-packages/certifi/cacert.pem

at /opt/poetry/venv/lib/python3.9/site-packages/requests/adapters.py:227
in cert_verify
```

Poetry may be incorrectly attempting to read from its virtualenv if it's
not respecting `POETRY_VIRTUALENVS_CREATE` (python-poetry/poetry#3870).
Downstream steps also do not respect `POETRY_VIRTUALENVS_CREATE`, so the
application does not run. To avoid these issues, `poetry run` can be
prepended to commands to prompt Poetry to use its virtualenv.

Additionally, Poetry errors out with a `JSONDecodeError` when attempting
to install packages with Python 3.10 (python-poetry/poetry#4210). Python
3.10 support will be postponed until Poetry is compatible.
@ghost ghost mentioned this pull request Oct 14, 2021
2 tasks
davetapley added a commit to JEFuller/pyserde that referenced this pull request Feb 6, 2024
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.