Skip to content

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

@jiasli

Description

@jiasli

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions