summaryrefslogtreecommitdiff
path: root/setuptools/command
diff options
context:
space:
mode:
authorAnderson Bravalheri <andersonbravalheri@gmail.com>2022-08-11 20:37:37 +0100
committerAnderson Bravalheri <andersonbravalheri@gmail.com>2022-08-11 21:06:31 +0100
commitc056758b664fd3a9fb042a254d1c1462282ce127 (patch)
treed58e4dafdae52245dc7c20388ca789d6c5d5f4ee /setuptools/command
parentf26e15c281ac645dbee77f805ced06e2f86d69d4 (diff)
downloadpython-setuptools-git-c056758b664fd3a9fb042a254d1c1462282ce127.tar.gz
Filter external egg_info files
Diffstat (limited to 'setuptools/command')
-rw-r--r--setuptools/command/build_py.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/setuptools/command/build_py.py b/setuptools/command/build_py.py
index 923a3232..796d7bdd 100644
--- a/setuptools/command/build_py.py
+++ b/setuptools/command/build_py.py
@@ -11,7 +11,7 @@ import itertools
import stat
import warnings
from pathlib import Path
-from typing import Dict, Iterator, List, Optional, Tuple
+from typing import Dict, Iterable, Iterator, List, Optional, Tuple
from setuptools._deprecation_warning import SetuptoolsDeprecationWarning
from setuptools.extern.more_itertools import unique_everseen
@@ -175,15 +175,17 @@ class build_py(orig.build_py):
getattr(self, 'existing_egg_info_dir', None)
and Path(self.existing_egg_info_dir, "SOURCES.txt").exists()
):
- manifest = Path(self.existing_egg_info_dir, "SOURCES.txt")
+ egg_info_dir = self.existing_egg_info_dir
+ manifest = Path(egg_info_dir, "SOURCES.txt")
files = manifest.read_text(encoding="utf-8").splitlines()
else:
self.run_command('egg_info')
ei_cmd = self.get_finalized_command('egg_info')
+ egg_info_dir = ei_cmd.egg_info
files = ei_cmd.filelist.files
check = _IncludePackageDataAbuse()
- for path in files:
+ for path in _filter_absolute_egg_info(files, egg_info_dir):
d, f = os.path.split(assert_relative(path))
prev = None
oldf = f
@@ -346,3 +348,15 @@ class _IncludePackageDataAbuse:
msg = textwrap.dedent(self.MESSAGE).format(importable=importable)
warnings.warn(msg, SetuptoolsDeprecationWarning, stacklevel=2)
self._already_warned.add(importable)
+
+
+def _filter_absolute_egg_info(files: Iterable[str], egg_info: str) -> Iterator[str]:
+ """
+ ``build_meta`` may try to create egg_info outside of the project directory,
+ and this can be problematic for certain plugins (reported in issue #3500).
+ This function should filter this case of invalid files out.
+ """
+ egg_info_name = Path(egg_info).name
+ for file in files:
+ if not (egg_info_name in file and os.path.isabs(file)):
+ yield file