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

install-poetry.py: Use new official install location #15

Merged
merged 1 commit into from
Nov 27, 2021

Conversation

tony
Copy link
Contributor

@tony tony commented Nov 25, 2021

This operates independently of poetry releases so it can pull
bugfixes merged outside of poetry's own release cadence.

Error:
ModuleNotFoundError: No module named 'cleo'

Versions: Python 3.10 and poetry 1.1.7 - 1.1.11

See also:

In conjunction with #14 this gets python 3.10 working with poetry
1.1.11 where ModuleNotFoundError: No module named 'cleo' was raised.

Copy link
Contributor

@Kurt-von-Laven Kurt-von-Laven left a comment

Choose a reason for hiding this comment

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

I am not affiliated with asdf, asdf-poetry, or Poetry, but this looks good to me.

@tony
Copy link
Contributor Author

tony commented Nov 25, 2021

Additionally I've been using this script installation method on a production website (with poetry 1.11.0). I can confirm this works on 1.1.9 and above - technically 1.1.7 - 1.1.8 would too but it has some bugs that are only resolved via poetry package itself.

@crflynn
Copy link
Member

crflynn commented Nov 26, 2021

I'm currently testing locally with the following code, combining #14 and #15 as you suggest.

install_poetry() {
  local install_type=$1
  local version=$2
  local install_path=$3

  # Ensure the installer will work even if the user has the
  # PIP_REQUIRE_VIRTUALENV variable set. Can be removed after this issue is
  # resolved: https://github.com/python-poetry/poetry/issues/4089
  unset PIP_REQUIRE_VIRTUALENV

  if [ "$install_type" != "version" ]; then
    fail "asdf-poetry supports release installs only"
  fi

  semver_ge "$ASDF_INSTALL_VERSION" 1.1.9 && vercomp="ge" || vercomp="lt"

  if [ $vercomp == "ge" ]; then
    install_url="https://install.python-poetry.org/install-poetry.py"
    curl -sSL "$install_url" | POETRY_HOME=$install_path python3 - --version "$version"
  else
    install_url="https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py"
    curl -sSL "$install_url" | POETRY_HOME=$install_path python3 - --version "$version" --no-modify-path
  fi
}

install_poetry "$ASDF_INSTALL_TYPE" "$ASDF_INSTALL_VERSION" "$ASDF_INSTALL_PATH"

I have an empty example project in which I'm testing the changes, but it doesn't appear to solve the issue in #10. Here is what I'm running:

flynn@MBP ~/projects/poetrytesting
% asdf local python 3.10.0
flynn@MBP ~/projects/poetrytesting
% asdf uninstall poetry 1.1.9
flynn@MBP ~/projects/poetrytesting
% asdf install poetry 1.1.9
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:

/Users/flynn/.asdf/installs/poetry/1.1.9/bin

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

     Installing Poetry (1.1.9): Installing Poetry
Installing Poetry (1.1.9): Done

Poetry (1.1.9) is installed now. Great!

To get started you need Poetry's bin directory (/Users/flynn/.asdf/installs/poetry/1.1.9/bin) in your `PATH`
environment variable.

Add `export PATH="/Users/flynn/.asdf/installs/poetry/1.1.9/bin:$PATH"` to your shell configuration file.

Alternatively, you can call Poetry explicitly with `/Users/flynn/.asdf/installs/poetry/1.1.9/bin/poetry`.

You can test that everything is set up by executing:

`poetry --version`

flynn@MBP ~/projects/poetrytesting
% asdf local poetry 1.1.9
flynn@MBP ~/projects/poetrytesting
% asdf local python 3.9.5
flynn@MBP ~/projects/poetrytesting
% rm -rf .venv
flynn@MBP ~/projects/poetrytesting
% poetry run python -V
Creating virtualenv poetrytesting in /Users/flynn/projects/poetrytesting/.venv
Python 3.10.0

For the last few commands I expect the output to be python 3.9.5, since that is what is indicated locally in .tool-versions, but it's creating the environment with python 3.10.0, the version which was active when poetry was installed.

I haven't really explored the newest (extracted) installer. Is part of the intent to resolve this issue in particular or just to decouple the installer from the poetry repo? It appears to be working the same just from a different location.

Copy link
Member

@crflynn crflynn left a comment

Choose a reason for hiding this comment

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

We can merge this with this change since it seems to be the new url for the new installer. Unfortunately it does not resolve #10

bin/install Outdated Show resolved Hide resolved
This operates independently of poetry releases so it can pull
bugfixes merged outside of poetry's own release cadence.

See also:
- https://github.com/python-poetry/install.python-poetry.org
- python-poetry/poetry#3345 (comment)

In conjunction with asdf-community#14 this gets python 3.10 working with poetry
1.1.11 where ModuleNotFoundError: No module named 'cleo' was raised.
@tony
Copy link
Contributor Author

tony commented Nov 27, 2021

@crflynn Updated to the URL specified (via squashing)

Is part of the intent to resolve this issue in particular or just to decouple the installer from the poetry repo? It appears to be working the same just from a different location.

It's decoupled from the poetry repo, just the new URL.

But the reason why I claimed it'd be potentially related comments around this: python-poetry/poetry#3345 (comment)

@crflynn crflynn merged commit 216e18d into asdf-community:master Nov 27, 2021
@Kurt-von-Laven
Copy link
Contributor

Kurt-von-Laven commented Nov 27, 2021

The key point from the Poetry maintainer, and I believe the reason @crflynn experienced no joy, is that the needed patches have been merged to master, but not yet released. See python-poetry/poetry#3345. I agree that it was wise to update the install URL based on guidance provided by said Poetry maintainer.

@tony tony deleted the tn-official-installer branch November 27, 2021 04:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants