Repository: sagemath/sage

Issue:
Test modularised distributions causes CI failure 
### Steps To Reproduce

Check the CI for recently run PR. For example: 

1. https://github.com/sagemath/sage/pull/37441
2. https://github.com/sagemath/sage/pull/37513
3. https://github.com/sagemath/sage/pull/37615

```
Run make V=0 tox && make pypi-wheels-check
make -j2 --output-sync=recurse build/make/Makefile --stop
make[1]: 'build/make/Makefile' is up to date.
build/bin/sage-logger \
	"cd build/make && ./install 'tox'" logs/install.log
Nothing to (re)build / all up-to-date.
make -j2 --output-sync=recurse build/make/Makefile --stop
make[1]: 'build/make/Makefile' is up to date.
build/bin/sage-logger \
	"cd build/make && ./install 'pypi-wheels-check'" logs/install.log
*** ALL ENVIRONMENT VARIABLES BEFORE BUILD: ***
sage_sws2rst-10.4.beta1
sage_setup-10.4.beta1
[sage_sws2rst-10.4.beta1] + set -e
[sage_sws2rst-10.4.beta1] + sage-sws2rst -h
sagemath_environment-10.4.beta1
sagemath_objects-10.4.beta1
make[1]: *** [Makefile:3584: sagemath_environment-SAGE_VENV-check] Error 1
make[1]: *** Waiting for unfinished jobs....
[sagemath_objects-10.4.beta1] ERROR: Could not find a version that satisfies the requirement cysignals>=1.10.2 (from versions: none)
[sagemath_objects-10.4.beta1] ERROR: No matching distribution found for cysignals>=1.10.2
[sagemath_objects-10.4.beta1] .pkg-sagepython-sagewheels-nopypi: remove tox env folder /sage/pkgs/sagemath-objects/.tox/.pkg-sagepython-sagewheels-nopypi
[sagemath_objects-10.4.beta1] .pkg-sagepython-sagewheels-nopypi: find interpreter for spec PythonSpec(path=/bin/python3)
[sagemath_objects-10.4.beta1] .pkg-sagepython-sagewheels-nopypi: proposed PythonInfo(spec=CPython3.8.10.final.0-64, exe=/bin/python3, platform=linux, version='3.8.10 (default, Nov 22 2023, 10:22:35) \n[GCC 9.4.0]', encoding_fs_io=utf-8-utf-8)
[sagemath_objects-10.4.beta1] .pkg-sagepython-sagewheels-nopypi: create virtual environment via CPython3Posix(dest=/sage/pkgs/sagemath-objects/.tox/.pkg-sagepython-sagewheels-nopypi, clear=False, no_vcs_ignore=False, global=False)
[sagemath_objects-10.4.beta1] .pkg-sagepython-sagewheels-nopypi: add seed packages via FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/github/home/.local/share/virtualenv)
[sagemath_objects-10.4.beta1] .pkg-sagepython-sagewheels-nopypi: add activators for Bash, CShell, Fish, Nushell, PowerShell, Python
[sagemath_objects-10.4.beta1] .pkg-sagepython-sagewheels-nopypi: freeze> python -m pip freeze --all
[sagemath_objects-10.4.beta1] .pkg-sagepython-sagewheels-nopypi: exit 0 (0.68 seconds) /sage/pkgs/sagemath-objects> python -m pip freeze --all pid=61304
[sagemath_objects-10.4.beta1] .pkg-sagepython-sagewheels-nopypi: pip==23.3.1,setuptools==69.0.2,wheel==0.42.0
[sagemath_objects-10.4.beta1] .pkg-sagepython-sagewheels-nopypi_sdist_meta: remove tox env folder /sage/pkgs/sagemath-objects/.tox/.pkg-sagepython-sagewheels-nopypi_sdist_meta
[sagemath_objects-10.4.beta1] sagepython-sagewheels-nopypi-norequirements: find interpreter for spec PythonSpec(path=/bin/python3)
[sagemath_objects-10.4.beta1] sagepython-sagewheels-nopypi-norequirements: proposed PythonInfo(spec=CPython3.8.10.final.0-64, exe=/bin/python3, platform=linux, version='3.8.10 (default, Nov 22 2023, 10:22:35) \n[GCC 9.4.0]', encoding_fs_io=utf-8-utf-8)
[sagemath_objects-10.4.beta1] sagepython-sagewheels-nopypi-norequirements: create virtual environment via CPython3Posix(dest=/sage/pkgs/sagemath-objects/.tox/sagepython-sagewheels-nopypi-norequirements, clear=False, no_vcs_ignore=False, global=False)
[sagemath_objects-10.4.beta1] sagepython-sagewheels-nopypi-norequirements: add seed packages via FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/github/home/.local/share/virtualenv)
[sagemath_objects-10.4.beta1] sagepython-sagewheels-nopypi-norequirements: add activators for Bash, CShell, Fish, Nushell, PowerShell, Python
[sagemath_objects-10.4.beta1] sagepython-sagewheels-nopypi-norequirements: install_package_deps> python -I -m pip install 'cysignals>=1.10.2' 'gmpy2~=2.1.b999'
[sagemath_objects-10.4.beta1] sagepython-sagewheels-nopypi-norequirements: exit 1 (0.83 seconds) /sage/pkgs/sagemath-objects> python -I -m pip install 'cysignals>=1.10.2' 'gmpy2~=2.1.b999' pid=61312
[sagemath_objects-10.4.beta1] Looking in links: file:///sage/local/var/lib/sage/venv-python3.11.1/var/lib/sage/wheels
[sagemath_objects-10.4.beta1]   sagepython-sagewheels-nopypi-norequirements: FAIL code 1 (1.97 seconds)
[sagemath_objects-10.4.beta1]   evaluation failed :( (2.05 seconds)
[sagemath_objects-10.4.beta1] Failures testing the package
[sagemath_objects-10.4.beta1] 
[sagemath_objects-10.4.beta1] real	0m2.228s
[sagemath_objects-10.4.beta1] user	0m1.675s
[sagemath_objects-10.4.beta1] sys	0m0.670s
[sagemath_objects-10.4.beta1] ************************************************************************
[sagemath_objects-10.4.beta1] Error testing package sagemath_objects-10.4.beta1
[sagemath_objects-10.4.beta1] ************************************************************************
[sagemath_objects-10.4.beta1] Please email sage-devel (http://groups.google.com/group/sage-devel)
[sagemath_objects-10.4.beta1] explaining the problem and including the log files
[sagemath_objects-10.4.beta1]   /sage/logs/pkgs/sagemath_objects-10.4.beta1.log
[sagemath_objects-10.4.beta1] and
[sagemath_objects-10.4.beta1]   /sage/config.log
[sagemath_objects-10.4.beta1] Describe your computer, operating system, etc.
[sagemath_objects-10.4.beta1] If you want to try to fix the problem yourself, *don't* just cd to
[sagemath_objects-10.4.beta1] /sage/build/pkgs/sagemath_objects and type 'make check' or whatever is appropriate.
[sagemath_objects-10.4.beta1] Instead, the following commands setup all environment variables
[sagemath_objects-10.4.beta1] correctly and load a subshell for you to debug the error:
[sagemath_objects-10.4.beta1]   (cd '/sage/build/pkgs/sagemath_objects' && '/sage/sage' --buildsh)
[sagemath_objects-10.4.beta1] When you are done debugging, you can type "exit" to leave the subshell.
[sagemath_objects-10.4.beta1] ************************************************************************

make[1]: *** [Makefile:3584: sagemath_objects-SAGE_VENV-check] Error 1

real	0m3.126s
user	0m4.423s
sys	0m1.758s
***************************************************************
Error building Sage.

The following package(s) may have failed to build (not necessarily
during this run of 'make pypi-wheels-check'):

* package:         sagemath_environment-10.4.beta1
  last build time: Apr 3 11:24
  log file:        /sage/logs/pkgs/sagemath_environment-10.4.beta1.log

* package:         sagemath_objects-10.4.beta1
  last build time: Apr 3 11:24
  log file:        /sage/logs/pkgs/sagemath_objects-10.4.beta1.log

It is safe to delete any log files and build directories, but they
contain information that is helpful for debugging build problems.
WARNING: If you now run 'make' again, the build directory of the
same version of the package will, by default, be deleted. Set the
environment variable SAGE_KEEP_BUILT_SPKGS=yes to prevent this.

make: *** [Makefile:40: pypi-wheels-check] Error 1
Error: Process completed with exit code 2.
```

### Expected Behavior

The CI should pass when these parts of Sage are unchanged 

### Actual Behavior

The CI fails

### Additional Information

_No response_

### Environment

```markdown
- **OS**:
- **Sage Version**:
```


### Checklist

- [X] I have searched the existing issues for a bug report that matches the one I want to file, without success.
- [X] I have read the documentation and troubleshoot guide


Discussion:
(https://github.com/sagemath/sage/pull/37705#issuecomment-2033131954)

Resolving patch:
diff --git a/src/sage/doctest/reporting.py b/src/sage/doctest/reporting.py
--- a/src/sage/doctest/reporting.py
+++ b/src/sage/doctest/reporting.py
@@ -145,7 +145,8 @@ def were_doctests_with_optional_tag_run(self, tag):
         When latex is available, doctests marked with optional tag
         ``latex`` are run by default since :issue:`32174`::
 
-            sage: filename = os.path.join(SAGE_SRC,'sage','misc','latex.py')
+            sage: # needs SAGE_SRC
+            sage: filename = os.path.join(SAGE_SRC, 'sage', 'misc', 'latex.py')
             sage: DC = DocTestController(DocTestDefaults(), [filename])
             sage: DTR = DocTestReporter(DC)
             sage: DTR.were_doctests_with_optional_tag_run('latex')   # optional - latex
diff --git a/src/sage/features/__init__.py b/src/sage/features/__init__.py
--- a/src/sage/features/__init__.py
+++ b/src/sage/features/__init__.py
@@ -948,7 +948,10 @@ def _is_present(self):
             # Available since https://setuptools.pypa.io/en/latest/history.html#v59-0-0
             from setuptools.errors import CCompilerError
         except ImportError:
-            from distutils.errors import CCompilerError
+            try:
+                from distutils.errors import CCompilerError
+            except ImportError:
+                CCompilerError = ()
         with open(tmp_filename(ext=".pyx"), 'w') as pyx:
             pyx.write(self.test_code)
         try:


Test patch: