FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-99204: Calculate base_executable by alternate names in POSIX venvs by vfazio · Pull Request #99206 · python/cpython · GitHub

/ cpython Public

gh-99204: Calculate base_executable by alternate names in POSIX venvs - #99206

Merged
zooba merged 1 commit into
python:mainfrom
vfazio:vfazio-base-exec-fallback
Nov 10, 2022
Merged

gh-99204: Calculate base_executable by alternate names in POSIX venvs#99206
zooba merged 1 commit into
python:mainfrom
vfazio:vfazio-base-exec-fallback

Conversation

vfazio commented Nov 7, 2022
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Contributor

Check to see if base_executable exists. If it does not, attempt to use known alternative names of the python binary to find an executable in the path specified by home.

If no alternative is found, previous behavior is preserved.

FFY00 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I think this is a reasonable fix, but let's see if others agree.

Comment thread Modules/getpath.py Outdated

zooba commented Nov 9, 2022

Copy link
Copy Markdown
Member

Conceptually it seems fine. Not sure whether we should mark this a "QUIRK" and aim to resolve it in some other way? I'll leave that to the POSIX people to decide

vfazio force-pushed the vfazio-base-exec-fallback branch 2 times, most recently from e427dea to 76403d8 Compare November 9, 2022 21:16
… venvs

Check to see if `base_executable` exists. If it does not, attempt
to use known alternative names of the python binary to find an
executable in the path specified by `home`.

If no alternative is found, previous behavior is preserved.

Signed-off-by: Vincent Fazio <vfazio@gmail.com>
vfazio force-pushed the vfazio-base-exec-fallback branch from 76403d8 to 0683b37 Compare November 9, 2022 21:18
vfazio requested a review from zooba November 9, 2022 21:22

zooba commented Nov 9, 2022

Copy link
Copy Markdown
Member

Please don't force push changes when doing PRs. We'll squash merge at the end, but for now I have to re-review from the start because the diff is broken.

I don't have time for that right now, but if someone else signs off and the variable names are indeed fixed, they can merge.

vfazio commented Nov 9, 2022

Copy link
Copy Markdown
Contributor Author

Please don't force push changes when doing PRs. We'll squash merge at the end, but for now I have to re-review from the start because the diff is broken.

I don't have time for that right now, but if someone else signs off and the variable names are indeed fixed, they can merge.

@zooba sorry about that, my mistake completely. Diff below

-                        _base_exe = basename(executable)
-                        for _candidate in (DEFAULT_PROGRAM_NAME, f'python{VERSION_MAJOR}.{VERSION_MINOR}'):
-                            _candidate += EXE_SUFFIX if EXE_SUFFIX else ''
-                            if _base_exe == _candidate:
+                        base_exe = basename(executable)
+                        for candidate in (DEFAULT_PROGRAM_NAME, f'python{VERSION_MAJOR}.{VERSION_MINOR}'):
+                            candidate += EXE_SUFFIX if EXE_SUFFIX else ''
+                            if base_exe == candidate:
                                 continue
-                            _candidate = joinpath(executable_dir, _candidate)
+                            candidate = joinpath(executable_dir, candidate)
                             # Only set base_executable if the candidate exists.
                             # If no candidate succeeds, subsequent errors related to
                             # base_executable (like FileNotFoundError) remain in the
                             # context of the original executable name
-                            if isfile(_candidate):
-                                base_executable = _candidate
+                            if isfile(candidate):
+                                base_executable = candidate
                                 break
             break
     else:

vfazio commented Nov 9, 2022
edited
Loading

Copy link
Copy Markdown
Contributor Author

would there be any concerns about me also making a PR targeting 3.11? Fixing it here means not having to work around it in downstream packages.

zooba merged commit c41b13d into python:main Nov 10, 2022
zooba added the needs backport to 3.11 only security fixes label Nov 10, 2022

Copy link
Copy Markdown
Contributor

Thanks @vfazio for the PR, and @zooba for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Nov 10, 2022
… venvs (pythonGH-99206)

Check to see if `base_executable` exists. If it does not, attempt
to use known alternative names of the python binary to find an
executable in the path specified by `home`.

If no alternative is found, previous behavior is preserved.

Signed-off-by: Vincent Fazio <vfazio@gmail.com>

(cherry picked from commit c41b13d)

Co-authored-by: Vincent Fazio <vfazio@gmail.com>
Signed-off-by: Vincent Fazio <vfazio@gmail.com>

Copy link
Copy Markdown

GH-99340 is a backport of this pull request to the 3.11 branch.

bedevere-bot removed the needs backport to 3.11 only security fixes label Nov 10, 2022

zooba commented Nov 10, 2022

Copy link
Copy Markdown
Member

would there be any concerns about me also making a PR targeting 3.11?

We'll let the bot do it. Should backport fine, as we haven't really been working on anything new in this file

miss-islington added a commit that referenced this pull request Nov 10, 2022
…GH-99206)

Check to see if `base_executable` exists. If it does not, attempt
to use known alternative names of the python binary to find an
executable in the path specified by `home`.

If no alternative is found, previous behavior is preserved.

Signed-off-by: Vincent Fazio <vfazio@gmail.com>

(cherry picked from commit c41b13d)

Co-authored-by: Vincent Fazio <vfazio@gmail.com>
Signed-off-by: Vincent Fazio <vfazio@gmail.com>
gvanrossum pushed a commit to gvanrossum/cpython that referenced this pull request Nov 10, 2022
… venvs (pythonGH-99206)

Check to see if `base_executable` exists. If it does not, attempt
to use known alternative names of the python binary to find an
executable in the path specified by `home`.

If no alternative is found, previous behavior is preserved.

Signed-off-by: Vincent Fazio <vfazio@gmail.com>

Signed-off-by: Vincent Fazio <vfazio@gmail.com>
ethanfurman pushed a commit to ethanfurman/cpython that referenced this pull request Nov 12, 2022
… venvs (pythonGH-99206)

Check to see if `base_executable` exists. If it does not, attempt
to use known alternative names of the python binary to find an
executable in the path specified by `home`.

If no alternative is found, previous behavior is preserved.

Signed-off-by: Vincent Fazio <vfazio@gmail.com>

Signed-off-by: Vincent Fazio <vfazio@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants


Back | FazBrowse Home | New Git URL