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

virtualenv 20.22.0 breaks on python3.9 on some conditions #2551

Closed
yakky opened this issue Apr 20, 2023 · 7 comments
Closed

virtualenv 20.22.0 breaks on python3.9 on some conditions #2551

yakky opened this issue Apr 20, 2023 · 7 comments
Labels

Comments

@yakky
Copy link

yakky commented Apr 20, 2023

Issue

Starting from release of virtualenv 20.22.0 our CI using tox breaks upon tox virtualenv creation with AttributeError: module 'virtualenv.create.via_global_ref.builtin.cpython.mac_os' has no attribute 'CPython2macOsArmFramework' error

The error happens when virtualenv is installed at system or user level (ie: by running pip install --user "virtualenv==20.22.0" but I can't reproduce this in the python:3.9 image or in a virtualenv using the same interpreter that fails

Environment

Provide at least:

  • OS: Ubuntu 22.04

  • pip list of the host python where virtualenv is installed:

$ python3.9 -mpip list --user
Package Version


distlib 0.3.6
filelock 3.12.0
platformdirs 3.2.0
virtualenv 20.22.0


**Output of the virtual environment creation**


```console
36 setup logging to NOTSET [DEBUG report:37]
41 find interpreter for spec PythonSpec(path=/usr/bin/python3.9) [INFO builtin:58]
41 proposed PythonInfo(spec=CPython3.9.16.final.0-64, exe=/usr/bin/python3.9, platform=linux, version='3.9.16 (main, Dec  7 2022, 01:12:08) \n[GCC 11.3.0]', encoding_fs_io=utf-8-utf-8) [INFO builtin:65]
41 accepted PythonInfo(spec=CPython3.9.16.final.0-64, exe=/usr/bin/python3.9, platform=linux, version='3.9.16 (main, Dec  7 2022, 01:12:08) \n[GCC 11.3.0]', encoding_fs_io=utf-8-utf-8) [DEBUG builtin:67]
42 filesystem is case-sensitive [DEBUG info:26]
Traceback (most recent call last):
File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
  return _run_code(code, main_globals, None,
File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
  exec(code, run_globals)
File "/home/yakky/.local/lib/python3.9/site-packages/virtualenv/__main__.py", line 71, in <module>
  run_with_catch()  # pragma: no cov
File "/home/yakky/.local/lib/python3.9/site-packages/virtualenv/__main__.py", line 56, in run_with_catch
  run(args, options, env)
File "/home/yakky/.local/lib/python3.9/site-packages/virtualenv/__main__.py", line 18, in run
  session = cli_run(args, options, env)
File "/home/yakky/.local/lib/python3.9/site-packages/virtualenv/run/__init__.py", line 30, in cli_run
  of_session = session_via_cli(args, options, setup_logging, env)
File "/home/yakky/.local/lib/python3.9/site-packages/virtualenv/run/__init__.py", line 48, in session_via_cli
  parser, elements = build_parser(args, options, setup_logging, env)
File "/home/yakky/.local/lib/python3.9/site-packages/virtualenv/run/__init__.py", line 74, in build_parser
  CreatorSelector(interpreter, parser),
File "/home/yakky/.local/lib/python3.9/site-packages/virtualenv/run/plugin/creators.py", line 15, in __init__
  creators, self.key_to_meta, self.describe, self.builtin_key = self.for_interpreter(interpreter)
File "/home/yakky/.local/lib/python3.9/site-packages/virtualenv/run/plugin/creators.py", line 22, in for_interpreter
  for key, creator_class in cls.options("virtualenv.create").items():
File "/home/yakky/.local/lib/python3.9/site-packages/virtualenv/run/plugin/base.py", line 46, in options
  cls._OPTIONS = cls.entry_points_for(key)
File "/home/yakky/.local/lib/python3.9/site-packages/virtualenv/run/plugin/base.py", line 25, in entry_points_for
  return OrderedDict((e.name, e.load()) for e in cls.entry_points().get(key, {}))
File "/home/yakky/.local/lib/python3.9/site-packages/virtualenv/run/plugin/base.py", line 25, in <genexpr>
  return OrderedDict((e.name, e.load()) for e in cls.entry_points().get(key, {}))
File "/usr/lib/python3.9/importlib/metadata.py", line 88, in load
  return functools.reduce(getattr, attrs, module)
AttributeError: module 'virtualenv.create.via_global_ref.builtin.cpython.mac_os' has no attribute 'CPython2macOsArmFramework'
@yakky yakky added the bug label Apr 20, 2023
@yakky yakky changed the title virtualenv 20.22.0 breaks on python3.9 on some virtualenv 20.22.0 breaks on python3.9 on some conditions Apr 20, 2023
@gaborbernat
Copy link
Contributor

Almost certainly this is a bad installation where you have it installed both at system and user level and they conflict.

@tgs
Copy link

tgs commented Apr 20, 2023

My organization sets --system-site-packages by default, to allow crypto packages to be upgraded system-wide when needed, and we are also encountering this bug.

@gaborbernat
Copy link
Contributor

Sounds like you were using an unsupported feature. We plan to do no changes here .

@gaborbernat gaborbernat closed this as not planned Won't fix, can't repro, duplicate, stale Apr 20, 2023
@gaborbernat
Copy link
Contributor

My organization sets --system-site-packages by default, to allow crypto packages to be upgraded system-wide when needed, and we are also encountering this bug.

This feels like the wrong solution to the problem 😊

@yakky
Copy link
Author

yakky commented Apr 20, 2023

@gaborbernat thanks for the feedback, I guess is something wrong with my setup even if I am struggling to understand what's going on 🤷

@hcstern
Copy link

hcstern commented Apr 20, 2023

Hi, I'm seeing this as well when trying to install hatch locally via pip install --user hatch on linux. The install succeeds but then actually running hatch fails presumably trying to create the venv.

My system virtualenv is version 20.14.1 and 20.21.1 was working but 20.22.0 breaks with the same "has no attribute 'CPython2macOsArmFramework'" message.

I assume this is because CPython2macOsArmFramework was removed when python2 support was dropped, but the name is getting passed from the old version somewhere to the new version, which doesn't know about it.

It seems strange that you just can't have both a local version and a system version of virtualenv installed, but then again python building and packaging has been strange for a couple decades...

@buhtz
Copy link

buhtz commented Dec 29, 2023

Have the same problem with hatch and tox.
It can be fixed with just removing "virtuelenv" from the system. It seems that hatch/tox in that case using another way to create virtual environments.

btw: What is an unsupported feature?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants