-
-
Notifications
You must be signed in to change notification settings - Fork 407
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
fix: Fix the bug that pdm plugins are invalid on ubuntu(#3289) #3293
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3293 +/- ##
==========================================
- Coverage 85.33% 85.33% -0.01%
==========================================
Files 112 112
Lines 11402 11407 +5
Branches 2487 2489 +2
==========================================
+ Hits 9730 9734 +4
- Misses 1143 1144 +1
Partials 529 529
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
I need to know why the original code is if sys.platform == "darwin" and "osx_framework_library" in scheme_names: Are there macos computers without "osx_framework_library" in scheme_names? Is my code correct on all mainstream systems? |
Yes, the built-in Python that comes with recent macOS, report
Python from brew also reports If Python reports |
If you want to be 100% backwards compatible regarding if ((sys.platform == "darwin" and "osx_framework_library" in scheme_names) or sys.platform == "linux") and kind == "prefix": Basically that's similar to one of the statements from your issue |
That's the very first code I thought which should be. But consider here # tag 2.20.1 src/pdm/core.py #L314
def _add_project_plugins_library(self) -> None:
...
scheme = "nt" if os.name == "nt" else "posix_prefix"
purelib = sysconfig.get_path("purelib", scheme, replace_vars)
scripts = sysconfig.get_path("scripts", scheme, replace_vars) If Or maybe there is another way better, def _add_project_plugins_library(self) -> None:
...
scheme_names = sysconfig.get_scheme_names()
if os.name == "nt":
scheme = "nt"
elif sys.platform == "darwin" and "osx_framework_library" in scheme_names:
scheme = "posix_prefix"
else:
scheme = sysconfig.get_default_scheme()
purelib = sysconfig.get_path("purelib", scheme, replace_vars)
scripts = sysconfig.get_path("scripts", scheme, replace_vars) That would be exactly 100% backwards compatible, and could ensure the consistency of loading path and installation path |
So strange. I just found this bug occurs because ubuntu def _get_preferred_schemes():
if os.name == 'nt':
return {
'prefix': 'nt',
'home': 'posix_home',
'user': 'nt_user',
}
if sys.platform == 'darwin' and sys._framework:
return {
'prefix': 'posix_prefix',
'home': 'posix_home',
'user': 'osx_framework_user',
}
return {
'prefix': 'posix_prefix',
'home': 'posix_home',
'user': 'posix_user',
} while both on my wsl2 (ubuntu 24.04, python 3.12.3) and the server in my company (ubuntu 22.04, python 3.10.12), the code is def _get_preferred_schemes():
if os.name == 'nt':
return {
'prefix': 'nt',
'home': 'posix_home',
'user': 'nt_user',
}
if sys.platform == 'darwin' and sys._framework:
return {
'prefix': 'posix_prefix',
'home': 'posix_home',
'user': 'osx_framework_user',
}
if sys.base_prefix != sys.prefix or hasattr(sys, "real_prefix"):
# virtual environments
prefix_scheme = 'posix_prefix'
else:
# default to /usr for package builds, /usr/local otherwise
deb_build = os.environ.get('DEB_PYTHON_INSTALL_LAYOUT', 'posix_local')
if deb_build in ('deb', 'deb_system'):
prefix_scheme = 'deb_system'
else:
prefix_scheme = 'posix_local'
return {
'prefix': prefix_scheme,
'home': 'posix_home',
'user': 'posix_user',
} I don't know why it's not the code on github. Anyway we need to fix it |
I don't think that this difference is a bug. Even though Ubuntu's (Debian's) Python reports as cPython, Debian patches it to better fit their distribution. There's a whole repository to track such changes: https://salsa.debian.org/python-team Here's a thread regading changing the local installation path starting with Python 3.10 (which is part of the sysconfig patch): https://lists.debian.org/debian-python/2022/03/msg00039.html |
I never regard this difference as a bug, and there's no way for us to change the code for debian team. Maybe I said "Anyway we need to fix it" misleads you, but what I mean is we need to fix the bug that results from this difference. |
Pull Request Checklist
news/
describing what is new.Describe what you have changed in this PR.
fix #3289