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

pkg_resources.declare_namespace is deprecated #270

Open
bluetech opened this issue Jun 5, 2023 · 5 comments
Open

pkg_resources.declare_namespace is deprecated #270

bluetech opened this issue Jun 5, 2023 · 5 comments

Comments

@bluetech
Copy link

bluetech commented Jun 5, 2023

BUG

What I did:

Imported zope.interface (through gevent).

What I expect to happen:

No warning.

What actually happened:

The method zope.interface uses to declare a namespace package is deprecated in latest setuptools:

DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('zope')`.
  Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
    declare_namespace(pkg)

The relevant code:

https://github.com/zopefoundation/zope.interface/blob/405017fef489ff9d517d0e86e6cb0e6a14fb9bd6/src/zope/__init__.py

Linkified link:

https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages

What version of Python and Zope/Addons I am using:

zope.interface==6.0

@cjwatson
Copy link
Contributor

cjwatson commented Jun 5, 2023

Unfortunately as https://packaging.python.org/en/latest/guides/packaging-namespace-packages/#pkg-resources-style-namespace-packages says:

If you are creating a new distribution within an existing namespace package that uses this method then it’s recommended to continue using this as the different methods are not cross-compatible and it’s not advisable to try to migrate an existing package.

It's not clear that it's possible to fix this. If a method exists that doesn't break things then I'd be very interested to hear about it!

@bluetech
Copy link
Author

bluetech commented Jun 6, 2023

Hmm a way forward is definitely unclear, I've opened a setuptools issue asking about this: pypa/setuptools#3943

@jensens
Copy link
Member

jensens commented Jun 9, 2023

Takeaway from the above PyPA issue:

Once we have one pep420 namespace package in our installation we lose the ability to do a pip install -e on all packages in the same namespace not converted to the new standard.

This according to the example package here https://github.com/pypa/sample-namespace-packages
and specifically the compatibility table there.

@gforcada
Copy link
Contributor

gforcada commented Jun 9, 2023

A major breaking change for any namespace then 😱 if we coordinate enough, for zope and plone that might still work, but for collective... that's going to be a minefield 😕

@icemac
Copy link
Member

icemac commented Jun 21, 2023

What I found out is that it is not always possible to mix PEP 420 installations with the currently used namespaces: If I install a namespaced package using pip (which does PEP 420 now by default) and install later on packages using zc.buildout (which does not know about PEP 420) it depends on the import order if the packages installed using zc.buildout can be found: It seem that one of these modules has to be imported first.

The only way I see is to migrate the whole namespace.
See also zopefoundation/meta#194 where this issue is discussed for the whole zopefoundation ecosystem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

5 participants