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

Add plugin system #91

Draft
wants to merge 22 commits into
base: main
Choose a base branch
from
Draft

Add plugin system #91

wants to merge 22 commits into from

Conversation

JeanChristopheMorinPerso
Copy link
Owner

@JeanChristopheMorinPerso JeanChristopheMorinPerso commented Feb 3, 2024

Fixes #64.

Add a new generic plugins system and builtin plugins. The glugin system is based on pluggy and has 5 hooks: prePipResolve, postPipResolve, groupPackages, cleanup and metadata.

The 2 builtin plugins are the PySide6 and shiboken6 plugins for correctly installing PySide6>=6.3. The plugins take care of merging all the PySide6 related packages (PySide6, PySide6-Addons and PySide6-Essentials) into one rez package.

$ rez-pip2 PySide6 --prefix /tmp/asd --python 3.11 -- --find-links /tmp/wheels --no-index

$ rez-env PySide6 --paths ~/rez_packages:/tmp/asd -- python -c 'import PySide6,shiboken6; print(PySide6); print(shiboken6)'
<module 'PySide6' from '/tmp/asd/PySide6/6.6.1/9645a50b415bcaad6bcde791aeb0859a43c56501/python/PySide6/__init__.py'>
<module 'shiboken6' from '/tmp/asd/shiboken6/6.6.1/9645a50b415bcaad6bcde791aeb0859a43c56501/python/shiboken6/__init__.py'>

🎉

TODOs:

  • Add option to disable plugins/hooks
  • Test if builtin plugins can be overridden
  • Test on Windows
  • Write tests
  • Cleanup the code
  • Write docs (and automatically generate docs for builtin plugins).

src/rez_pip/rez.py Outdated Show resolved Hide resolved
src/rez_pip/plugins/__init__.py Outdated Show resolved Hide resolved
@@ -113,8 +136,8 @@ def make_root(variant: rez.packages.Variant, path: str) -> None:
pkg.pip = {
"name": dist.name,
"version": dist.version,
"is_pure_python": metadata["is_pure_python"],
"wheel_url": wheelURL,
"is_pure_python": isPure,
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This annoys me. I don't think we really need this...

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is annoying about it?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's kind of useless and getting the value of "is pure" is annoying. Do you think I should keep it?

src/rez_pip/plugins/PySide6.py Outdated Show resolved Hide resolved
src/rez_pip/cli.py Outdated Show resolved Hide resolved
Copy link

codecov bot commented Feb 4, 2024

Codecov Report

Attention: Patch coverage is 69.79167% with 87 lines in your changes missing coverage. Please review.

Project coverage is 77.54%. Comparing base (71ba391) to head (d39e1d7).

Files with missing lines Patch % Lines
src/rez_pip/plugins/PySide6.py 51.78% 19 Missing and 8 partials ⚠️
src/rez_pip/cli.py 25.00% 23 Missing and 1 partial ⚠️
src/rez_pip/pip.py 75.00% 6 Missing and 3 partials ⚠️
src/rez_pip/plugins/__init__.py 87.50% 5 Missing and 2 partials ⚠️
src/rez_pip/plugins/shiboken6.py 61.11% 5 Missing and 2 partials ⚠️
src/rez_pip/install.py 55.55% 4 Missing ⚠️
src/rez_pip/rez.py 87.87% 1 Missing and 3 partials ⚠️
src/rez_pip/utils.py 40.00% 2 Missing and 1 partial ⚠️
src/rez_pip/compat.py 75.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #91      +/-   ##
==========================================
- Coverage   81.14%   77.54%   -3.61%     
==========================================
  Files           8       12       +4     
  Lines         716      935     +219     
  Branches      133      180      +47     
==========================================
+ Hits          581      725     +144     
- Misses        121      177      +56     
- Partials       14       33      +19     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Repository owner deleted a comment from sonarqubecloud bot Mar 6, 2024
@JeanChristopheMorinPerso JeanChristopheMorinPerso force-pushed the plugins branch 3 times, most recently from 178c63c to f9b6577 Compare April 28, 2024 23:38
@JeanChristopheMorinPerso JeanChristopheMorinPerso changed the title Initial commit adding a plugin system and a PySide6 plugin Plugin system Apr 28, 2024
Copy link

@BryceGattis BryceGattis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a couple questions/comments.

"rez": ("https://rez.readthedocs.io/en/stable/", None),
}

# Force usage of :external:
intersphinx_disabled_reftypes = ["*"]
# intersphinx_disabled_reftypes = ["*"]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this something we are wanting to keep commented out or remove?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember the exact reason I did this, but I remember that it was causing issues. I'll probably have to investigate this more to remember why I changed that.

=======
Plugins
=======

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could use a small writeup of what plugins are in rez-pip and how they work at the top here.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. I'll write something up once I'm fully happy with the plugin system.

self.__localPath = path


class PackageGroup:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What functionality does this new class provide?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's mainly a convenience that saves me from having to use zip in multiple places. A package groups contains the grouped packages and also has their distribution objects. It's also slightly easier to work with a list of PackageGroup than a list of list. I first implemented the code without this class, and the result was 🍝.


On Windows, the PySide6/openssl folder has to be added to PATH, see https://inspector.pypi.io/project/pyside6/6.6.1/packages/ec/3d/1da1b88d74cb5318466156bac91f17ad4272c6c83a973e107ad9a9085009/PySide6-6.6.1-cp38-abi3-win_amd64.whl/PySide6/__init__.py#line.81.

So it's at least a 3 steps process:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that you only listed 2 steps here 😆

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is outdated I think

if typing.TYPE_CHECKING:
from rez_pip.compat import importlib_metadata

# PySide6 was initiall a single package that had shiboken as a dependency.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of typos in these comments.

packages: typing.List[str],
) -> None:
pyside6Seen = False
variantsSeens = []

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this just be variantsSeen?

@@ -113,8 +136,8 @@ def make_root(variant: rez.packages.Variant, path: str) -> None:
pkg.pip = {
"name": dist.name,
"version": dist.version,
"is_pure_python": metadata["is_pure_python"],
"wheel_url": wheelURL,
"is_pure_python": isPure,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is annoying about it?

Signed-off-by: Jean-Christophe Morin <jean_christophe_morin@hotmail.com>
Signed-off-by: Jean-Christophe Morin <jean_christophe_morin@hotmail.com>
Signed-off-by: Jean-Christophe Morin <jean_christophe_morin@hotmail.com>
Signed-off-by: Jean-Christophe Morin <jean_christophe_morin@hotmail.com>
Signed-off-by: Jean-Christophe Morin <jean_christophe_morin@hotmail.com>
Signed-off-by: Jean-Christophe Morin <jean_christophe_morin@hotmail.com>
Signed-off-by: Jean-Christophe Morin <jean_christophe_morin@hotmail.com>
Signed-off-by: Jean-Christophe Morin <jean_christophe_morin@hotmail.com>
Signed-off-by: Jean-Christophe Morin <jean_christophe_morin@hotmail.com>
Signed-off-by: Jean-Christophe Morin <jean_christophe_morin@hotmail.com>
Signed-off-by: Jean-Christophe Morin <jean_christophe_morin@hotmail.com>
…e arguments are immutable

The code is also a little bit cleaner IMO

Signed-off-by: Jean-Christophe Morin <jean_christophe_morin@hotmail.com>
Signed-off-by: Jean-Christophe Morin <jean_christophe_morin@hotmail.com>
…force immutability at runtime.

Signed-off-by: Jean-Christophe Morin <jean_christophe_morin@hotmail.com>
Signed-off-by: Jean-Christophe Morin <jean_christophe_morin@hotmail.com>
… positional arguments instead of kwargs

Signed-off-by: Jean-Christophe Morin <jean_christophe_morin@hotmail.com>
Signed-off-by: Jean-Christophe Morin <jean_christophe_morin@hotmail.com>
Signed-off-by: Jean-Christophe Morin <jean_christophe_morin@hotmail.com>
Signed-off-by: Jean-Christophe Morin <jean_christophe_morin@hotmail.com>
Signed-off-by: Jean-Christophe Morin <jean_christophe_morin@hotmail.com>
Signed-off-by: Jean-Christophe Morin <jean_christophe_morin@hotmail.com>
Signed-off-by: Jean-Christophe Morin <jean_christophe_morin@hotmail.com>
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.

Fail to install PySide6
2 participants