Description
Describe the bug
plugins is invalid after installation on Ubuntu
To reproduce
In one pdm project, create plugin/my_plugin.py
# plugin/my_plugin.py`
def plugin(core):
print("test")
and plugin/pyproject.toml
# plugin/pyproject.toml
[project]
name = "my_plugin"
version = "0.0.0"
[project.entry-points.pdm]
test_plug = "my_plugin:plugin"
[build-system]
requires = ["pdm-backend"]
build-backend = "pdm.backend"
In pyproject.toml, add
[tool.pdm]
plugins = [
"-e file:///${PROJECT_ROOT}/plugin#egg=my-plugin"
]
run pdm install --plugins
, make sure the plugins are installed successfully by checking .pdm-plugins
which should be
.pdm-plugins
└── local
└── lib
└── python3.10
└── dist-packages
├── my_plugin-0.0.0.dist-info
│ ├── direct_url.json
│ ├── entry_points.txt
│ ├── METADATA
│ ├── RECORD
│ └── WHEEL
└── my_plugin.pth
Then, try to type something starts with pdm
like pdm lock
Expected Behavior
If the plugin is valid, whatever you input, "test" would be output as long as you are running a pdm
command
Environment Information
pdm 2.20.1
ubuntu 22.04
pdm -v output
No response
Additional Context
Reason Analysis
On windows system, plugins' installation route and loading route would be the same, both ${PROJECT}/.pdm-plugins/Lib/site-packages
, but on ubuntu they are different.
On ubuntu, as site.py
said
For Debian and derivatives, this sys.path is augmented with directories
for packages distributed within the distribution. Local addons go
into /usr/local/lib/python<version>/dist-packages, Debian addons
install into /usr/lib/python3/dist-packages.
/usr/lib/python<version>/site-packages is not used.
So the installation route would be /${PROJECT}/.pdm-plugins/local/lib/python{ver}/dist-packages
, while the loading route got by
# pdm/core.py
def _add_project_plugins_library(self) -> None:
...
purelib = sysconfig.get_path("purelib", scheme, replace_vars)
would be ${PROJECT}/.pdm-plugins/lib/python{ver}/site-pacakges
, so pdm would not load any plugins on ubuntu.
In fact, when I manually change the local/lib/python{ver}/dist-packages
to lib/python{ver}/site-pacakges
, plugins are enabled.
So, the two routes on ubuntu must somehow be consistent.
Are you willing to submit a PR to fix this bug?
- Yes, I would like to submit a PR.