In Azure CLI source code, `azure` and `azure.cli` contain `__init__.py` files calling `pkgutil`
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 3.5k
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 60
Description
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:
```py
__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` (https://github.com/Azure/azure-cli-extensions/issues/4562) and `communication`.
These `pkgutil` `__init__.py` files was introduced by https://github.com/Azure/azure-cli/pull/14372 to comply with [Azure SDK's packaging guideline](https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/packaging.md), possibly in order to support both Python 2 and 3:
https://packaging.python.org/guides/packaging-namespace-packages/
> Use [pkgutil-style namespace packages](https://packaging.python.org/en/latest/guides/packaging-namespace-packages/#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 https://github.com/Azure/azure-cli/pull/11363.
During packaging (whl, deb, etc), these `pkgutil` `__init__.py` files are excluded using
https://github.com/Azure/azure-cli/blob/83c11a49f2e45fbee43a3aa57ec89a8e83169350/src/azure-cli-core/setup.py#L81
Keeping these files seems unnecessary anymore.
### References
- https://github.com/Azure/azure-cli/issues/21910
Contributor guide
Assessment
This issue has not been assessed yet.