From 0b73c06ae99264a8d7d6801415941ee6c2bde9ab Mon Sep 17 00:00:00 2001 From: Arun Babu Neelicattu Date: Thu, 25 Mar 2021 22:06:49 +0100 Subject: [PATCH 1/3] pip installer: fix installed script executable --- poetry/utils/pip.py | 31 ++++++++++++++++++++--------- tests/installation/test_executor.py | 2 +- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/poetry/utils/pip.py b/poetry/utils/pip.py index 1c182e46708..a4929709105 100644 --- a/poetry/utils/pip.py +++ b/poetry/utils/pip.py @@ -1,8 +1,12 @@ +import os +import sys + from pathlib import Path from typing import Union from poetry.exceptions import PoetryException from poetry.utils.env import Env +from poetry.utils.env import EnvCommandError from poetry.utils.env import ephemeral_environment @@ -14,9 +18,13 @@ def pip_install( upgrade: bool = False, ) -> Union[int, str]: path = Path(path) if isinstance(path, str) else path + is_wheel = path.suffix == ".whl" args = ["install", "--prefix", str(environment.path)] + if not is_wheel: + args.insert(1, "--use-pep517") + if upgrade: args.append("--upgrade") @@ -32,16 +40,21 @@ def pip_install( args.append(str(path)) - if path.is_file() and path.suffix == ".whl": + try: return environment.run_pip(*args) - - with ephemeral_environment( - executable=environment.python, pip=True, setuptools=True - ) as env: - return env.run( - "pip", - *args, - ) + except EnvCommandError as e: + if sys.version_info < (3, 7) and not is_wheel: + # Under certain Python3.6 installs vendored pip wheel does not contain zip-safe + # pep517 lib. In this cases we create an isolated ephemeral virtual environment. + with ephemeral_environment( + executable=environment.python, pip=True, setuptools=True + ) as env: + return environment.run( + env._bin("pip"), + *args, + env={**os.environ, "PYTHONPATH": str(env.purelib)}, + ) + raise PoetryException(f"Failed to install {path.as_posix()}") from e def pip_editable_install(directory: Path, environment: Env) -> Union[int, str]: diff --git a/tests/installation/test_executor.py b/tests/installation/test_executor.py index 368b72c90f5..4511e770a9d 100644 --- a/tests/installation/test_executor.py +++ b/tests/installation/test_executor.py @@ -137,7 +137,7 @@ def test_execute_executes_a_batch_of_operations( expected = set(expected.splitlines()) output = set(io.fetch_output().splitlines()) assert expected == output - assert 4 == len(env.executed) + assert 5 == len(env.executed) assert 0 == return_code pip_editable_install.assert_called_once() From 5fe6bafd2004fc6e5f95dbd5e040e0c64a84ad5a Mon Sep 17 00:00:00 2001 From: Arun Babu Neelicattu Date: Thu, 25 Mar 2021 23:10:33 +0100 Subject: [PATCH 2/3] ci: turn off fail fast --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c1eb33fe187..07475596c09 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -23,6 +23,7 @@ jobs: matrix: os: [Ubuntu, MacOS, Windows] python-version: [3.6, 3.7, 3.8, 3.9] + fail-fast: false steps: - uses: actions/checkout@v2 From af6ffc95e65a6502e5d80a38596a601b35c85ec2 Mon Sep 17 00:00:00 2001 From: Arun Babu Neelicattu Date: Thu, 25 Mar 2021 23:15:19 +0100 Subject: [PATCH 3/3] deps: update virtualenv to 20.4.3 --- poetry.lock | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/poetry.lock b/poetry.lock index dd00e3385b6..fb8897009e2 100644 --- a/poetry.lock +++ b/poetry.lock @@ -697,7 +697,7 @@ testing = ["pytest (>=4.6)", "pytest-checkdocs (>=1.2.3)", "pytest-flake8", "pyt [metadata] lock-version = "1.1" python-versions = "^3.6" -content-hash = "fa762bec451ef26021b1882a6f657ca2c0b3eeff514e28f805dfa7dfc1a02495" +content-hash = "6cbc07e5853bcf1280421b77b6fca85f2f7eb5a6ff12049f65ea116b256d94ea" [metadata.files] appdirs = [ diff --git a/pyproject.toml b/pyproject.toml index bd2dd612dec..a487a789dbf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,7 +40,7 @@ shellingham = "^1.1" tomlkit = ">=0.7.0,<1.0.0" pexpect = "^4.7.0" packaging = "^20.4" -virtualenv = { version = "^20.0.26" } +virtualenv = "^20.4.3" keyring = "^21.2.0" importlib-metadata = {version = "^1.6.0", python = "<3.8"}