diff --git a/newsfragments/+61911d95.bugfix.rst b/newsfragments/+61911d95.bugfix.rst new file mode 100644 index 0000000000..f542998cd5 --- /dev/null +++ b/newsfragments/+61911d95.bugfix.rst @@ -0,0 +1 @@ +Synced with pypa/distutils@30b7331 including fix for modified check on empty sources (pypa/distutils#284). \ No newline at end of file diff --git a/setuptools/_distutils/_modified.py b/setuptools/_distutils/_modified.py index 6532aa1073..b7bdaa2943 100644 --- a/setuptools/_distutils/_modified.py +++ b/setuptools/_distutils/_modified.py @@ -63,7 +63,7 @@ def missing_as_newer(source): return missing == 'newer' and not os.path.exists(source) ignored = os.path.exists if missing == 'ignore' else None - return any( + return not os.path.exists(target) or any( missing_as_newer(source) or _newer(source, target) for source in filter(ignored, sources) ) diff --git a/setuptools/_distutils/dist.py b/setuptools/_distutils/dist.py index 0a57d60be9..115302b3e7 100644 --- a/setuptools/_distutils/dist.py +++ b/setuptools/_distutils/dist.py @@ -658,7 +658,7 @@ def _show_help( ) print() - for command in self.commands: + for command in commands: if isinstance(command, type) and issubclass(command, Command): klass = command else: diff --git a/setuptools/_distutils/tests/test_modified.py b/setuptools/_distutils/tests/test_modified.py index 2bd82346cf..e35cec2d6f 100644 --- a/setuptools/_distutils/tests/test_modified.py +++ b/setuptools/_distutils/tests/test_modified.py @@ -117,3 +117,10 @@ def test_newer_pairwise_group(groups_target): newer = newer_pairwise_group([groups_target.newer], [groups_target.target]) assert older == ([], []) assert newer == ([groups_target.newer], [groups_target.target]) + + +def test_newer_group_no_sources_no_target(tmp_path): + """ + Consider no sources and no target "newer". + """ + assert newer_group([], str(tmp_path / 'does-not-exist'))