|  | 
| 9 | 9 | import tempfile | 
| 10 | 10 | import unicodedata | 
| 11 | 11 | from inspect import cleandoc | 
|  | 12 | +from pathlib import Path | 
| 12 | 13 | from unittest import mock | 
| 13 | 14 | 
 | 
| 14 | 15 | import jaraco.path | 
| @@ -425,6 +426,46 @@ def test_defaults_case_sensitivity(self, source_dir): | 
| 425 | 426 |         assert 'setup.py' not in manifest, manifest | 
| 426 | 427 |         assert 'setup.cfg' not in manifest, manifest | 
| 427 | 428 | 
 | 
|  | 429 | +    def test_exclude_dev_only_cache_folders(self, source_dir): | 
|  | 430 | +        included = { | 
|  | 431 | +            # Emulate problem in https://github.com/pypa/setuptools/issues/4601 | 
|  | 432 | +            "MANIFEST.in": ( | 
|  | 433 | +                "global-include LICEN[CS]E* COPYING* NOTICE* AUTHORS*\n" | 
|  | 434 | +                "global-include *.txt\n" | 
|  | 435 | +            ), | 
|  | 436 | +            # For the sake of being conservative and limiting unforeseen side-effects | 
|  | 437 | +            # we just exclude dev-only cache folders at the root of the repository: | 
|  | 438 | +            "test/.venv/lib/python3.9/site-packages/bar-2.dist-info/AUTHORS.rst": "", | 
|  | 439 | +            "src/.nox/py/lib/python3.12/site-packages/bar-2.dist-info/COPYING.txt": "", | 
|  | 440 | +            "doc/.tox/default/lib/python3.11/site-packages/foo-4.dist-info/LICENSE": "", | 
|  | 441 | +            # Let's test against false positives with similarly named files: | 
|  | 442 | +            ".venv-requirements.txt": "", | 
|  | 443 | +            ".tox-coveragerc.txt": "", | 
|  | 444 | +            ".noxy/coveragerc.txt": "", | 
|  | 445 | +        } | 
|  | 446 | + | 
|  | 447 | +        excluded = { | 
|  | 448 | +            # .tox/.nox/.venv are well-know folders present at the root of Python repos | 
|  | 449 | +            # and therefore should be excluded | 
|  | 450 | +            ".tox/release/lib/python3.11/site-packages/foo-4.dist-info/LICENSE": "", | 
|  | 451 | +            ".nox/py/lib/python3.12/site-packages/bar-2.dist-info/COPYING.txt": "", | 
|  | 452 | +            ".venv/lib/python3.9/site-packages/bar-2.dist-info/AUTHORS.rst": "", | 
|  | 453 | +        } | 
|  | 454 | + | 
|  | 455 | +        for file, content in {**excluded, **included}.items(): | 
|  | 456 | +            Path(source_dir, file).parent.mkdir(parents=True, exist_ok=True) | 
|  | 457 | +            Path(source_dir, file).write_text(content, encoding="utf-8") | 
|  | 458 | + | 
|  | 459 | +        cmd = self.setup_with_extension() | 
|  | 460 | +        self.assert_package_data_in_manifest(cmd) | 
|  | 461 | +        manifest = {f.replace(os.sep, '/') for f in cmd.filelist.files} | 
|  | 462 | +        for path in excluded: | 
|  | 463 | +            assert os.path.exists(path) | 
|  | 464 | +            assert path not in manifest, (path, manifest) | 
|  | 465 | +        for path in included: | 
|  | 466 | +            assert os.path.exists(path) | 
|  | 467 | +            assert path in manifest, (path, manifest) | 
|  | 468 | + | 
| 428 | 469 |     @fail_on_ascii | 
| 429 | 470 |     def test_manifest_is_written_with_utf8_encoding(self): | 
| 430 | 471 |         # Test for #303. | 
| @@ -915,4 +956,4 @@ def test_sanity_check_setuptools_own_sdist(setuptools_sdist): | 
| 915 | 956 | 
 | 
| 916 | 957 |     # setuptools sdist should not include the .tox folder | 
| 917 | 958 |     tox_files = [name for name in files if ".tox" in name] | 
| 918 |  | -    assert len(tox_files) == 0 | 
|  | 959 | +    assert len(tox_files) == 0, f"not empty {tox_files}" | 
0 commit comments