From 0e629d38996dfe8d989a53ef49eebff9aa6ae8c0 Mon Sep 17 00:00:00 2001 From: Jeremy Fleischman Date: Tue, 16 Aug 2022 01:04:50 -0700 Subject: [PATCH 1/3] Actually filter out missing interpreters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes https://github.com/pypa/pipenv/issues/5261. Before this change, I would get a "The Python interpreter can't be found" error when running `pipenv install --system` with a python3 but no python. Demo: ``` $ docker run $(docker build -q -f Dockerfile.pipenv-2022.8.15 https://github.com/jfly/2022-08-16-pipenv-system-which-issue.git#main) Installing dependencies from Pipfile.lock (63bec0)... The Python interpreter can't be found.▉ 0/4 — 00:00:00 🐍 ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 0/4 — 00:00:00 ``` I'm confident this bug was introduced in https://github.com/pypa/pipenv/commit/f276360dfcef3200908e2c6569567d617919c63d, which removed a usage of `first()`, but broke the "filter None values" behavior that `first()` gave us. --- news/5261.bugfix | 1 + pipenv/utils/shell.py | 1 + 2 files changed, 2 insertions(+) create mode 100644 news/5261.bugfix diff --git a/news/5261.bugfix b/news/5261.bugfix new file mode 100644 index 0000000000..d30c2823cc --- /dev/null +++ b/news/5261.bugfix @@ -0,0 +1 @@ +Fix "The Python interpreter can't be found" error when running `pipenv install --system` with a python3 but no python. diff --git a/pipenv/utils/shell.py b/pipenv/utils/shell.py index 030fb19b2e..362290fae9 100644 --- a/pipenv/utils/shell.py +++ b/pipenv/utils/shell.py @@ -446,6 +446,7 @@ def project_python(project, system=False): python = project._which("python") else: interpreters = [system_which(p) for p in ("python", "python3")] + interpreters = [i for i in interpreters if i] # filter out not found interpreters python = interpreters[0] if interpreters else None if not python: click.secho("The Python interpreter can't be found.", fg="red", err=True) From d06a811a24626f88de26596a4fb0aad4496c0f78 Mon Sep 17 00:00:00 2001 From: Jeremy Fleischman Date: Tue, 16 Aug 2022 01:44:05 -0700 Subject: [PATCH 2/3] Rename NEWS fragment This build just failed https://github.com/pypa/pipenv/runs/7853944342?check_suite_focus=true with the following error: NEWS fragment files must be named *.(feature|behavior|bugfix|vendor|doc|trivial|removal|process).rst news/5261.bugfix pre-commit hook(s) made changes. If you are seeing this message in CI, reproduce locally with: `pre-commit run --all-files`. I created this file by following the PR template instructions, which don't say anything about the `.rst` part of the filename. I'm fixing up those instructions while I'm in here as well. --- .github/PULL_REQUEST_TEMPLATE.md | 2 +- news/{5261.bugfix => 5261.bugfix.rst} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename news/{5261.bugfix => 5261.bugfix.rst} (52%) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 325d14dbc9..f7c77d1354 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -19,7 +19,7 @@ How does this pull request fix your problem? Did you consider any alternatives? ### The checklist * [ ] Associated issue -* [ ] A news fragment in the `news/` directory to describe this fix with the extension `.bugfix`, `.feature`, `.behavior`, `.doc`. `.vendor`. or `.trivial` (this will appear in the release changelog). Use semantic line breaks and name the file after the issue number or the PR #. +* [ ] A news fragment in the `news/` directory to describe this fix with the extension `.bugfix.rst`, `.feature.rst`, `.behavior.rst`, `.doc.rst`. `.vendor.rst`. or `.trivial.rst` (this will appear in the release changelog). Use semantic line breaks and name the file after the issue number or the PR #.