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

Avoid distutils imports in tests #11521

Closed
1 task done
hroncok opened this issue Oct 17, 2022 · 0 comments · Fixed by #11522
Closed
1 task done

Avoid distutils imports in tests #11521

hroncok opened this issue Oct 17, 2022 · 0 comments · Fixed by #11522
Labels
type: bug A confirmed bug or unintended behavior

Comments

@hroncok
Copy link
Contributor

hroncok commented Oct 17, 2022

Description

When running pip's tests, it still imports from distutils directly. I'd like to work on a PR that will remove or conditionalize this dependency.

To check, I've used Python 3.11 with distutils removed.

First, I get:

$ nox -e test-3.11
ImportError while loading conftest '/home/churchyard/Dokumenty/pypa/pip/tests/conftest.py'.
tests/conftest.py:41: in <module>
    from tests.lib import DATA_DIR, SRC_DIR, PipTestEnvironment, TestData
tests/lib/__init__.py:42: in <module>
    from tests.lib.venv import VirtualEnvironment
tests/lib/venv.py:11: in <module>
    import virtualenv as _virtualenv
.nox/test-3-11/lib/python3.11/site-packages/virtualenv.py:24: in <module>
    import distutils.spawn
E   ModuleNotFoundError: No module named 'distutils'

Then I upgrade virtualenv, edit tests/requirements.txt, and skip some tests due to #8273

$ pytest_k='not test_from_link_vcs_with_source_dir_obtains_commit_id and not test_from_link_vcs_without_source_dir and not test_should_cache_git_sha'
$ nox -e test-3.11 -- -k "$pytest_k" --deselect tests/functional --deselect tests/lib/test_lib.py --deselect tests/unit/test_build_env.py
...
==================================== ERRORS ====================================
______________ ERROR collecting tests/functional/test_install.py _______________
ImportError while importing test module '.../pypa/pip/tests/functional/test_install.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/lib64/python3.11/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/functional/test_install.py:1: in <module>
    import distutils
E   ModuleNotFoundError: No module named 'distutils'
___________ ERROR collecting tests/functional/test_install_wheel.py ____________
ImportError while importing test module '.../pypa/pip/tests/functional/test_install_wheel.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/lib64/python3.11/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/functional/test_install_wheel.py:3: in <module>
    import distutils
E   ModuleNotFoundError: No module named 'distutils'

I'd like to avoid the imports entirely, even though the 2 test files probably cannot run with the new virtualenv anyway (yet).

Expected behavior

Tests still run on Python without distutils.

pip version

main

Python version

3.11.0rc2 sans distuils

OS

Fedora Linux

How to Reproduce

See the description.

Output

No response

Code of Conduct

@hroncok hroncok added S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior labels Oct 17, 2022
hroncok added a commit to hroncok/pip that referenced this issue Oct 17, 2022
The tests still don't run without distutils
because they require virtualenv < 20 (and virtualenv 16 uses distutils),
but at least they don't import distutils directly now.

Fixes pypa#11521
hroncok added a commit to hroncok/pip that referenced this issue Oct 17, 2022
The tests still don't run without distutils
because they require virtualenv < 20 (and virtualenv 16 uses distutils),
but at least they don't import distutils directly now.

Fixes pypa#11521
@pradyunsg pradyunsg removed the S: needs triage Issues/PRs that need to be triaged label Nov 10, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug A confirmed bug or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants