Skip to content

Commit

Permalink
Fix installation and editable
Browse files Browse the repository at this point in the history
  • Loading branch information
cidrblock committed Sep 19, 2023
1 parent dc39ef8 commit 3940ff5
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/pip4a/subcommands/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ def __init__(self: Installer, config: Config, output: Output) -> None:

def run(self: Installer) -> None:
"""Run the installer."""
if self._config.args.editable and not self._collection.local:
err = "Editable installs are only supported for local collections."
self._output.critical(err)

if (
self._config.args.collection_specifier
and "," in self._config.args.collection_specifier
Expand All @@ -67,6 +63,9 @@ def run(self: Installer) -> None:
if self._config.args.editable:
self._swap_editable_collection()
elif not self._collection.local:
if self._config.args.editable:
msg = "Editable installs are only supported for local collections."
self._output.critical(msg)
self._install_galaxy_collection()

builder_introspect(config=self._config)
Expand Down Expand Up @@ -296,11 +295,11 @@ def _install_local_collection(self: Installer) -> None: # noqa: PLR0912, PLR091
if not self._config.args.editable:
shutil.copy(
self._collection.build_dir / "galaxy.yml",
self._config.site_pkg_path / "galaxy.yml",
self._collection.site_pkg_path / "galaxy.yml",
)
else:
shutil.copy(
self._config.site_pkg_path / "MANIFEST.json",
self._collection.site_pkg_path / "MANIFEST.json",
self._collection.cache_dir / "MANIFEST.json",
)

Expand All @@ -320,13 +319,13 @@ def _swap_editable_collection(self: Installer) -> None:
if self._collection.path is None:
msg = "Collection path not set"
raise RuntimeError(msg)
msg = f"Removing installed {self._config.site_pkg_path}"
msg = f"Removing installed {self._collection.site_pkg_path}"
self._output.debug(msg)
if self._config.site_pkg_path.exists():
if self._config.site_pkg_path.is_symlink():
self._config.site_pkg_path.unlink()
if self._collection.site_pkg_path.exists():
if self._collection.site_pkg_path.is_symlink():
self._collection.site_pkg_path.unlink()
else:
shutil.rmtree(self._config.site_pkg_path)
shutil.rmtree(self._collection.site_pkg_path)

msg = f"Symlinking {self._collection.site_pkg_path} to {self._collection.path}"
self._output.debug(msg)
Expand Down

0 comments on commit 3940ff5

Please sign in to comment.