Describe the bug
Dependency resolution for .whl installed extension changes depending on how the AZ-CLI was installed.
Our extension requires the azure-mgmt-resourcegraph which we define in setup.py:
DEPENDENCIES = [
'azure-cli-core',
'azure-mgmt-resourcegraph',
# The following are dependencies from azure-cli-core that we are using directly
'requests~=2.20',
'six~=1.12'
]
When the az-cli is installed via pip in a clean python distro, or via the Debian/Redhat installer, our extensions dependencies are successfully resolved to $USERHOME/.azure/cliextensions/livedata/azure/mgmt/resourcegraph
Other supported means of installing the az-cli may result in the following errors when installing our .whl extension and trying to resolve dependencies
az-cli installed via brew on macOS:
ImportError: cannot import name 'resourcegraph' from 'azure.mgmt' (/usr/local/Cellar/azure-cli/2.25.0/libexec/lib/python3.8/site-packages/azure/mgmt/__init__.py)
Observe that the dependency is being looked for in the python distribution rather than under .azure/cliextensions
az-cli installed in venv where azdev setup is ran:
File "/Users/user/.pyenv/versions/3.8.5/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/Users/user/.azure/cliextensions/livedata/azext_livedata/custom.py", line 14, in <module>
from azure.mgmt import resourcegraph as arg
ImportError: cannot import name 'resourcegraph' from 'azure.mgmt' (unknown location)
Observe that importlib is used from within the python distribution and is not resolving dependency from .azure/cliextensions/livedata/module-name
To Reproduce
- Install az-cli through homebrew
- Create an extension with the
azure-mgmt-resourcegraph listed in setup.py and a command which will import this dependency
- Build and add extension via
az extension add --source /path/to/extension.whl
Expected behavior
Extensions used in the az-cli should resolve their dependencies from the extension module in .azure/cliextensions in a consistent way when using commands
Attached is the python build wheel for our extension. It needs to have the filename extension renamed to .whl in order to work.
livedata-0.14.2-py2.py3-none-any.2412.zip
Describe the bug
Dependency resolution for .whl installed extension changes depending on how the AZ-CLI was installed.
Our extension requires the
azure-mgmt-resourcegraphwhich we define insetup.py:When the az-cli is installed via
pipin a clean python distro, or via the Debian/Redhat installer, our extensions dependencies are successfully resolved to$USERHOME/.azure/cliextensions/livedata/azure/mgmt/resourcegraphOther supported means of installing the az-cli may result in the following errors when installing our .whl extension and trying to resolve dependencies
az-cli installed via brew on macOS:
Observe that the dependency is being looked for in the python distribution rather than under
.azure/cliextensionsaz-cli installed in venv where
azdev setupis ran:Observe that importlib is used from within the python distribution and is not resolving dependency from
.azure/cliextensions/livedata/module-nameTo Reproduce
azure-mgmt-resourcegraphlisted in setup.py and a command which will import this dependencyaz extension add --source /path/to/extension.whlExpected behavior
Extensions used in the az-cli should resolve their dependencies from the extension module in
.azure/cliextensionsin a consistent way when using commandsAttached is the python build wheel for our extension. It needs to have the filename extension renamed to
.whlin order to work.livedata-0.14.2-py2.py3-none-any.2412.zip