GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-99204: Calculate base_executable by alternate names in POSIX venvs by vfazio · Pull Request #99206 · python/cpython

Conversation

@vfazio

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

Uh oh!

There was an error while loading. Please reload this page.

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.

  • Issue: sys._base_executable may not exist on posix venvs made with --copies #99204

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

uSpike reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@bedevere-bot bedevere-bot mentioned this pull request Nov 7, 2022
sys._base_executable may not exist on posix venvs made with --copies #99204
Closed
@bedevere-bot bedevere-bot added the awaiting review label Nov 7, 2022
FFY00
FFY00 approved these changes Nov 9, 2022
View reviewed changes

@FFY00 FFY00 left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting review labels Nov 9, 2022
@FFY00
FFY00 requested a review from zooba November 9, 2022 03:49
zooba
zooba reviewed Nov 9, 2022
View reviewed changes
Comment thread Modules/getpath.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@zooba

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vfazio
vfazio force-pushed the vfazio-base-exec-fallback branch 2 times, most recently from e427dea to 76403d8 Compare November 9, 2022 21:16
@vfazio
pythongh-99204: Calculate base_executable by alternate names in POSIX…
0683b37
… 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 <[email protected]>
@vfazio
vfazio force-pushed the vfazio-base-exec-fallback branch from 76403d8 to 0683b37 Compare November 9, 2022 21:18
@vfazio
vfazio requested a review from zooba November 9, 2022 21:22
@zooba

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vfazio

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:
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vfazio

vfazio commented Nov 9, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@zooba
zooba merged commit c41b13d into python:main Nov 10, 2022
@bedevere-bot bedevere-bot removed the awaiting merge label Nov 10, 2022
@zooba zooba added the needs backport to 3.11 only security fixes label Nov 10, 2022
@miss-islington

miss-islington commented 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.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Nov 10, 2022
@vfazio @miss-islington
pythongh-99204: Calculate base_executable by alternate names in POSIX…
0109c7b
… 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 <[email protected]>

(cherry picked from commit c41b13d)

Co-authored-by: Vincent Fazio <[email protected]>
Signed-off-by: Vincent Fazio <[email protected]>
@bedevere-bot

bedevere-bot commented Nov 10, 2022

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

miss-islington added a commit that referenced this pull request Nov 10, 2022
@miss-islington @vfazio
gh-99204: Calculate base_executable by alternate names in POSIX venvs (…
c9f2177
…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 <[email protected]>

(cherry picked from commit c41b13d)

Co-authored-by: Vincent Fazio <[email protected]>
Signed-off-by: Vincent Fazio <[email protected]>
gvanrossum pushed a commit to gvanrossum/cpython that referenced this pull request Nov 10, 2022
@vfazio @gvanrossum
pythongh-99204: Calculate base_executable by alternate names in POSIX…
8226fb9
… 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 <[email protected]>

Signed-off-by: Vincent Fazio <[email protected]>
ethanfurman pushed a commit to ethanfurman/cpython that referenced this pull request Nov 12, 2022
@vfazio @ethanfurman
pythongh-99204: Calculate base_executable by alternate names in POSIX…
05ddd53
… 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 <[email protected]>

Signed-off-by: Vincent Fazio <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@FFY00 FFY00 FFY00 approved these changes
@zooba zooba Awaiting requested review from zooba

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@vfazio @zooba @miss-islington @bedevere-bot @FFY00
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.