diff options
| author | Anderson Bravalheri <andersonbravalheri@gmail.com> | 2022-08-12 19:41:13 +0100 |
|---|---|---|
| committer | Anderson Bravalheri <andersonbravalheri@gmail.com> | 2022-08-12 19:41:13 +0100 |
| commit | d7f5704cbc8e739fe6144402a6c2ed45e38cd6c0 (patch) | |
| tree | 78f7c93ef7dee574442adf3be3336fb1f854fd6a /setuptools/command | |
| parent | e4dd4bdd923cfc2f69dd4cfbb119644bb46e5e9d (diff) | |
| parent | c380214475ebbd3e93d15ebcfc0bd691f6c2e5a0 (diff) | |
| download | python-setuptools-git-d7f5704cbc8e739fe6144402a6c2ed45e38cd6c0.tar.gz | |
Fix other problems with editable installs (#3517)
1. Ensure commands are finalized, to ensure plat_name is set.
2. Filter out temporary source files and prevent setuptools for
attempting to consider them as part of the data_files/package_data
list
Diffstat (limited to 'setuptools/command')
| -rw-r--r-- | setuptools/command/build_py.py | 33 | ||||
| -rw-r--r-- | setuptools/command/editable_wheel.py | 7 |
2 files changed, 24 insertions, 16 deletions
diff --git a/setuptools/command/build_py.py b/setuptools/command/build_py.py index 8b1a3320..ec062742 100644 --- a/setuptools/command/build_py.py +++ b/setuptools/command/build_py.py @@ -184,7 +184,7 @@ class build_py(orig.build_py): files = ei_cmd.filelist.files check = _IncludePackageDataAbuse() - for path in _filter_absolute_egg_info(files, egg_info_dir): + for path in self._filter_build_files(files, egg_info_dir): d, f = os.path.split(assert_relative(path)) prev = None oldf = f @@ -202,6 +202,25 @@ class build_py(orig.build_py): check.warn(importable) mf.setdefault(src_dirs[d], []).append(path) + def _filter_build_files(self, 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). + + Extensions might also include between their sources files created on the + ``build_lib`` and ``build_temp`` directories. + + This function should filter this case of invalid files out. + """ + build = self.get_finalized_command("build") + build_dirs = (egg_info, self.build_lib, build.build_temp, build.build_base) + norm_dirs = [os.path.normpath(p) for p in build_dirs if p] + + for file in files: + norm_path = os.path.normpath(file) + if not os.path.isabs(file) or all(d not in norm_path for d in norm_dirs): + yield file + def get_data_files(self): pass # Lazily compute data files in _get_data_files() function. @@ -347,15 +366,3 @@ 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 diff --git a/setuptools/command/editable_wheel.py b/setuptools/command/editable_wheel.py index 2631a082..560efebd 100644 --- a/setuptools/command/editable_wheel.py +++ b/setuptools/command/editable_wheel.py @@ -133,7 +133,8 @@ class editable_wheel(Command): self._ensure_dist_info() # Add missing dist_info files - bdist_wheel = self.reinitialize_command("bdist_wheel") + self.reinitialize_command("bdist_wheel") + bdist_wheel = self.get_finalized_command("bdist_wheel") bdist_wheel.write_wheelfile(self.dist_info_dir) self._create_wheel_file(bdist_wheel) @@ -156,7 +157,7 @@ class editable_wheel(Command): if self.dist_info_dir is None: dist_info = self.reinitialize_command("dist_info") dist_info.output_dir = self.dist_dir - dist_info.finalize_options() + dist_info.ensure_finalized() dist_info.run() self.dist_info_dir = dist_info.dist_info_dir else: @@ -278,7 +279,7 @@ class editable_wheel(Command): # Also remove _safely_run, TestCustomBuildPy. Suggested date: Aug/2023. build: Command = self.get_finalized_command("build") for name in build.get_sub_commands(): - cmd = self.distribution.get_command_obj(name) + cmd = self.get_finalized_command(name) if name == "build_py" and type(cmd) != build_py_cls: self._safely_run(name) else: |
