Skip to content
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

Support Python 3.11 #24494

Closed
4 tasks
jiasli opened this issue Oct 31, 2022 · 16 comments · Fixed by #26923
Closed
4 tasks

Support Python 3.11 #24494

jiasli opened this issue Oct 31, 2022 · 16 comments · Fixed by #26923
Assignees
Labels
Azure CLI Team The command of the issue is owned by Azure CLI team feature-request Packaging
Milestone

Comments

@jiasli
Copy link
Member

jiasli commented Oct 31, 2022

Description

Python 3.11 has been released on 2022-10-24: https://www.python.org/downloads/release/python-3110/

Azure CLI needs to support Python 3.11 like how we supported 3.9 (#16611), 3.10 (#19857).

TODOs

@jiasli
Copy link
Member Author

jiasli commented Oct 31, 2022

psycopg2 (introduced by #22459) fails to install on Python 3.11:

Collecting psycopg2==2.9.3
  Downloading psycopg2-2.9.3.tar.gz (380 kB)
     ------------------------------------- 380.6/380.6 kB 23.1 MB/s eta 0:00:00
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'error'
  error: subprocess-exited-with-error

  python setup.py egg_info did not run successfully.
  exit code: 1

  [23 lines of output]
  running egg_info
  creating C:\Users\username\AppData\Local\Temp\pip-pip-egg-info-4nrehwws\psycopg2.egg-info
  writing C:\Users\username\AppData\Local\Temp\pip-pip-egg-info-4nrehwws\psycopg2.egg-info\PKG-INFO
  writing dependency_links to C:\Users\username\AppData\Local\Temp\pip-pip-egg-info-4nrehwws\psycopg2.egg-info\dependency_links.txt
  writing top-level names to C:\Users\username\AppData\Local\Temp\pip-pip-egg-info-4nrehwws\psycopg2.egg-info\top_level.txt
  writing manifest file 'C:\Users\username\AppData\Local\Temp\pip-pip-egg-info-4nrehwws\psycopg2.egg-info\SOURCES.txt'

  Error: pg_config executable not found.

  pg_config is required to build psycopg2 from source.  Please add the directory
  containing pg_config to the $PATH or specify the full executable path with the
  option:

      python setup.py build_ext --pg-config /path/to/pg_config build ...

  or with the pg_config option in 'setup.cfg'.

  If you prefer to avoid building psycopg2 from source, please install the PyPI
  'psycopg2-binary' package instead.

  For further information please check the 'doc/src/install.rst' file (also at
  <https://www.psycopg.org/docs/install.html>).

  [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

Encountered error while generating package metadata.

@bebound
Copy link
Contributor

bebound commented Oct 31, 2022

I guess we need to update psycopg2 to 2.9.5
psycopg/psycopg2#1514

@bebound
Copy link
Contributor

bebound commented Nov 16, 2022

azdev's dependency pylint==2.11.1 breaks vcrpy, as wrapt 1.13 does not support 3.11.
wrapt support 3.11 in 1.14 https://wrapt.readthedocs.io/en/latest/changes.html#version-1-14-0
pylint will support 3.11 in 2.16

Version 1.14.0
Bugs Fixed
Python 3.11 dropped inspect.formatargspec() which was used in creating signature changing decorators. Now bundling a version of this function which uses Parameter and Signature from inspect module when available. The replacement function is exposed as wrapt.formatargspec() if need it for your own code.

├── pylint==2.11.1                                                                                  python code static checker
│   ├── astroid<2.9,>=2.8.0                                                                         An abstract syntax tree for Python with inference support.
│   │   ├── lazy-object-proxy>=1.4.0                                                                A fast and thorough lazy object proxy.
│   │   ├── setuptools>=20.0                                                                        Easily download, build, install, upgrade, and uninstall Python packages
│   │   └── wrapt<1.14,>=1.11
ImportError while importing test module '/mnt/vss/_work/1/s/src/azure-cli/azure/cli/command_modules/network/tests/latest/test_private_endpoint_commands.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/opt/hostedtoolcache/Python/3.11.0/x64/lib/python3.11/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
src/azure-cli/azure/cli/command_modules/network/tests/latest/test_private_endpoint_commands.py:13: in <module>
    from azure.cli.testsdk import (
src/azure-cli-testsdk/azure/cli/testsdk/__init__.py:6: in <module>
    from .scenario_tests import live_only, record_only, get_sha1_hash
src/azure-cli-testsdk/azure/cli/testsdk/scenario_tests/__init__.py:13: in <module>
    from .base import IntegrationTestBase, ReplayableTest, LiveTest
src/azure-cli-testsdk/azure/cli/testsdk/scenario_tests/base.py:14: in <module>
    import vcr
env/lib/python3.11/site-packages/vcr/__init__.py:2: in <module>
    from .config import VCR
env/lib/python3.11/site-packages/vcr/config.py:11: in <module>
    from .cassette import Cassette
env/lib/python3.11/site-packages/vcr/cassette.py:8: in <module>
    import wrapt
env/lib/python3.11/site-packages/wrapt/__init__.py:10: in <module>
    from .decorators import (adapter_factory, AdapterFactory, decorator,
env/lib/python3.11/site-packages/wrapt/decorators.py:34: in <module>
    from inspect import ismethod, isclass, formatargspec
E   ImportError: cannot import name 'formatargspec' from 'inspect' (/opt/hostedtoolcache/Python/3.11.0/x64/lib/python3.11/inspect.py)

@bebound
Copy link
Contributor

bebound commented Nov 17, 2022

vcrpy supports 3.11 in kevin1024/vcrpy#667, but it's dependency multidict does not provide wheels for 3.11. Here is the issue Wheels for CPython 3.11.

vcrpy                   Automatically mock your HTTP interactions to simplify and speed up testing
├── PyYAML              YAML parser and emitter for Python
├── six>=1.5            Python 2 and 3 compatibility utilities
├── wrapt               Module for decorators, wrappers and monkey patching.
└── yarl                Yet another URL library
    ├── idna>=2.0       Internationalized Domain Names in Applications (IDNA)
    └── multidict>=4.0  multidict implementation

PS: This dependency tree is generated with johnnydep

@mrmuskrat
Copy link

Is there a workaround for users on an operating system with python3.11 preinstalled (like Fedora 37)?

@mrmuskrat
Copy link

Is there a workaround for users on an operating system with python3.11 preinstalled (like Fedora 37)?

I did find a workaround for myself this afternoon.

Steps:

  1. Remove the azure-cli RPM: sudo dnf remove azure-cli
  2. Install Python 3.10: sudo dnf install python3.10
  3. Create a virtual environment for Python: python3.10 -m venv ~/.venv
  4. Activate the virtual environment: . ~/.venv/bin/activate
  5. Install the Azure CLI using pip: pip install azure-cli

@jiasli
Copy link
Member Author

jiasli commented Feb 6, 2023

A CVE has been reported with Program Files (x86)\Microsoft SDKs\Azure\CLI2\python310.dll: #25246, but I can't see its validity yet. Anyway, let's try to use Python 3.11 if all blockers are now gone.

@jiasli
Copy link
Member Author

jiasli commented Feb 6, 2023

PS: This dependency tree is generated with johnnydep

A more popular tool is pipdeptree: https://pypi.org/project/pipdeptree/ 😉

@peterbax117
Copy link

https://nvd.nist.gov/vuln/detail/CVE-2023-24329

With the new CVE-2023-24329, Program Files (x86)\Microsoft SDKs\Azure\CLI2\python310.dll now shows in security scans and will start to be automatically removed from environments.

CVE-2023-24329-Scan

@jiasli
Copy link
Member Author

jiasli commented Mar 15, 2023

@peterbax117, it seems the Python community still has some debate on CVE-2023-24329: python/cpython#102153

@peterbax117
Copy link

@jiasli , Thank you for the information and link. I will follow-up on this with the customer and point them to the Python community. Appreciate the quick response.

@jiasli
Copy link
Member Author

jiasli commented Mar 21, 2023

I have contacted Microsoft's internal Python community and got their reply:

Any risk here would be from people relying on urlparse to implement security measures like site blocking.

So the Python 3.10 itself is safe to use.

According to Python's official website, Python 3.10 is a fully supported version, including python310.dll. Therefore, we don't think Azure CLI is affected by CVE-2023-24329.

@luckman212
Copy link

Today I noticed azure-cli is the last remaining tool I have installed via Homebrew that depends on Python3.10. I do hope one day 3.11 is supported.

@roman-vynar
Copy link

This happens every time! Very annoying!

When the main python was 3.10, it depended from 3.9.
Now 3.11 vs 3.10.
Most likely it was the same way a long time ago as well but I can't confirm exactly.

Can we please stop hardcoding python version into this tool?
awscli has never had such issues and it's not different much.

Thank you!

@luckman212
Copy link

luckman212 commented Oct 5, 2023

Python 3.12 is now the current version. We never even got 3.11 support! I hope this hardcoded dependency on 2+ year old versions of Python will be solved at some point.

@bebound
Copy link
Contributor

bebound commented Oct 18, 2023

@provenvelocity The PR is merged but we haven't released a new CLI version. 3.11 will be supported in next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Azure CLI Team The command of the issue is owned by Azure CLI team feature-request Packaging
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants