Azure / azure-cli

Azure Command-Line Interface
MIT License
4k stars 2.98k forks source link

`pip` installs `azure-cli` 2.0.73 because of the dependency on deprecated `jsmin` #19468

Closed mihaimyh closed 3 years ago

mihaimyh commented 3 years ago

I am trying to install the latest az cli, but instead I am getting an older version due to a jsmin setup error:

python -m pip install --upgrade wheel setuptools
python -m pip install --upgrade azure-cli azure-devops azure-keyvault-secrets azure-identity
python -m pip install --upgrade testresources
# python -m pip install --upgrade cryptography
python -m pip install --upgrade requests

2021-09-07T11:26:04.9965939Z   Downloading https://pkgs.dev.azure.com/mihaimyh/49255723-5232-4e9f-9501-068bf5e381a9/_packaging/e1661b2f-7e5d-484a-aab6-54c2a1cb5b0e/pypi/download/jsmin/2.2.2/jsmin-2.2.2.tar.gz (12 kB)
2021-09-07T11:26:05.2418035Z     ERROR: Command errored out with exit status 1:
2021-09-07T11:26:05.2421084Z      command: /usr/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-a863hy6i/jsmin_710895a4c3e44d21a48f56af2b8b8174/setup.py'"'"'; __file__='"'"'/tmp/pip-install-a863hy6i/jsmin_710895a4c3e44d21a48f56af2b8b8174/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-etdryiat
2021-09-07T11:26:05.2423588Z          cwd: /tmp/pip-install-a863hy6i/jsmin_710895a4c3e44d21a48f56af2b8b8174/
2021-09-07T11:26:05.2424522Z     Complete output (1 lines):
2021-09-07T11:26:05.2424978Z     error in jsmin setup command: use_2to3 is invalid.
2021-09-07T11:26:05.2425795Z     ----------------------------------------
2021-09-07T11:26:05.2429984Z WARNING: Discarding https://pkgs.dev.azure.com/mihaimyh/49255723-5232-4e9f-9501-068bf5e381a9/_packaging/e1661b2f-7e5d-484a-aab6-54c2a1cb5b0e/pypi/download/jsmin/2.2.2/jsmin-2.2.2.tar.gz#sha256=b6df99b2cd1c75d9d342e4335b535789b8da9107ec748212706ef7bbe5c2553b (from https://pkgs.dev.azure.com/mihaimyh/IngOne/_packaging/P10641-incoming/pypi/simple/jsmin/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
2021-09-07T11:26:05.2515374Z Collecting azure-cli

Successfully installed PyJWT-1.7.1 adal-1.2.7 antlr4-python3-runtime-4.9.2 applicationinsights-0.11.10 argcomplete-1.12.3 azure-batch-8.0.0 azure-cli-2.0.73 azure-cli-command-modules-nspkg-2.0.3 azure-cli-core-2.0.73 azure-cli-nspkg-3.0.4 azure-cli-telemetry-1.0.6 azure-common-1.1.27 azure-core-1.18.0 azure-cosmos-3.2.0 azure-datalake-store-0.0.52 azure-devops-6.0.0b4 azure-functions-devops-build-0.0.22 azure-graphrbac-0.60.0 azure-identity-1.6.1 azure-keyvault-1.1.0 azure-keyvault-secrets-4.3.0 azure-mgmt-advisor-2.0.1 azure-mgmt-apimanagement-2.1.0 azure-mgmt-appconfiguration-2.0.0 azure-mgmt-applicationinsights-0.1.1 azure-mgmt-authorization-0.52.0 azure-mgmt-batch-7.0.0 azure-mgmt-batchai-2.0.0 azure-mgmt-billing-0.2.0 azure-mgmt-botservice-0.2.0 azure-mgmt-cdn-3.1.0 azure-mgmt-cognitiveservices-5.0.0 azure-mgmt-compute-6.0.0 azure-mgmt-consumption-2.0.0 azure-mgmt-containerinstance-1.5.0 azure-mgmt-containerregistry-3.0.0rc17 azure-mgmt-containerservice-5.3.0 azure-mgmt-core-1.3.0 azure-mgmt-cosmosdb-0.8.0 azure-mgmt-datalake-analytics-0.2.1 azure-mgmt-datalake-nspkg-3.0.1 azure-mgmt-datalake-store-0.5.0 azure-mgmt-datamigration-0.1.0 azure-mgmt-deploymentmanager-0.1.0 azure-mgmt-devtestlabs-2.2.0 azure-mgmt-dns-2.1.0 azure-mgmt-eventgrid-2.2.0 azure-mgmt-eventhub-2.6.0 azure-mgmt-hdinsight-1.1.0 azure-mgmt-imagebuilder-0.2.1 azure-mgmt-iotcentral-1.0.0 azure-mgmt-iothub-0.8.2 azure-mgmt-iothubprovisioningservices-0.2.0 azure-mgmt-keyvault-1.1.0 azure-mgmt-kusto-0.3.0 azure-mgmt-loganalytics-0.7.0 azure-mgmt-managedservices-1.0.0 azure-mgmt-managementgroups-0.2.0 azure-mgmt-maps-0.1.0 azure-mgmt-marketplaceordering-0.2.1 azure-mgmt-media-1.1.1 azure-mgmt-monitor-0.5.2 azure-mgmt-msi-0.2.0 azure-mgmt-netapp-0.5.0 azure-mgmt-network-4.0.0 azure-mgmt-nspkg-3.0.2 azure-mgmt-policyinsights-0.3.1 azure-mgmt-privatedns-0.1.0 azure-mgmt-rdbms-1.9.0 azure-mgmt-recoveryservices-0.4.0 azure-mgmt-recoveryservicesbackup-0.4.0 azure-mgmt-redis-6.0.0 azure-mgmt-relay-0.1.0 azure-mgmt-reservations-0.3.1 azure-mgmt-resource-3.1.0 azure-mgmt-search-2.1.0 azure-mgmt-security-0.1.0 azure-mgmt-servicebus-0.6.0 azure-mgmt-servicefabric-0.2.0 azure-mgmt-signalr-0.3.0 azure-mgmt-sql-0.12.0 azure-mgmt-sqlvirtualmachine-0.4.0 azure-mgmt-storage-4.2.0 azure-mgmt-trafficmanager-0.51.0 azure-mgmt-web-0.42.0 azure-multiapi-storage-0.2.4 azure-nspkg-3.0.2 azure-storage-blob-1.5.0 azure-storage-common-1.4.2 cryptography-2.9.2 fabric-2.6.0 humanfriendly-4.18 invoke-1.6.0 isodate-0.6.0 javaproperties-0.5.1 jsondiff-1.2.0 knack-0.6.3 mock-2.0.0 msal-1.14.0 msal-extensions-0.3.0 msrest-0.6.21 msrestazure-0.6.4 oauthlib-3.1.1 pathlib2-2.3.6 pbr-5.6.0 portalocker-1.7.1 psutil-5.8.0 pyOpenSSL-19.1.0 pydocumentdb-2.3.5 python-dateutil-2.8.2 pytz-2019.1 requests-oauthlib-1.3.0 scp-0.13.6 sshtunnel-0.1.5 tabulate-0.8.9 vsts-0.1.25 vsts-cd-manager-1.0.2 websocket-client-0.56.0 wheel-0.30.0 xmltodict-0.12.0

mihaimyh commented 3 years ago

Might be related to this https://github.com/pypa/setuptools/issues/2775

yonzhan commented 3 years ago

@jiasli for awareness

tgagor commented 3 years ago

It's because you depend on jsmin, which is no longer maintained: https://github.com/tikitu/jsmin/issues/33

jiasli commented 3 years ago

setuptools deprecated use_2to3 in v58.0.0:

https://github.com/pypa/setuptools/blob/main/CHANGES.rst#v5800

Breaking Changes

2086: Removed support for 2to3 during builds. Projects should port to a unified codebase or pin to an older version of Setuptools using PEP 518 build-requires.

Azure CLI requires jsmin

https://github.com/Azure/azure-cli/blob/ea46ad4a424a63406f40f732a9d76258623fd12a/src/azure-cli/setup.py#L140

jsmin requires use_2to3, so it doesn't work with the latest setuptools (https://github.com/tikitu/jsmin/issues/33), but jsmin is not maintained anymore.

The failure causes pip to install Azure CLI 2.0.73 which is the last version that doesn't depend on jsmin (#10389).

Workaround

For now, please pin the version of setuptools until https://github.com/tikitu/jsmin/pull/34 is merged and Azure CLI starts to use the updated version, or Azure CLI drops jsmin:

pip install setuptools==57.5.0
jiasli commented 3 years ago

We have released a hotfix 2.28.1 specifically on PyPI: https://pypi.org/project/azure-cli/2.28.1/

Now Azure CLI installs correctly:

$ docker run -it --rm python /bin/bash
# pip install --upgrade setuptools
...
Successfully installed setuptools-58.0.4

# pip install azure-cli
...
Successfully installed ... azure-cli-2.28.1 azure-cli-core-2.28.1 ...

# az --version
azure-cli                         2.28.1

core                              2.28.1
telemetry                          1.0.6

Python location '/usr/local/bin/python'
Extensions directory '/root/.azure/cliextensions'

Python (Linux) 3.9.7 (default, Sep  3 2021, 20:10:26)
[GCC 10.2.1 20210110]

@mihaimyh, @tgagor, thank you so much for reporting this issue and the precise analysis.

don4of4 commented 2 years ago

Is there a permanent fix for this issue? I was surprised to still be encountering it on a new install. It looks like the JSMin change was merged.

jiasli commented 2 years ago

This issue has been fixed and the fix has been released long ago. Please try to install the latest Azure CLI (2.30.0).

tyler-suard-parker commented 4 months ago

I just tried installing azure-cli today and I am still getting this issue.

tyler-suard-parker commented 4 months ago
image

This is 3 years later and this issue still has not been fixed.