-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
test_bdb and test_distutils fail on installed Python 3.9, 3.10 and 3.11 (setuptools 60.9.3, pip 22.0.4) #91169
Comments
Since build 298, test_bdb test_distutils fail on s390x Fedora Rawhide Clang Installed 3.10: 2 changes of build 298:
Logs: 0:02:03 load avg: 9.95 [213/427/1] test_distutils failed (uncaught exception) -- running: test_concurrent_futures (42.4 sec)
test test_distutils crashed -- Traceback (most recent call last):
File "/home/dje/cpython-buildarea/3.10.edelsohn-fedora-rawhide-z.clang-installed/build/target/lib/python3.10/test/libregrtest/runtest.py", line 335, in _runtest_inner
refleak = _runtest_inner2(ns, test_name)
File "/home/dje/cpython-buildarea/3.10.edelsohn-fedora-rawhide-z.clang-installed/build/target/lib/python3.10/test/libregrtest/runtest.py", line 280, in _runtest_inner2
the_module = importlib.import_module(abstest)
File "/home/dje/cpython-buildarea/3.10.edelsohn-fedora-rawhide-z.clang-installed/build/target/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 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 "/home/dje/cpython-buildarea/3.10.edelsohn-fedora-rawhide-z.clang-installed/build/target/lib/python3.10/test/test_distutils.py", line 15, in <module>
import distutils.tests
ModuleNotFoundError: No module named 'distutils.tests' ====================================================================== Traceback (most recent call last):
File "/home/dje/cpython-buildarea/3.10.edelsohn-fedora-rawhide-z.clang-installed/build/target/lib/python3.10/test/test_bdb.py", line 730, in test_skip
with TracerRun(self, skip=skip) as tracer:
File "/home/dje/cpython-buildarea/3.10.edelsohn-fedora-rawhide-z.clang-installed/build/target/lib/python3.10/test/test_bdb.py", line 448, in __exit__
self.test_case.fail(err_msg)
File "/home/dje/cpython-buildarea/3.10.edelsohn-fedora-rawhide-z.clang-installed/build/target/lib/python3.10/test/test_bdb.py", line 582, in fail
raise self.failureException(msg) from None
AssertionError: Wrong event type at expect_set item 2, got 'call'
Expected: ('line', 3, 'tfunc_import')
Got: ('call', 84, 'find_spec'), ('quit',), |
Reproduce: $ ./configure --prefix /opt/py310 && make clean && make && make install
$ cd /somewhere/else/
$ /opt/py310/bin/python3 -m test -v test_bdb
...
FAIL: test_skip (test.test_bdb.StateTestCase)
...
$ /opt/py310/bin/python3 -m test -v test_distutils
...
ModuleNotFoundError: No module named 'distutils.tests'
... setuptools installs this file: $ cat /opt/py310/lib/python3.10/site-packages/distutils-precedence.pth
import os; var = 'SETUPTOOLS_USE_DISTUTILS'; enabled = os.environ.get(var, 'local') == 'local'; enabled and __import__('_distutils_hack').add_shim(); |
See: [BUG] Having setuptools installed causes cpython stdlib build to fail |
x86 Gentoo Installed with X 3.9: 4 tests failed: Python 3.9 gets two more issues: test_importlib and test_peg_generator. ====================================================================== Traceback (most recent call last):
File "/buildbot/buildarea/cpython/3.9.ware-gentoo-x86.installed/build/target/lib/python3.9/test/test_importlib/test_main.py", line 159, in test_package_discovery
assert all(
AssertionError
0:06:27 load avg: 3.96 [ 83/425/3] test_peg_generator failed (uncaught exception) -- running: test_multiprocessing_forkserver (1 min 27 sec)
Warning -- warnings.filters was modified by test_peg_generator
Failed to import test module: test.test_peg_generator.test_c_parser
Traceback (most recent call last):
File "/buildbot/buildarea/cpython/3.9.ware-gentoo-x86.installed/build/target/lib/python3.9/unittest/loader.py", line 436, in _find_test_path
module = self._get_module_from_name(name)
File "/buildbot/buildarea/cpython/3.9.ware-gentoo-x86.installed/build/target/lib/python3.9/unittest/loader.py", line 377, in _get_module_from_name
__import__(name)
File "/buildbot/buildarea/cpython/3.9.ware-gentoo-x86.installed/build/target/lib/python3.9/test/test_peg_generator/test_c_parser.py", line 4, in <module>
from distutils.tests.support import TempdirManager
ModuleNotFoundError: No module named 'distutils.tests' |
AMD64 Fedora Stable Clang Installed 3.x: 2 re-run tests: |
I also reproduce test_bdb and test_distutils failures on the main branch. |
(The buildbot failures were triggered by yesterday's merges for bpo-46986 which updated the bundled setuptools in ensurepip. I'm reverting those merges now to unblock planned releases.) |
See pypa/setuptools#3007 (comment) where I did a brief analysis and probable explanation. What it boils down to: Setuptools needs to supply its own copy of distutils aggressively. It provides an opt out for this behavior and is able to offer built in opt out based on whatever signal is available. The default opt out is the SETUPTOOLS_USE_DISTUTILS=stdlib env var. for CPython, it also disables the behavior when ./pybuilddir.txt is present, but installed Pythons probably don’t have this config. Can those test runners be updated to set this environment variable? |
From pypa/setuptools#3007:
If tiran is right, then Setuptools is already doing everything it can not to interfere with CPython builds.
It appears that Setuptools is unable to do anything to detect that the stdlib distutils is to be preferred. Trying to think outside the box, maybe there's a way that the distutils hook could be extended to detect the import of any module matching It's not simply enough to detect an attempt to import In fact, maybe Setuptools could simply disable the hook if the specifically-implicated modules are encountered. I can try that, maybe using the repro above. |
I was able to repro at least some of the failures with this dockerfile: FROM jaraco/multipy-tox
RUN apt install -y libarchive-tools libssl-dev
RUN wget -O - https://github.com/python/cpython/archive/refs/heads/3.9.zip | bsdtar -xf -
WORKDIR cpython-3.9
RUN sh ./configure --prefix /opt/python
RUN make install
WORKDIR /
RUN /opt/python/bin/python3 -m pip install --upgrade pip setuptools
CMD /opt/python/bin/python3 -m test Here's an excerpt from the output:
|
Attempting to install a pre-release of setuptools, I find that the custom build of Python is inadequate because I suspect FROM jaraco/multipy-tox
RUN apt install -y libarchive-tools
RUN apt install -y build-essential gdb lcov pkg-config libbz2-dev libffi-dev libgdbm-dev libgdbm-compat-dev liblzma-dev libncurses5-dev libreadline6-dev libsqlite3-dev libssl-dev lzma lzma-dev tk-dev uuid-dev zlib1g-dev
RUN wget -O - https://github.com/python/cpython/archive/refs/heads/3.9.zip | bsdtar -xf -
WORKDIR cpython-3.9
RUN sh ./configure --prefix /opt/python
RUN make install
WORKDIR /
RUN /opt/python/bin/python3 -m pip install --upgrade pip
RUN /opt/python/bin/python3 -m pip install git+https://github.com/pypa/setuptools@experiment/sensitive-tests
CMD /opt/python/bin/python3 -m test |
My attempts to have setuptools selectively disable the distutils override worked for all of the tests except |
Here's a repro not involving Setuptools showing how
It fails with a similar error:
|
Based on this finding, I don't think there's anything that Setuptools can do short of completely removing the hook, which is a non-starter because (a) it would break all users relying on the hook to provide distutils when it's not available in the stdlib and (b) it would remove the ability for use cases still reliant on stdlib to opt out. I suggest we'll want to find a fix for test_bdb independent of the concerns introduced by setuptools. |
With this Dockerfile, I can confirm the proposed fix in Setuptools has the desired effect: FROM jaraco/multipy-tox
RUN apt install -y libarchive-tools
RUN apt install -y build-essential gdb lcov pkg-config libbz2-dev libffi-dev libgdbm-dev libgdbm-compat-dev liblzma-dev libncurses5-dev libreadline6-dev libsqlite3-dev libssl-dev lzma lzma-dev tk-dev uuid-dev zlib1g-dev
RUN wget -O - https://github.com/python/cpython/archive/refs/heads/3.9.zip | bsdtar -xf -
WORKDIR cpython-3.9
RUN sh ./configure --prefix /opt/python
RUN make install
RUN chmod u+x /opt/python/lib/python3.9/test/ziptestdata/exe_with_*
WORKDIR /
RUN /opt/python/bin/python3 -m pip install --upgrade pip
RUN /opt/python/bin/python3 -m pip install git+https://github.com/pypa/setuptools@bugfix/3383-cpython-sensitive-tests
CMD /opt/python/bin/python3 -m test
Unfortunately, it also creates its own regression in
And annoyingly, that error message is all but worthless for diagnosis. |
After adding a breakpoint where the error is occurring (pytest would do this automatically with
It seems there's a new issue, probably brought on by changes in Setuptools. |
The failure looks suspiciously similar to pypa/setuptools#2940. |
Okay, so Setuptools fixed that issue and released it in 60.0.3, but the version of Setuptools installed into the virtualenv doesn't have that fix. But that doesn't explain why the issue only emerges when the version of Setuptools is bumped. Aah. I get it. This test is running a venv with |
At this point, pypa/setuptools#3386 (to be released with Setuptools>=62.5.0) and gh-93962 should fix the issue. |
@jaraco I upgraded to setuptools 64.0.3 and still get these errors. Is there a solution? Using docker pull registry.gitlab.com/python-devs/ci-images:active from README for dev container All 3 tests fail due to no module found. Pip install --upgrade setuptools doesn't resolve although version is 64.0.3. I also tried make from source and it throws the error at test_peg_generator. Thanks! |
@yilun11 I suspect your issue is different than this one. I can indeed produce an error if I use your repro:
However, I also observe that I get the same error for any test module:
When I look at the Python lib directory, I see a To close the loop on this issue, I've confirmed that the repro that previously failed no longer fails with the latest Setuptools:
|
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: