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

Drop pkg_resources usage #1882

Merged
merged 7 commits into from
Mar 10, 2025
Merged

Drop pkg_resources usage #1882

merged 7 commits into from
Mar 10, 2025

Conversation

gforcada
Copy link
Member

@gforcada gforcada commented Mar 1, 2025

@mister-roboto
Copy link

@gforcada thanks for creating this Pull Request and helping to improve Plone!

TL;DR: Finish pushing changes, pass all other checks, then paste a comment:

@jenkins-plone-org please run jobs

To ensure that these changes do not break other parts of Plone, the Plone test suite matrix needs to pass, but it takes 30-60 min. Other CI checks are usually much faster and the Plone Jenkins resources are limited, so when done pushing changes and all other checks pass either start all Jenkins PR jobs yourself, or simply add the comment above in this PR to start all the jobs automatically.

Happy hacking!

@gforcada gforcada force-pushed the drop-pkg-resources-usage branch from 4b57233 to b58b201 Compare March 1, 2025 21:59
@gforcada gforcada force-pushed the drop-pkg-resources-usage branch from b58b201 to 32589be Compare March 1, 2025 22:01
Copy link
Contributor

@stevepiercy stevepiercy left a comment

Choose a reason for hiding this comment

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

When trying to apply the change in conf.py from plone.api to plone.restapi, I was not able to build the docs locally.

      File "/Users/stevepiercy/projects/Plone/documentation/submodules/plone.restapi/lib/python3.13/site-packages/sphinx/config.py", line 616, in eval_config_file
        raise ConfigError(msg % traceback.format_exc()) from exc
    sphinx.errors.ConfigError: There is a programmable error in your configuration file:
    
    Traceback (most recent call last):
      File "/opt/homebrew/Cellar/[email protected]/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/importlib/metadata/__init__.py", line 407, in from_name
        return next(iter(cls.discover(name=name)))
    StopIteration
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/Users/stevepiercy/projects/Plone/documentation/submodules/plone.restapi/lib/python3.13/site-packages/sphinx/config.py", line 601, in eval_config_file
        exec(code, namespace)  # NoQA: S102
        ~~~~^^^^^^^^^^^^^^^^^
      File "/Users/stevepiercy/projects/Plone/documentation/submodules/plone.restapi/docs/source/conf.py", line 40, in <module>
        version = release = version("plone.restapi")
                            ~~~~~~~^^^^^^^^^^^^^^^^^
      File "/opt/homebrew/Cellar/[email protected]/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/importlib/metadata/__init__.py", line 987, in version
        return distribution(distribution_name).version
               ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
      File "/opt/homebrew/Cellar/[email protected]/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/importlib/metadata/__init__.py", line 960, in distribution
        return Distribution.from_name(distribution_name)
               ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
      File "/opt/homebrew/Cellar/[email protected]/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/importlib/metadata/__init__.py", line 409, in from_name
        raise PackageNotFoundError(name)
    importlib.metadata.PackageNotFoundError: No package metadata was found for plone.restapi

I have no idea why it doesn't work the same.

I also noticed the file https://github.com/plone/plone.restapi/blob/main/src/plone/__init__.py is the same in both packages. I don't know if it should also be included in this PR to remove that instance of pkg_resources, or if it's related to not being able to build docs.

It's not absolutely necessary to use the change in conf.py from plone.api in plone.restapi, but it would be nice not to have to remember to manually update the version number when making a release going forward.

@davisagli
Copy link
Member

@stevepiercy Fixed in 7677ce8 (plone.restapi needs to be actually installed in the virtualenv where the docs commands are, in order to look up its version this way).

The use of pkg_resources in __init__.py files is how setuptools namespaces are declared, and they need to be removed in a coordinated fashion with other packages as planned in plone/Products.CMFPlone#3928

@davisagli davisagli requested a review from stevepiercy March 9, 2025 23:19
@davisagli
Copy link
Member

@jenkins-plone-org please run jobs

@stevepiercy stevepiercy self-requested a review March 10, 2025 00:45
Copy link
Contributor

@stevepiercy stevepiercy left a comment

Choose a reason for hiding this comment

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

Docs look good on RTD. Thank you!

@davisagli davisagli merged commit 40ecd60 into main Mar 10, 2025
15 of 21 checks passed
@davisagli davisagli deleted the drop-pkg-resources-usage branch March 10, 2025 01:17
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.

5 participants