Closed buhtz closed 6 months ago
This is a really strange error. I admit. I have no clue currently what’s happening in your environment t it behaves like this.
how does tox -e test
behaves ?
Are there any steps to prepare tox (except installing it) that are not documented somewhere and I might have missed?
$ tox -e test
test: internal error
Traceback (most recent call last):
File "/home/user/.local/lib/python3.9/site-packages/tox/session/cmd/run/single.py", line 46, in _evaluate
tox_env.setup()
File "/home/user/.local/lib/python3.9/site-packages/tox/tox_env/api.py", line 247, in setup
self._setup_env()
File "/home/user/.local/lib/python3.9/site-packages/tox/tox_env/python/runner.py", line 107, in _setup_env
super()._setup_env()
File "/home/user/.local/lib/python3.9/site-packages/tox/tox_env/python/api.py", line 199, in _setup_env
self.ensure_python_env()
File "/home/user/.local/lib/python3.9/site-packages/tox/tox_env/python/api.py", line 203, in ensure_python_env
conf = self.python_cache()
File "/home/user/.local/lib/python3.9/site-packages/tox/tox_env/python/virtual_env/api.py", line 77, in python_cache
base = super().python_cache()
File "/home/user/.local/lib/python3.9/site-packages/tox/tox_env/python/api.py", line 240, in python_cache
"version_info": list(self.base_python.version_info),
File "/home/user/.local/lib/python3.9/site-packages/tox/tox_env/python/api.py", line 250, in base_python
self._base_python = self._get_python(base_pythons)
File "/home/user/.local/lib/python3.9/site-packages/tox/tox_env/python/virtual_env/api.py", line 134, in _get_python
interpreter = self.creator.interpreter
File "/home/user/.local/lib/python3.9/site-packages/tox/tox_env/python/virtual_env/api.py", line 126, in creator
return self.session.creator
File "/home/user/.local/lib/python3.9/site-packages/tox/tox_env/python/virtual_env/api.py", line 107, in session
self._virtualenv_session = session_via_cli(env_dir, options=None, setup_logging=False, env=env)
File "/home/user/.local/lib/python3.9/site-packages/virtualenv/run/__init__.py", line 49, in session_via_cli
parser, elements = build_parser(args, options, setup_logging, env)
File "/home/user/.local/lib/python3.9/site-packages/virtualenv/run/__init__.py", line 82, in build_parser
CreatorSelector(interpreter, parser),
File "/home/user/.local/lib/python3.9/site-packages/virtualenv/run/plugin/creators.py", line 24, in __init__
creators, self.key_to_meta, self.describe, self.builtin_key = self.for_interpreter(interpreter)
File "/home/user/.local/lib/python3.9/site-packages/virtualenv/run/plugin/creators.py", line 31, in for_interpreter
for key, creator_class in cls.options("virtualenv.create").items():
File "/home/user/.local/lib/python3.9/site-packages/virtualenv/run/plugin/base.py", line 45, in options
cls._OPTIONS = cls.entry_points_for(key)
File "/home/user/.local/lib/python3.9/site-packages/virtualenv/run/plugin/base.py", line 24, in entry_points_for
return OrderedDict((e.name, e.load()) for e in cls.entry_points().get(key, {}))
File "/home/user/.local/lib/python3.9/site-packages/virtualenv/run/plugin/base.py", line 24, in <genexpr>
return OrderedDict((e.name, e.load()) for e in cls.entry_points().get(key, {}))
File "/home/user/.local/lib/python3.9/site-packages/setuptools/_vendor/importlib_metadata/__init__.py", line 210, in load
return functools.reduce(getattr, attrs, module)
AttributeError: module 'virtualenv.create.via_global_ref.builtin.cpython.mac_os' has no attribute 'CPython2macOsFramework'
test: FAIL code 2 (0.03 seconds)
evaluation failed :( (0.28 seconds)
I might have found a hot trail. Totally independent from tox and pydoctor I accidentally observed a similar error using hatch
to create a virtual environment. The error output of hatch (see below) is bit easier to read so I realized the problem is about the package virtualenv
. I uninstalled it via python3 -m pip uninstall virtuelenv
. Then hatch
worked.
Then I tried tox on pydoctor. And it worked.
I am not enough into the details about virtual environments or the package virtuelenv. So I am not able to decide where and if I should open a bug report. Maybe related to https://github.com/pypa/virtualenv/issues/2551. Maybe I encountered the first time a real use case why I should use virtual environments. Currently I do avoid them as much as possible. I am a but stubborn about this topic. :smile:
$ hatch env create
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /home/user/.local/lib/python3.9/site-packages/hatch/cli/__init__.py:221 in main │
│ │
│ 218 │
│ 219 def main(): # no cov │
│ 220 │ try: │
│ ❱ 221 │ │ return hatch(prog_name='hatch', windows_expand_args=False) │
│ 222 │ except Exception: # noqa: BLE001 │
│ 223 │ │ from rich.console import Console │
│ 224 │
│ │
│ /home/user/.local/lib/python3.9/site-packages/click/core.py:1157 in __call__ │
│ │
│ /home/user/.local/lib/python3.9/site-packages/click/core.py:1078 in main │
│ │
│ /home/user/.local/lib/python3.9/site-packages/click/core.py:1688 in invoke │
│ │
│ /home/user/.local/lib/python3.9/site-packages/click/core.py:1688 in invoke │
│ │
│ /home/user/.local/lib/python3.9/site-packages/click/core.py:1434 in invoke │
│ │
│ /home/user/.local/lib/python3.9/site-packages/click/core.py:783 in invoke │
│ │
│ /home/user/.local/lib/python3.9/site-packages/click/decorators.py:45 in new_func │
│ │
│ /home/user/.local/lib/python3.9/site-packages/hatch/cli/env/create.py:38 in create │
│ │
│ 35 │ │ │ │
│ 36 │ │ │ app.abort(f'Environment `{env}` is incompatible: {e}') │
│ 37 │ │ │
│ ❱ 38 │ │ app.prepare_environment(environment) │
│ 39 │ │
│ 40 │ if incompatible: │
│ 41 │ │ num_incompatible = len(incompatible) │
│ │
│ /home/user/.local/lib/python3.9/site-packages/hatch/cli/application.py:89 in prepare_environment │
│ │
│ 86 │ │ │ self.env_metadata.reset(environment) │
│ 87 │ │ │ │
│ 88 │ │ │ with self.status(f'Creating environment: {environment.name}'): │
│ ❱ 89 │ │ │ │ environment.create() │
│ 90 │ │ │ │
│ 91 │ │ │ if not environment.skip_install: │
│ 92 │ │ │ │ if environment.pre_install_commands: │
│ │
│ /home/user/.local/lib/python3.9/site-packages/hatch/env/virtual.py:103 in create │
│ │
│ 100 """ │
│ 101 │ │ │ │ ) │
│ 102 │ │ │
│ ❱ 103 │ │ self.virtual_env.create(self.parent_python, allow_system_packages=self.config.ge │
│ 104 │ │
│ 105 │ def remove(self): │
│ 106 │ │ self.virtual_env.remove() │
│ │
│ /home/user/.local/lib/python3.9/site-packages/hatch/venv/core.py:59 in create │
│ │
│ 56 │ │ # Decrease verbosity since the virtualenv CLI defaults to something like +2 verb │
│ 57 │ │ add_verbosity_flag(command, self.verbosity, adjustment=-1) │
│ 58 │ │ │
│ ❱ 59 │ │ cli_run(command) │
│ 60 │ │
│ 61 │ def remove(self): │
│ 62 │ │ self.directory.remove() │
│ │
│ /home/user/.local/lib/python3.9/site-packages/virtualenv/run/__init__.py:31 in cli_run │
│ │
│ 28 │ :return: the session object of the creation (its structure for now is experimental a │
│ 29 │ """ │
│ 30 │ env = os.environ if env is None else env │
│ ❱ 31 │ of_session = session_via_cli(args, options, setup_logging, env) │
│ 32 │ with of_session: │
│ 33 │ │ of_session.run() │
│ 34 │ return of_session │
│ │
│ /home/user/.local/lib/python3.9/site-packages/virtualenv/run/__init__.py:49 in session_via_cli │
│ │
│ 46 │ :return: the session object of the creation (its structure for now is experimental a │
│ 47 │ """ # noqa: D205 │
│ 48 │ env = os.environ if env is None else env │
│ ❱ 49 │ parser, elements = build_parser(args, options, setup_logging, env) │
│ 50 │ options = parser.parse_args(args) │
│ 51 │ creator, seeder, activators = tuple(e.create(options) for e in elements) # create t │
│ 52 │ return Session( │
│ │
│ /home/user/.local/lib/python3.9/site-packages/virtualenv/run/__init__.py:82 in build_parser │
│ │
│ 79 │ │ msg = f"failed to find interpreter for {discover}" │
│ 80 │ │ raise RuntimeError(msg) │
│ 81 │ elements = [ │
│ ❱ 82 │ │ CreatorSelector(interpreter, parser), │
│ 83 │ │ SeederSelector(interpreter, parser), │
│ 84 │ │ ActivationSelector(interpreter, parser), │
│ 85 │ ] │
│ │
│ /home/user/.local/lib/python3.9/site-packages/virtualenv/run/plugin/creators.py:24 in __init__ │
│ │
│ 21 │
│ 22 class CreatorSelector(ComponentBuilder): │
│ 23 │ def __init__(self, interpreter, parser) -> None: │
│ ❱ 24 │ │ creators, self.key_to_meta, self.describe, self.builtin_key = self.for_interpret │
│ 25 │ │ super().__init__(interpreter, parser, "creator", creators) │
│ 26 │ │
│ 27 │ @classmethod │
│ │
│ /home/user/.local/lib/python3.9/site-packages/virtualenv/run/plugin/creators.py:31 in │
│ for_interpreter │
│ │
│ 28 │ def for_interpreter(cls, interpreter): │
│ 29 │ │ key_to_class, key_to_meta, builtin_key, describe = OrderedDict(), {}, None, None │
│ 30 │ │ errors = defaultdict(list) │
│ ❱ 31 │ │ for key, creator_class in cls.options("virtualenv.create").items(): │
│ 32 │ │ │ if key == "builtin": │
│ 33 │ │ │ │ msg = "builtin creator is a reserved name" │
│ 34 │ │ │ │ raise RuntimeError(msg) │
│ │
│ /home/user/.local/lib/python3.9/site-packages/virtualenv/run/plugin/base.py:45 in options │
│ │
│ 42 │ @classmethod │
│ 43 │ def options(cls, key): │
│ 44 │ │ if cls._OPTIONS is None: │
│ ❱ 45 │ │ │ cls._OPTIONS = cls.entry_points_for(key) │
│ 46 │ │ return cls._OPTIONS │
│ 47 │ │
│ 48 │ def add_selector_arg_parse(self, name, choices): │
│ │
│ /home/user/.local/lib/python3.9/site-packages/virtualenv/run/plugin/base.py:24 in │
│ entry_points_for │
│ │
│ 21 │ def entry_points_for(cls, key): │
│ 22 │ │ if sys.version_info >= (3, 10) or importlib_metadata_version >= (3, 6): │
│ 23 │ │ │ return OrderedDict((e.name, e.load()) for e in cls.entry_points().select(gro │
│ ❱ 24 │ │ return OrderedDict((e.name, e.load()) for e in cls.entry_points().get(key, {})) │
│ 25 │ │
│ 26 │ @staticmethod │
│ 27 │ def entry_points(): │
│ │
│ /home/user/.local/lib/python3.9/site-packages/virtualenv/run/plugin/base.py:24 in <genexpr> │
│ │
│ 21 │ def entry_points_for(cls, key): │
│ 22 │ │ if sys.version_info >= (3, 10) or importlib_metadata_version >= (3, 6): │
│ 23 │ │ │ return OrderedDict((e.name, e.load()) for e in cls.entry_points().select(gro │
│ ❱ 24 │ │ return OrderedDict((e.name, e.load()) for e in cls.entry_points().get(key, {})) │
│ 25 │ │
│ 26 │ @staticmethod │
│ 27 │ def entry_points(): │
│ │
│ /home/user/.local/lib/python3.9/site-packages/setuptools/_vendor/importlib_metadata/__init__.py: │
│ 210 in load │
│ │
│ 207 │ │ match = self.pattern.match(self.value) │
│ 208 │ │ module = import_module(match.group('module')) │
│ 209 │ │ attrs = filter(None, (match.group('attr') or '').split('.')) │
│ ❱ 210 │ │ return functools.reduce(getattr, attrs, module) │
│ 211 │ │
│ 212 │ @property │
│ 213 │ def module(self): │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
AttributeError: module 'virtualenv.create.via_global_ref.builtin.cpython.mac_os' has no attribute
'CPython2macOsFramework'
I guess what is missing in the contributors docu is how to install pydoctor for developers (e.g. "python3 -m pip install -e ."). And why is there a "mac_os" in this output? I do run these tests on Debian 11 on an AMD64.