|
5 | 5 | import platform |
6 | 6 | from copy import deepcopy |
7 | 7 | from importlib import import_module |
| 8 | +from importlib.machinery import EXTENSION_SUFFIXES |
8 | 9 | from pathlib import Path |
9 | 10 | from textwrap import dedent |
10 | 11 | from unittest.mock import Mock |
|
28 | 29 | editable_wheel, |
29 | 30 | ) |
30 | 31 | from setuptools.dist import Distribution |
| 32 | +from setuptools.extension import Extension |
31 | 33 |
|
32 | 34 |
|
33 | 35 | @pytest.fixture(params=["strict", "lenient"]) |
@@ -872,9 +874,40 @@ def test_access_plat_name(self, tmpdir_cwd): |
872 | 874 | cmd = editable_wheel(dist) |
873 | 875 | cmd.ensure_finalized() |
874 | 876 | cmd.run() |
875 | | - wheel_file = str(next(Path().glob('dist/*'))) |
| 877 | + wheel_file = str(next(Path().glob('dist/*.whl'))) |
876 | 878 | assert "editable" in wheel_file |
877 | | - assert wheel_file.endswith(".whl") |
| 879 | + |
| 880 | + |
| 881 | +class TestCustomBuildExt: |
| 882 | + def install_custom_build_ext_distutils(self, dist): |
| 883 | + from distutils.command.build_ext import build_ext as build_ext_cls |
| 884 | + |
| 885 | + class MyBuildExt(build_ext_cls): |
| 886 | + pass |
| 887 | + |
| 888 | + dist.cmdclass["build_ext"] = MyBuildExt |
| 889 | + |
| 890 | + @pytest.mark.skipif( |
| 891 | + sys.platform != "linux", reason="compilers may fail without correct setup", |
| 892 | + ) |
| 893 | + def test_distutils_leave_inplace_files(self, tmpdir_cwd): |
| 894 | + jaraco.path.build({"module.c": ""}) |
| 895 | + attrs = { |
| 896 | + "ext_modules": [Extension("module", ["module.c"])], |
| 897 | + } |
| 898 | + dist = Distribution(attrs) |
| 899 | + dist.script_name = "setup.py" |
| 900 | + dist.set_defaults() |
| 901 | + self.install_custom_build_ext_distutils(dist) |
| 902 | + cmd = editable_wheel(dist) |
| 903 | + cmd.ensure_finalized() |
| 904 | + cmd.run() |
| 905 | + wheel_file = str(next(Path().glob('dist/*.whl'))) |
| 906 | + assert "editable" in wheel_file |
| 907 | + files = [p for p in Path().glob("module.*") if p.suffix != ".c"] |
| 908 | + assert len(files) == 1 |
| 909 | + name = files[0].name |
| 910 | + assert any(name.endswith(ext) for ext in EXTENSION_SUFFIXES) |
878 | 911 |
|
879 | 912 |
|
880 | 913 | def install_project(name, venv, tmp_path, files, *opts): |
|
0 commit comments