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

In Azure CLI source code, azure and azure.cli contain __init__.py files calling pkgutil #21911

Open
jiasli opened this issue Apr 2, 2022 · 1 comment

Comments

@jiasli
Copy link
Member

jiasli commented Apr 2, 2022

In a virtual env which installs Azure CLI from source code, under azure and azure.cli folders, there are __init__.py files containing one line:

__path__ = __import__("pkgutil").extend_path(__path__, __name__)

These files make azure and azure.cli normal (non-namespace) packages, preventing Python from lookup additional library folders, causing problems for extensions which installs their own azure and azure.mgmt namespace packages, like dataprotection (Azure/azure-cli-extensions#4562) and communication.

These pkgutil __init__.py files was introduced by #14372 to comply with Azure SDK's packaging guideline, possibly in order to support both Python 2 and 3:

https://packaging.python.org/guides/packaging-namespace-packages/

Use pkgutil-style namespace packages. This is recommended for new packages that need to support Python 2 and 3 and installation via both pip and python setup.py install.

However, Python 2 support was dropped from Azure CLI long ago by #11363.

During packaging (whl, deb, etc), these pkgutil __init__.py files are excluded using

packages=find_packages(exclude=["*.tests", "*.tests.*", "tests.*", "tests", "azure", "azure.cli"]),

Keeping these files seems unnecessary anymore.

References

@ghost ghost added Auto-Assign Auto assign by bot Installation labels Apr 2, 2022
@ghost ghost assigned jiasli Apr 2, 2022
@ghost ghost added this to the Backlog milestone Apr 2, 2022
@yonzhan
Copy link
Collaborator

yonzhan commented Apr 2, 2022

packaging

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

No branches or pull requests

3 participants