Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Stop falling back to pkgutil #326

Closed
wants to merge 1 commit into from
Closed

Stop falling back to pkgutil #326

wants to merge 1 commit into from

Conversation

jeffwidman
Copy link
Contributor

Falling back to pkgutil is now discouraged:

Note Some older recommendations advise the following in the namespace package __init__.py:

try:
    __import__('pkg_resources').declare_namespace(__name__)
except ImportError:
    __path__ = __import__('pkgutil').extend_path(__path__, __name__)

The idea behind this was that in the rare case that setuptools isn’t available packages would fall-back to the pkgutil-style packages. This isn’t advisable because pkgutil and pkg_resources-style namespace packages are not cross-compatible. If the presence of setuptools is a concern then the package should just explicitly depend on setuptools via install_requires.

Falling back to `pkgutil` is now [discouraged](https://packaging.python.org/guides/packaging-namespace-packages/):
> Note Some older recommendations advise the following in the namespace package `__init__.py`:
>```
> try:
>     __import__('pkg_resources').declare_namespace(__name__)
> except ImportError:
>     __path__ = __import__('pkgutil').extend_path(__path__, __name__)
>```
> The idea behind this was that in the rare case that `setuptools` isn’t available packages would fall-back to the `pkgutil`-style packages. This isn’t advisable because `pkgutil` and `pkg_resources`-style namespace packages are not cross-compatible. If the presence of `setuptools` is a concern then the package should just explicitly depend on `setuptools` via `install_requires`.
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Feb 27, 2019
@jeffwidman
Copy link
Contributor Author

Related: #322

@theacodes
Copy link
Contributor

theacodes commented Feb 27, 2019 via email

@jeffwidman
Copy link
Contributor Author

jeffwidman commented Feb 27, 2019

Hi, I wrote that referenced doc.

😄

@jeffwidman jeffwidman closed this Feb 27, 2019
@jeffwidman jeffwidman deleted the patch-2 branch February 27, 2019 17:45
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants