Skip to content

Commit

Permalink
Update comments
Browse files Browse the repository at this point in the history
  • Loading branch information
goanpeca committed Jan 24, 2023
1 parent aeb8600 commit b08b4c4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
19 changes: 12 additions & 7 deletions constructor-manager-cli/src/constructor_manager_cli/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def check_updates(
-------
dict
Dictionary containing the current and latest versions, found
installed versions and the installer type used.
installed versions.
"""
package_name, current_version, build = parse_conda_version_spec(package)
versions = conda_package_versions(
Expand Down Expand Up @@ -147,10 +147,14 @@ def check_updates(
"current_version": current_version,
"latest_version": latest_version,
"previous_version": previous_version,
"found_versions": installed_versions,
"installed_versions": installed_versions,
"update": update,
"installed": latest_version in installed_versions,
"status": {},
"status": {
"data": "",
"stdout": "",
"stderr": "",
},
}


Expand Down Expand Up @@ -270,7 +274,7 @@ def check_updates_clean_and_launch(
clean_all(package_name)


def remove(package: str):
def remove(package: str, use_mamba: bool = False):
"""Remove specific environment of a given package.
Environment will be removed using conda/mamba, or the folders deleted in
Expand All @@ -282,14 +286,13 @@ def remove(package: str):
Package specification.
"""
# Try to remove using conda/mamba
installer = CondaInstaller()
installer = CondaInstaller(use_mamba=use_mamba)
package_name, version, _ = parse_conda_version_spec(package)
prefix = get_prefix_by_name(f"{package_name}-{version}")
job_id = installer.remove(prefix)
job_id = installer.remove(str(prefix))

# Otherwise remove the folder manually
if job_id:
print("removing", prefix)
shutil.rmtree(prefix)


Expand Down Expand Up @@ -362,6 +365,7 @@ def lock_environment(

package_name, current_version, _ = parse_conda_version_spec(package)
if not current_version:
# TODO:
sys.stderr.write("Cannot lock environment without version number!")
return 1

Expand All @@ -388,6 +392,7 @@ def lock_environment(
with open(lockfile) as fh:
lines = fh.read().split("\n")

# Remove comments on lock file
lines = [line for line in lines if not line.startswith("#")]
with open(lockfile, "w") as fh:
data = "\n".join(lines)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def get_installed_versions(package_name: str) -> List[Tuple[str, ...]]:
):
for p in conda_meta_folder.iterdir():
if p.suffix == ".json":
# Check environment contains a napari package
# Check environment contains the package
parts = p.stem.rsplit("-")
if len(parts) == 3 and parts[-3] == package_name:
versions.append(tuple(parts[1:]))
Expand Down

0 comments on commit b08b4c4

Please sign in to comment.