Skip to content

Commit a3974f3

Browse files
authored
fix: Fix the bug that pdm plugins are invalid on ubuntu system python(#3289) (#3293)
* fix: Fix the bug that pdm plugins are invalid after installation on ubuntu. * ensure backwards compatibility * fix: undefined name * make code runnable before python 3.10 * use "posix_prefix" as scheme on both plugin-installing and loading sides on ubuntu
1 parent 7a16106 commit a3974f3

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

news/3289.bugfix.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix the bug that pdm plugins are invalid after installation on ubuntu system python.

src/pdm/core.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,15 @@ def _add_project_plugins_library(self) -> None:
316316

317317
base = str(project.root / ".pdm-plugins")
318318
replace_vars = {"base": base, "platbase": base}
319-
scheme = "nt" if os.name == "nt" else "posix_prefix"
319+
320+
scheme_names = sysconfig.get_scheme_names()
321+
if (sys.platform == "darwin" and "osx_framework_library" in scheme_names) or sys.platform == "linux":
322+
scheme = "posix_prefix"
323+
# sysconfig._get_default_scheme is a private function in 3.8 & 3.9
324+
elif sys.version_info < (3, 10):
325+
scheme = "nt" if os.name == "nt" else "posix_prefix"
326+
else:
327+
scheme = sysconfig.get_default_scheme()
320328
purelib = sysconfig.get_path("purelib", scheme, replace_vars)
321329
scripts = sysconfig.get_path("scripts", scheme, replace_vars)
322330
site.addsitedir(purelib)

src/pdm/models/in_process/sysconfig_get_paths.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ def get_paths(kind="default", vars=None):
3636
raise ValueError(f"{scheme} is not a valid scheme on the system, or user site may be disabled.")
3737
return sysconfig.get_paths(scheme, vars=vars)
3838
else:
39-
if sys.platform == "darwin" and "osx_framework_library" in scheme_names and kind == "prefix":
39+
if (
40+
(sys.platform == "darwin" and "osx_framework_library" in scheme_names) or sys.platform == "linux"
41+
) and kind == "prefix":
4042
return sysconfig.get_paths("posix_prefix", vars=vars)
4143
return sysconfig.get_paths(vars=vars)
4244

0 commit comments

Comments
 (0)