{Packaging} Use proper PEP 508 environment marker for dependencies#21660
{Packaging} Use proper PEP 508 environment marker for dependencies#21660
Conversation
| # dependencies for specific OSes | ||
| if not sys.platform.startswith('cygwin'): | ||
| DEPENDENCIES.append('psutil~=5.9') |
There was a problem hiding this comment.
These lines were added by #15076.
This brought back #9399, making it impossible to install azure-cli on cygwin:
Collecting psutil~=5.9
Using cached psutil-5.9.0.tar.gz (478 kB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [1 lines of output]
platform cygwin is not supported
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
There was a problem hiding this comment.
This is what it becomes in generated wheel METADATA:
Requires-Dist: psutil (~=5.9) ; sys_platform != "cygwin"
There was a problem hiding this comment.
Well, anyway, latest cryptography doesn't have cygwin support either: pyca/cryptography#6834
| 'chardet~=3.0.4', | ||
| 'colorama~=0.4.4', | ||
| # On Linux, the distribution (Ubuntu, Debian, etc) and version are checked for `az feedback` | ||
| 'distro; sys_platform == "linux"', |
There was a problem hiding this comment.
This is what it becomes in generated wheel METADATA:
Requires-Dist: distro ; sys_platform == "linux"
There was a problem hiding this comment.
You should use platform_system == "Linux" .
Here: https://peps.python.org/pep-0508/#environment-markers
It says that sys_platform will be linux in python3 and linux2 in python2
There was a problem hiding this comment.
It's ok. We have dropped support for Python 2 anyway.
We also use sys.platform elsewhere:
azure-cli/src/azure-cli-core/azure/cli/core/auth/persistence.py
Lines 41 to 50 in fb805f4
There was a problem hiding this comment.
platform.system() looks weird on cygwin, and sys.platform seems to be easier:
$ python3 -c "import os; print(os.name)"
posix
$ python3 -c "import sys; print(sys.platform)"
cygwin
$ python3 -c "import platform; print(platform.system())"
CYGWIN_NT-10.0-19044
|
Packaging |

Description
Similar to microsoft/knack#257, use proper PEP 508 environment marker for dependencies.
Dependencies added by
DEPENDENCIES.append()are only added to the list of requirements if thesetup.pyis executed. However,azure-cliandazure-cli-coreare being distributed as a wheel packages andsetup.pyis not executed when installing a wheel package. Instead, dependencies are translated intoazure_cli-2.34.1-py3-none-any.whl/azure_cli-2.34.1.dist-info/METADATAwhen building wheels:What's in the wheel is determined by the packaging system, which is like taking a snapshot when packaging the wheel and the condition evaluation result is frozen into the wheel. Therefore, these conditional install won't work as expected.