Skip to content

pluginoriginpip: use importlib instead of pkg_resources#1948

Merged
gtristan merged 1 commit intomasterfrom
abderrahim/no-pkg-resources
Dec 11, 2024
Merged

pluginoriginpip: use importlib instead of pkg_resources#1948
gtristan merged 1 commit intomasterfrom
abderrahim/no-pkg-resources

Conversation

@abderrahim
Copy link
Contributor

No description provided.

@abderrahim abderrahim force-pushed the abderrahim/no-pkg-resources branch from 20da7c0 to 73c2387 Compare August 11, 2024 21:08
@abderrahim
Copy link
Contributor Author

It looks like we can use https://pypi.org/project/backports.entry-points-selectable/ to fix the failure on python 3.8.

@abderrahim abderrahim force-pushed the abderrahim/no-pkg-resources branch from 73c2387 to ff404f5 Compare November 27, 2024 11:12
@abderrahim abderrahim marked this pull request as ready for review November 27, 2024 11:12
@abderrahim
Copy link
Contributor Author

Now that we dropped python 3.8 support, we don't need to worry about it.

@juergbi
Copy link
Contributor

juergbi commented Nov 29, 2024

The Python package tests in CI are failing with:

       File "/tmp/venv/lib/python3.9/site-packages/buildstream/_pluginfactory/pluginoriginpip.py", line 35, in get_plugin_paths
        from packaging.requirements import Requirement, InvalidRequirement
      File "/tmp/venv/lib/python3.9/site-packages/pluginbase.py", line 438, in plugin_import
        return self._system_import(import_name, globals, locals,
    ModuleNotFoundError: No module named 'packaging'

And Debian 11 (Python 3.9) is also not happy:

  File "/home/testuser/buildstream/src/buildstream/_pluginfactory/pluginoriginpip.py", line 75, in get_plugin_paths
    detail="{} {} is installed but {} is required".format(dist.name, dist.version, package),
AttributeError: 'PathDistribution' object has no attribute 'name'

@juergbi
Copy link
Contributor

juergbi commented Nov 29, 2024

There are still a few remaining references to pkg_resources in the repository. Can we replace them in the same branch or does it make sense to defer that to a follow-up?

@abderrahim abderrahim force-pushed the abderrahim/no-pkg-resources branch from ff404f5 to 19620c8 Compare December 11, 2024 17:19
@abderrahim abderrahim force-pushed the abderrahim/no-pkg-resources branch from 19620c8 to 10b4521 Compare December 11, 2024 20:26
@abderrahim
Copy link
Contributor Author

CI is happy now.

  • I used importlib_metadata for python 3.9 that doesn't have all the needed features in importlib.metadata.
  • I moved setuptools to dev-requirements, as it's still used by tests. We can port tests as a followup.
  • I added packaging to the requirements

@gtristan gtristan merged commit bf0bf4e into master Dec 11, 2024
17 checks passed
@gtristan gtristan deleted the abderrahim/no-pkg-resources branch December 11, 2024 21:43
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.

4 participants