Skip to content

Commit

Permalink
fix: remove duplicate files when building wheel
Browse files Browse the repository at this point in the history
Signed-off-by: Frost Ming <[email protected]>
  • Loading branch information
frostming committed Jul 10, 2023
1 parent b032535 commit c8f70dd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/pdm/backend/editable.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ def pdm_build_initialize(self, context: Context) -> None:

def pdm_build_update_files(self, context: Context, files: dict[str, Path]) -> None:
packages: list[str] = context.config.convert_package_paths()["packages"]
package_dir = context.config.build_config.package_dir
proxied = {os.path.join(package_dir, p.replace(".", "/")) for p in packages}
proxied = {p.replace(".", "/") for p in packages}
for relpath in list(files):
if os.path.splitext(relpath)[1] in (".py", ".pyc", ".pyo"):
# All .py[cod] files are proxied
Expand Down
17 changes: 14 additions & 3 deletions src/pdm/backend/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from pdm.backend.base import Builder
from pdm.backend.hooks import Context
from pdm.backend.hooks.setuptools import SetuptoolsBuildHook
from pdm.backend.structures import FileMap
from pdm.backend.utils import (
expand_vars,
get_abi_tag,
Expand Down Expand Up @@ -122,13 +123,23 @@ def prepare_metadata(self, metadata_directory: str) -> Path:
self.initialize(context)
return self._write_dist_info(Path(metadata_directory))

def get_files(self, context: Context) -> Iterable[tuple[str, Path]]:
def _collect_files(self, context: Context) -> FileMap:
package_dir = self.config.build_config.package_dir
for relpath, path in super().get_files(context):
result = FileMap()

def clean_prefix(relpath: str) -> str:
# remove the package-dir part from the relative paths
if package_dir and relpath.startswith(package_dir + "/"):
relpath = relpath[len(package_dir) + 1 :]
yield relpath, path
return relpath

result.update(
(clean_prefix(k), v) for k, v in super()._collect_files(context).items()
)
return result

def get_files(self, context: Context) -> Iterable[tuple[str, Path]]:
yield from super().get_files(context)
yield from self._get_metadata_files(context)
yield from self._get_wheel_data(context)

Expand Down

0 comments on commit c8f70dd

Please sign in to comment.