-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
{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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what it becomes in generated wheel METADATA
:
Requires-Dist: psutil (~=5.9) ; sys_platform != "cygwin"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, anyway, latest cryptography
doesn't have cygwin support either: pyca/cryptography#6834
@@ -139,6 +139,8 @@ | |||
'azure-synapse-spark~=0.2.0', | |||
'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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what it becomes in generated wheel METADATA
:
Requires-Dist: distro ; sys_platform == "linux"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
if sys.platform.startswith('win'): | |
return FilePersistenceWithDataProtection(location) | |
if sys.platform.startswith('darwin'): | |
return KeychainPersistence(location, "my_service_name", "my_account_name") | |
if sys.platform.startswith('linux'): | |
return LibsecretPersistence( | |
location, | |
schema_name="my_schema_name", | |
attributes={"my_attr1": "foo", "my_attr2": "bar"} | |
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok sounds good to me
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.py
is executed. However,azure-cli
andazure-cli-core
are being distributed as a wheel packages andsetup.py
is 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/METADATA
when 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.