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

[bug] ubuntu plugins not valid after installation #3289

Open
1 task
monchin opened this issue Nov 14, 2024 · 0 comments
Open
1 task

[bug] ubuntu plugins not valid after installation #3289

monchin opened this issue Nov 14, 2024 · 0 comments
Labels
🐛 bug Something isn't working

Comments

@monchin
Copy link
Contributor

monchin commented Nov 14, 2024

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.
@monchin monchin added the 🐛 bug Something isn't working label Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant