Skip to content

Commit

Permalink
Customise *-nspkg.pth files for unique names in editable_wheel
Browse files Browse the repository at this point in the history
  • Loading branch information
abravalheri committed Sep 5, 2023
1 parent b526de0 commit 39245fc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions setuptools/command/editable_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ def _create_wheel_file(self, bdist_wheel):
with unpacked_wheel as unpacked, build_lib as lib, build_tmp as tmp:
unpacked_dist_info = Path(unpacked, Path(self.dist_info_dir).name)
shutil.copytree(self.dist_info_dir, unpacked_dist_info)
self._install_namespaces(unpacked, dist_info.name)
self._install_namespaces(unpacked, dist_name)
files, mapping = self._run_build_commands(dist_name, unpacked, lib, tmp)
strategy = self._select_strategy(dist_name, tag, lib)
with strategy, WheelFile(wheel_path, "w") as wheel_obj:
Expand Down Expand Up @@ -752,9 +752,9 @@ def __init__(self, distribution, installation_dir, editable_name, src_root):
self.outputs = []
self.dry_run = False

def _get_target(self):
def _get_nspkg_file(self):
"""Installation target."""
return os.path.join(self.installation_dir, self.editable_name)
return os.path.join(self.installation_dir, self.editable_name + self.nspkg_ext)

def _get_root(self):
"""Where the modules/packages should be loaded from."""
Expand Down
10 changes: 6 additions & 4 deletions setuptools/namespaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ def install_namespaces(self):
nsp = self._get_all_ns_packages()
if not nsp:
return
filename, ext = os.path.splitext(self._get_target())
filename += self.nspkg_ext
filename = self._get_nspkg_file()
self.outputs.append(filename)
log.info("Installing %s", filename)
lines = map(self._gen_nspkg_line, nsp)
Expand All @@ -28,13 +27,16 @@ def install_namespaces(self):
f.writelines(lines)

def uninstall_namespaces(self):
filename, ext = os.path.splitext(self._get_target())
filename += self.nspkg_ext
filename = self._get_nspkg_file()
if not os.path.exists(filename):
return
log.info("Removing %s", filename)
os.remove(filename)

def _get_nspkg_file(self):
filename, _ = os.path.splitext(self._get_target())
return filename + self.nspkg_ext

def _get_target(self):
return self.target

Expand Down

0 comments on commit 39245fc

Please sign in to comment.