-
Notifications
You must be signed in to change notification settings - Fork 480
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
Don't use pkg_resources.declare_namespace(__name__)
#766
Comments
@DanielNoord thank you for pointing this out, we'll get it updated in a future release. |
@DanielNoord I'm having trouble reproducing the deprecation warning, could you add some details as to how you're able to get it to appear? What I've tried so far is installing |
Have you also updated |
Yes, same result when using pip version Which version of Python are you using? |
I could reproduce on 3.10. |
https://discuss.python.org/t/announcement-pip-23-1-release/25844/6 This might be related. Can you reproduce with |
@DanielNoord I'm still unable to reproduce with Python It would be useful to get more specifics about your environment. When you have a moment, could you run the below commands in order, capturing the output that shows the deprecation warning?
|
I could reproduce with: python3.11 -m virtualenv .venv
source .venv/bin/activate
python -m pip install pip==23.1
python -m pip install setuptools==67.3.1
python -m pip install google-ads
python -m pip install pytest
vim test.py
python -m pytest test.py ❯ cat test.py
from google.ads.googleads.client import GoogleAdsClient
def test():
assert False Output: ❯ python -m pytest test.py
============================= test session starts ==============================
platform linux -- Python 3.11.3, pytest-7.3.1, pluggy-1.0.0
rootdir: /tmp
collected 1 item
test.py F [100%]
=================================== FAILURES ===================================
_____________________________________ test _____________________________________
def test():
> assert False
E assert False
test.py:4: AssertionError
=============================== warnings summary ===============================
.venv/lib/python3.11/site-packages/pkg_resources/__init__.py:2803
.venv/lib/python3.11/site-packages/pkg_resources/__init__.py:2803
.venv/lib/python3.11/site-packages/pkg_resources/__init__.py:2803
.venv/lib/python3.11/site-packages/pkg_resources/__init__.py:2803
.venv/lib/python3.11/site-packages/pkg_resources/__init__.py:2803
.venv/lib/python3.11/site-packages/pkg_resources/__init__.py:2803
/tmp/.venv/lib/python3.11/site-packages/pkg_resources/__init__.py:2803: DeprecationWarning: 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)
.venv/lib/python3.11/site-packages/pkg_resources/__init__.py:2308
.venv/lib/python3.11/site-packages/pkg_resources/__init__.py:2308
.venv/lib/python3.11/site-packages/pkg_resources/__init__.py:2308
/tmp/.venv/lib/python3.11/site-packages/pkg_resources/__init__.py:2308: DeprecationWarning: 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(parent)
.venv/lib/python3.11/site-packages/google/rpc/__init__.py:20
/tmp/.venv/lib/python3.11/site-packages/google/rpc/__init__.py:20: DeprecationWarning: 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
pkg_resources.declare_namespace(__name__)
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
FAILED test.py::test - assert False
======================== 1 failed, 10 warnings in 0.14s ======================== Running with ``python -m pytest test.py -Werror` shows that the errors originate from imports in this package. |
Thanks @DanielNoord I was able to reproduce the warning using those steps. What I found was that if I remove the |
Thanks for the update @BenRKarl! Do let me know if I can help out with testing anything! |
This PR will resolve this issue: #830 |
This is resolved in version 23.0.0, you should longer see any warnings. |
Describe the bug:
Importing after building the package with
setuptools
67.3 and later will raise aDeprecationWarning
because of the deprecation ofpkg_resources.declare_namespace
: https://setuptools.pypa.io/en/latest/history.html#v67-3-0Steps to Reproduce:
Expected behavior:
Remove this line from
__init__.py
and use the method as described in PEP 420.The text was updated successfully, but these errors were encountered: