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
In a virtual env which installs Azure CLI from source code, under
azureandazure.clifolders, there are__init__.pyfiles containing one line:These files make
azureandazure.clinormal (non-namespace) packages, preventing Python from lookup additional library folders, causing problems for extensions which installs their ownazureandazure.mgmtnamespace packages, likedataprotection(Azure/azure-cli-extensions#4562) andcommunication.These
pkgutil__init__.pyfiles 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/
However, Python 2 support was dropped from Azure CLI long ago by #11363.
During packaging (whl, deb, etc), these
pkgutil__init__.pyfiles are excluded usingazure-cli/src/azure-cli-core/setup.py
Line 81 in 83c11a4
Keeping these files seems unnecessary anymore.
References
azureandazure.mgmtstill have__init__.pyfiles callingpkg_resources#21910