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

Failure with python 3.10 #135

Closed
Goldziher opened this issue Dec 28, 2021 · 6 comments
Closed

Failure with python 3.10 #135

Goldziher opened this issue Dec 28, 2021 · 6 comments

Comments

@Goldziher
Copy link

Goldziher commented Dec 28, 2021

Hi there,

I am getting a failure in github with the default config suggested in the README. It worked like a charm until today - I am not sure what changed, perhaps github changed to use python 3.10 by default, or maybe it was the fact I ran pre-commit autoupdate. When I run pre-commit run --all-files locally in python 3.9.7 it works great.

I get the following stack trace:

An unexpected error has occurred: CalledProcessError: command: ('/home/runner/.cache/pre-commit/repo7sz6wk53/py_env-python3/bin/python', '-mpip', 'install', '.')
return code: 2
expected return code: 0
stdout:
    Processing /home/runner/.cache/pre-commit/repo7sz6wk53
      Installing build dependencies: started
      Installing build dependencies: finished with status 'done'
      Getting requirements to build wheel: started
      Getting requirements to build wheel: finished with status 'done'
    
stderr:
    ERROR: Exception:
    Traceback (most recent call last):
      File "/home/runner/.cache/pre-commit/repo7sz6wk53/py_env-python3/lib/python3.10/site-packages/pip/_internal/cli/base_command.py", line 164, in exc_logging_wrapper
        status = run_func(*args)
      File "/home/runner/.cache/pre-commit/repo7sz6wk53/py_env-python3/lib/python3.10/site-packages/pip/_internal/cli/req_command.py", line 205, in wrapper
        return func(self, options, args)
      File "/home/runner/.cache/pre-commit/repo7sz6wk53/py_env-python3/lib/python3.10/site-packages/pip/_internal/commands/install.py", line 338, in run
        requirement_set = resolver.resolve(
      File "/home/runner/.cache/pre-commit/repo7sz6wk53/py_env-python3/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 73, in resolve
        collected = self.factory.collect_root_requirements(root_reqs)
      File "/home/runner/.cache/pre-commit/repo7sz6wk53/py_env-python3/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 468, in collect_root_requirements
        req = self._make_requirement_from_install_req(
      File "/home/runner/.cache/pre-commit/repo7sz6wk53/py_env-python3/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 430, in _make_requirement_from_install_req
        cand = self._make_candidate_from_link(
      File "/home/runner/.cache/pre-commit/repo7sz6wk53/py_env-python3/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 201, in _make_candidate_from_link
        self._link_candidate_cache[link] = LinkCandidate(
      File "/home/runner/.cache/pre-commit/repo7sz6wk53/py_env-python3/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 281, in __init__
        super().__init__(
      File "/home/runner/.cache/pre-commit/repo7sz6wk53/py_env-python3/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 156, in __init__
        self.dist = self._prepare()
      File "/home/runner/.cache/pre-commit/repo7sz6wk53/py_env-python3/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 225, in _prepare
        dist = self._prepare_distribution()
      File "/home/runner/.cache/pre-commit/repo7sz6wk53/py_env-python3/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 292, in _prepare_distribution
        return preparer.prepare_linked_requirement(self._ireq, parallel_builds=True)
      File "/home/runner/.cache/pre-commit/repo7sz6wk53/py_env-python3/lib/python3.10/site-packages/pip/_internal/operations/prepare.py", line 482, in prepare_linked_requirement
        return self._prepare_linked_requirement(req, parallel_builds)
      File "/home/runner/.cache/pre-commit/repo7sz6wk53/py_env-python3/lib/python3.10/site-packages/pip/_internal/operations/prepare.py", line 546, in _prepare_linked_requirement
        dist = _get_prepared_distribution(
      File "/home/runner/.cache/pre-commit/repo7sz6wk53/py_env-python3/lib/python3.10/site-packages/pip/_internal/operations/prepare.py", line 58, in _get_prepared_distribution
        abstract_dist.prepare_distribution_metadata(finder, build_isolation)
      File "/home/runner/.cache/pre-commit/repo7sz6wk53/py_env-python3/lib/python3.10/site-packages/pip/_internal/distributions/sdist.py", line 47, in prepare_distribution_metadata
        self._install_build_reqs(finder)
      File "/home/runner/.cache/pre-commit/repo7sz6wk53/py_env-python3/lib/python3.10/site-packages/pip/_internal/distributions/sdist.py", line 106, in _install_build_reqs
        build_reqs = self._get_build_requires_wheel()
      File "/home/runner/.cache/pre-commit/repo7sz6wk53/py_env-python3/lib/python3.10/site-packages/pip/_internal/distributions/sdist.py", line 83, in _get_build_requires_wheel
        return backend.get_requires_for_build_wheel()
      File "/home/runner/.cache/pre-commit/repo7sz6wk53/py_env-python3/lib/python3.10/site-packages/pip/_vendor/pep517/wrappers.py", line 172, in get_requires_for_build_wheel
        return self._call_hook('get_requires_for_build_wheel', {
      File "/home/runner/.cache/pre-commit/repo7sz6wk53/py_env-python3/lib/python3.10/site-packages/pip/_vendor/pep517/wrappers.py", line 332, in _call_hook
        raise BackendUnavailable(data.get('traceback', ''))
    pip._vendor.pep517.wrappers.BackendUnavailable: Traceback (most recent call last):
      File "/home/runner/.cache/pre-commit/repo7sz6wk53/py_env-python3/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 89, in _build_backend
        obj = import_module(mod_path)
      File "/opt/hostedtoolcache/Python/3.10.1/x64/lib/python3.10/importlib/__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
      File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
      File "<frozen importlib._bootstrap>", line 992, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
      File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
      File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
      File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
      File "<frozen importlib._bootstrap_external>", line 883, in exec_module
      File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
      File "/tmp/pip-build-env-6fx0wzkd/overlay/lib/python3.10/site-packages/poetry/core/masonry/__init__.py", line 10, in <module>
        from .builder import Builder
      File "/tmp/pip-build-env-6fx0wzkd/overlay/lib/python3.10/site-packages/poetry/core/masonry/builder.py", line 7, in <module>
        from .builders.sdist import SdistBuilder
      File "/tmp/pip-build-env-6fx0wzkd/overlay/lib/python3.10/site-packages/poetry/core/masonry/builders/__init__.py", line 2, in <module>
        from .wheel import WheelBuilder
      File "/tmp/pip-build-env-6fx0wzkd/overlay/lib/python3.10/site-packages/poetry/core/masonry/builders/wheel.py", line 23, in <module>
        from packaging.tags import sys_tags
      File "/tmp/pip-build-env-6fx0wzkd/overlay/lib/python3.10/site-packages/poetry/core/_vendor/packaging/tags.py", line 7, in <module>
        import distutils.util
      File "/home/runner/.cache/pre-commit/repo7sz6wk53/py_env-python3/lib/python3.10/site-packages/_distutils_hack/__init__.py", line 92, in create_module
        return importlib.import_module('setuptools._distutils')
      File "/opt/hostedtoolcache/Python/3.10.1/x64/lib/python3.10/importlib/__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
    ModuleNotFoundError: No module named 'setuptools'
    
    
Check the log at /home/runner/.cache/pre-commit/pre-commit.log
Error: The process '/opt/hostedtoolcache/Python/3.10.1/x64/bin/pre-commit' failed with exit code 3

You can see my CI run here: https://github.com/Goldziher/pydantic-factories/runs/4649830101?check_suite_focus=true

This is my pre-commit config:

repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.1.0
    hooks:
      - id: check-ast
      - id: check-case-conflict
      - id: check-merge-conflict
      - id: debug-statements
      - id: end-of-file-fixer
        exclude: "\\.idea/(.)*"
      - id: trailing-whitespace
  - repo: https://github.com/asottile/pyupgrade
    rev: v2.30.0
    hooks:
      - id: pyupgrade
        args: ["--py37-plus"]
  - repo: https://github.com/pycqa/isort
    rev: 5.10.1
    hooks:
      - id: isort
  - repo: https://github.com/psf/black
    rev: 21.12b0
    hooks:
      - id: black
        args: [--config=./pyproject.toml]
  - repo: https://github.com/pycqa/bandit
    rev: 1.7.1
    hooks:
      - id: bandit
        args: ["-iii", "-ll", "-s=B308,B703"]
  - repo: https://gitlab.com/pycqa/flake8
    rev: 3.9.2
    hooks:
      - id: flake8
        additional_dependencies:
          [
            "flake8-bugbear",
            "flake8-comprehensions",
            "flake8-mutable",
            "flake8-print",
            "flake8-simplify",
            "flake8-type-checking",
          ]
  - repo: https://github.com/pycqa/pylint
    rev: "v2.12.2"
    hooks:
      - id: pylint
        exclude: "test_*"
        args:
          [
            "--unsafe-load-any-extension=y"
          ]
        additional_dependencies: [
          pydantic,
          faker,
          pytest,
          beanie
        ]
  - repo: https://github.com/pre-commit/mirrors-mypy
    rev: "v0.930"
    hooks:
      - id: mypy
        additional_dependencies: [
          pydantic,
          faker
        ]
@cmj0121
Copy link

cmj0121 commented Dec 28, 2021

same issue too

There is a work-around method: install virtualenv==20.10.0 via pip install -U virtualenv==20.10.0 before execute pre-commit, but do not know the root casue.

@bitphage
Copy link

Confirming the issue, we also started to get this a few hours ago. Also we experienced this error several days ago in our install scripts, and applied a workaround export SETUPTOOLS_USE_DISTUTILS=stdlib mentioned in pypa/setuptools#2353

@asottile
Copy link
Member

yes this is a bug in virtualenv / setuptools / pip

I'd recommend using https://pre-commit.ci instead which does not suffer from this bug

@Goldziher
Copy link
Author

Why are you closing the issue if its actual? The source might not be in this action par se, but it suffers from it.

@asottile
Copy link
Member

because the bug is not here, I can't influence or guide the discussion / changes that need to happen to fix it. I would rather direct users to the actual problem where they can adequately communicate with the stakeholders and drive a fix

@asottile
Copy link
Member

for those looking for a summary on where to follow up I've collected this to one place here: pre-commit/pre-commit#2178 (comment)

@pre-commit pre-commit locked as resolved and limited conversation to collaborators Dec 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

4 participants