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

feat: install plugins from project config #1893

Merged
merged 5 commits into from
May 8, 2023
Merged

feat: install plugins from project config #1893

merged 5 commits into from
May 8, 2023

Conversation

frostming
Copy link
Collaborator

@frostming frostming commented May 6, 2023

Signed-off-by: Frost Ming [email protected]

Pull Request Checklist

  • A news fragment is added in news/ describing what is new.
  • Test cases added for changed code.

Describe what you have changed in this PR.

Resolve #1461

This adds a config field tool.pdm.plugins as a list of plugin requirements. When user runs pdm install --plugins, the dependencies will be installed to a project plugin library under the project root, which will be gitignored by default.

Then, the following invocations of PDM will add the path to sys.path and load the plugins in it.

@frostming
Copy link
Collaborator Author

frostming commented May 6, 2023

/cc @tgolsson @noirbizarre may be interested. What do you think about the naming? Would a more verbose name like pdm-plugins be better?

@codecov-commenter
Copy link

codecov-commenter commented May 6, 2023

Codecov Report

Patch coverage: 83.52% and project coverage change: -0.08 ⚠️

Comparison is base (8bc41a1) 85.43% compared to head (dbb6b49) 85.35%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1893      +/-   ##
==========================================
- Coverage   85.43%   85.35%   -0.08%     
==========================================
  Files         100       99       -1     
  Lines        9137     9172      +35     
  Branches     1970     1983      +13     
==========================================
+ Hits         7806     7829      +23     
- Misses        900      909       +9     
- Partials      431      434       +3     
Flag Coverage Δ
unittests 85.16% <82.35%> (-0.09%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/pdm/environments/__init__.py 57.14% <ø> (-2.86%) ⬇️
src/pdm/installers/synchronizers.py 84.77% <56.00%> (-2.96%) ⬇️
src/pdm/cli/commands/install.py 89.36% <89.47%> (+0.07%) ⬆️
src/pdm/environments/python.py 83.33% <90.90%> (+2.68%) ⬆️
src/pdm/builders/base.py 88.95% <100.00%> (ø)
src/pdm/cli/utils.py 83.57% <100.00%> (+0.34%) ⬆️
src/pdm/core.py 93.57% <100.00%> (+0.54%) ⬆️
src/pdm/environments/base.py 70.58% <100.00%> (-0.43%) ⬇️
src/pdm/installers/core.py 100.00% <100.00%> (ø)
src/pdm/project/project_file.py 91.52% <100.00%> (+0.45%) ⬆️
... and 1 more

... and 2 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@tgolsson
Copy link
Contributor

tgolsson commented May 6, 2023

I've personally never installed a cargo plugin as a dev dependency and I wouldn't expect that to work as you can normally only depend on libs.

Thus, I do think more specific naming would be good. What about tool.pdm.plugins instead? Since it's already in a tool namespace it seems like treating it specially all the way makes more sense given it'd be a very special case of dev dependency. Same thing with install, I'd specialcase it there. pdm install --plugins? pdm init --plugins?

In essence: does the specialness of the plugins warrant more special workflows, as opposed to overloading existing commands with "similar" functionality.

If keeping it as a dev-dep group I'd definitely call it pdm-plugins as it's very likely to collide with existing use otherwise.

@pawamoy
Copy link
Contributor

pawamoy commented May 6, 2023

I agree with @tgolsson. I rely on a PDM plugin locally but not in CI, and therefore would prefer that it does not get installed by default.

Amazing feature anyway, great work @frostming!

@tgolsson
Copy link
Contributor

tgolsson commented May 6, 2023

I don't particularlymind if they get automatically installed though. I was just positing that they are a conceptually third kind of dependency. :-)

@frostming
Copy link
Collaborator Author

frostming commented May 7, 2023

I put them in dev-dependencies because I also want the plugins to be locked while reusing the lock ability. However I agree that plugins should not be install by default but should be requested explicitly.

I am about to move it to its own configuration field, is it acceptable that we do not create locks for plugins?

@tgolsson
Copy link
Contributor

tgolsson commented May 7, 2023

That's an aspect I hadn't considered, but I think it could be argued both ways. Pants doesn't, and I haven't felt any major issues working with it so far - but I also always do strict pinning Though that only solves some issues, not all. Presumably it could be retrofitted with locking capabilities if it turns out to not work well enough?

@frostming frostming merged commit d52c79c into main May 8, 2023
@frostming frostming deleted the feat/plugin branch May 8, 2023 01:26
@j178 j178 mentioned this pull request Apr 3, 2024
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.

Install plugins from pyproject.toml (+config)
4 participants