Skip to content

[Extension] fix loading wrong metadata for wheel type extension#13222

Merged
haroldrandom merged 3 commits intoAzure:devfrom
haroldrandom:fix-loading-ext-metadata
Apr 28, 2020
Merged

[Extension] fix loading wrong metadata for wheel type extension#13222
haroldrandom merged 3 commits intoAzure:devfrom
haroldrandom:fix-loading-ext-metadata

Conversation

@haroldrandom
Copy link
Contributor

@haroldrandom haroldrandom commented Apr 28, 2020

Description
With this #12782 merged, the ability to load metadata from a Python Package is enhanced, but the algorithm is to travel all folders under a specific extension home folder.

for dist_info_dirname in info_dirs:
try:
ext_whl_metadata = pkginfo.Wheel(dist_info_dirname)
metadata.update(vars(ext_whl_metadata))
except ValueError:
logger.warning('extension % contains invalid metadata for Python Package', self.name)

The problem is that if there are other folder named with .dist-info, it will load their metadata too, which will show a wrong extension version. Such as azure-iot and alias, as it has dependecies and CLI will place those dependecies inside the same folder for azure-iot.

$ ll ~/.azure/cliextensions/azure-iot           
total 568K
drwxrwxr-x 3 harold harold 4.0K Apr 28 11:25 attr
drwxrwxr-x 2 harold harold 4.0K Apr 28 11:25 attrs-19.3.0.dist-info
drwxrwxr-x 9 harold harold 4.0K Apr 28 11:25 azext_iot
drwxrwxr-x 2 harold harold 4.0K Apr 28 11:25 azure_iot-0.9.1.dist-info
-rw-rw-r-- 1 harold harold 289K Apr 28 11:25 azure_iot-0.9.1-py2.py3-none-any.whl
drwxrwxr-x 2 harold harold 4.0K Apr 28 11:25 bin
-rw-rw-r-- 1 harold harold  126 Apr 28 11:25 easy_install.py
drwxrwxr-x 6 harold harold 4.0K Apr 28 11:25 jsonschema
drwxrwxr-x 2 harold harold 4.0K Apr 28 11:25 jsonschema-3.0.2.dist-info
drwxrwxr-x 4 harold harold 4.0K Apr 28 11:25 paho
drwxrwxr-x 2 harold harold 4.0K Apr 28 11:25 paho_mqtt-1.5.0.dist-info
drwxrwxr-x 5 harold harold 4.0K Apr 28 11:25 pkg_resources
-rwxrwxr-x 1 harold harold 166K Apr 28 11:25 pvectorc.cpython-36m-x86_64-linux-gnu.so
drwxrwxr-x 2 harold harold 4.0K Apr 28 11:25 __pycache__
drwxrwxr-x 3 harold harold 4.0K Apr 28 11:25 pyrsistent
drwxrwxr-x 2 harold harold 4.0K Apr 28 11:25 pyrsistent-0.16.0.dist-info
-rw-rw-r-- 1 harold harold   23 Apr 28 11:25 _pyrsistent_version.py
drwxrwxr-x 6 harold harold 4.0K Apr 28 11:25 setuptools
drwxrwxr-x 2 harold harold 4.0K Apr 28 11:25 setuptools-46.1.3.dist-info
drwxrwxr-x 2 harold harold 4.0K Apr 28 11:25 six-1.14.0.dist-info
-rw-rw-r-- 1 harold harold  34K Apr 28 11:25 six.py

That's why causing this bug.

Testing Guide
Before fix, try install azure-iot extension, then az extension list -o table it will show a wrong version instead of its current version 0.9.1
After fix, it will show 0.9.1

History Notes


This checklist is used to make sure that common guidelines for a pull request are followed.

@haroldrandom haroldrandom self-assigned this Apr 28, 2020
@haroldrandom haroldrandom added this to the S170 milestone Apr 28, 2020
@haroldrandom haroldrandom added Core CLI core infrastructure Extensions `az extension` commands or extension infrastructure labels Apr 28, 2020
@yonzhan
Copy link
Collaborator

yonzhan commented Apr 28, 2020

add to S170

@haroldrandom haroldrandom marked this pull request as ready for review April 28, 2020 06:23
@haroldrandom haroldrandom changed the title [Core] fix loading wrong metadata for wheel type extension [Extension] fix loading wrong metadata for wheel type extension Apr 28, 2020
Copy link
Member

@fengzhou-msft fengzhou-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

verified locally with azure-iot.

@haroldrandom
Copy link
Contributor Author

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

Labels

Core CLI core infrastructure Extensions `az extension` commands or extension infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

az extension add -n aro --index https://az.aroapp.io/stable fails azure-iot fails install with v2.5.0

3 participants