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

prototyping pythonfinder pep514 support #6140

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft

Conversation

matteius
Copy link
Member

Prototyping bringing back a level of pep514 support to pythonfinder (would back-vendor it to pythonfinder if successful).

The checklist

  • Associated issue
  • 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 #.

pipenv/vendor/pythonfinder/models/python.py Outdated Show resolved Hide resolved
key_path = r"Software\Python\PythonCore"
try:
import winreg
with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, key_path) as key:
Copy link

Choose a reason for hiding this comment

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

There's two other registry locations we need to apply the same process to, to find user-land installations and 32-bit installs on 64-bit Windows.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for your help with all this -- greatly appreciated. Do you know what the other paths would be? I can get back to looking at this soon.

Copy link

Choose a reason for hiding this comment

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

Per PEP-0514, the three registry paths that need to be checked are:

HKEY_CURRENT_USER\Software\Python\<Company>\<Tag>
HKEY_LOCAL_MACHINE\Software\Python\<Company>\<Tag>
HKEY_LOCAL_MACHINE\Software\Wow6432Node\Python\<Company>\<Tag>

You can check them all the same way, there's some notes there about what to do if you see the same Company-Tag combination in different registry paths, and specific notes about how to disambiguate 32-bit and 64-bit Python older than 3.5, which did not include architecture in its Tag, and so has the same Company-Tag for 32-bit and 64-bit installs.

@@ -302,6 +317,39 @@ def which(self, name) -> PathEntry | None:
non_empty_match = next(iter(m for m in matches if m is not None), None)
return non_empty_match

def find_python_versions_from_windows_launcher(self):
# Open the registry key for Python launcher
key_path = r"Software\Python\PythonCore"
Copy link

Choose a reason for hiding this comment

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

It'd be nice to support non-PythonCore environments at some point, e.g., conda.

Accept PR suggestion

Co-authored-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
Copy link

@TBBle TBBle left a comment

Choose a reason for hiding this comment

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

Quickly plumbed through the architecture, since we should have that available for Python 3.5 onwards.

pipenv/vendor/pythonfinder/models/python.py Outdated Show resolved Hide resolved
pipenv/vendor/pythonfinder/models/python.py Outdated Show resolved Hide resolved
pipenv/vendor/pythonfinder/models/python.py Outdated Show resolved Hide resolved
pipenv/vendor/pythonfinder/models/python.py Outdated Show resolved Hide resolved
matteius and others added 4 commits May 2, 2024 05:37
Co-authored-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
Co-authored-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
Co-authored-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
Co-authored-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
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.

None yet

2 participants