question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

issue due to setuptools

See original GitHub issue

Just want to make it documented in case somebody faces the same issue due to the bug in virtualenv

reorder-python-imports fails with

 Traceback (most recent call last):
  File "/home/runner/.cache/pre-commit/repoizu8jol0/py_env-python3.10/bin/reorder-python-imports", line 8, in <module>
    sys.exit(main())
  File "/home/runner/.cache/pre-commit/repoizu8jol0/py_env-python3.10/lib/python3.10/site-packages/reorder_python_imports.py", line 907, in main
    retv |= _fix_file(filename, args)
  File "/home/runner/.cache/pre-commit/repoizu8jol0/py_env-python3.10/lib/python3.10/site-packages/reorder_python_imports.py", line 475, in _fix_file
    new_contents = fix_file_contents(
  File "/home/runner/.cache/pre-commit/repoizu8jol0/py_env-python3.10/lib/python3.10/site-packages/reorder_python_imports.py", line 456, in fix_file_contents
    partitioned = step(partitioned)
  File "/home/runner/.cache/pre-commit/repoizu8jol0/py_env-python3.10/lib/python3.10/site-packages/reorder_python_imports.py", line 366, in apply_import_sorting
    sorted_blocks = sort(import_obj_to_partition.keys(), **sort_kwargs)
  File "/home/runner/.cache/pre-commit/repoizu8jol0/py_env-python3.10/lib/python3.10/site-packages/aspy/refactor_imports/sort.py", line 96, in sort
    imports_partitioned[classify_func(import_obj)].append(import_obj)
  File "/home/runner/.cache/pre-commit/repoizu8jol0/py_env-python3.10/lib/python3.10/site-packages/aspy/refactor_imports/sort.py", line 73, in classify_func
    return classify_import(obj.import_statement.module, **kwargs)
  File "/home/runner/.cache/pre-commit/repoizu8jol0/py_env-python3.10/lib/python3.10/site-packages/aspy/refactor_imports/classify.py", line 138, in classify_import
    found, module_path, is_builtin = _get_module_info(
  File "/home/runner/.cache/pre-commit/repoizu8jol0/py_env-python3.10/lib/python3.10/site-packages/aspy/refactor_imports/classify.py", line 103, in _get_module_info
    assert spec.submodule_search_locations is not None
AssertionError

solution will be to update CI to force downgrade virtualenv:

name: pre-commit

on:
  push:
    branches:
      - master
  pull_request:

jobs:
  pre-commit:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-python@v2

# Install venv to avoid issues https://github.com/pre-commit/action/issues/135
    - name: Install virtualenv
      run: |
        python -m pip install -U virtualenv==20.10.0
    - uses: pre-commit/action@v2.0.3

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
asottilecommented, Jan 5, 2022

there’s a bunch of choices:

  1. override the entry to set the variable: entry: env SETUPTOOLS_USE_DISTUTILS=stdlib reorder-python-imports
  2. since it’s runtime and not installtime you could force an older setuptools: additional_dependencies: [setuptools<60]
1reaction
beliaev-maksimcommented, Jan 5, 2022

the proper workaround should be SETUPTOOLS_USE_DISTUTILS=stdlib

I confirm that this also solves the issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · pypa/setuptools - GitHub
Official project repository for the Setuptools build system - Issues · pypa/setuptools. ... Test suite failing due to deprecated --rsyncdir.
Read more >
sudo pip install setuptools --upgrade error - Stack Overflow
So far, so good :) My problem comes when I try to run: pip install --upgrade setuptools. The installation appears to work OK,...
Read more >
History - setuptools 65.6.3.post20221220 documentation
#2953: Fixed a bug that easy install incorrectly parsed Python 3.10 version string. #3006: Fixed startup performance issue of Python interpreter due to...
Read more >
2020635 – pip install fails if the setuptools weak dep is not ...
Description of problem: pip install fails if setuptools is not installed on the system. It is a weak dependency, but those are meant...
Read more >
setuptools 6.1 - PyPI
To install setuptools on Python 2.4 or Python 2.5, use the bootstrap ... Issue #262: Fixed regression in pip install due to egg-info...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found