Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix support for the PackageType.VIRTUAL_SYSTEM enum #2923

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions mamba/mamba/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from conda.core.solve import diff_for_unlink_link_precs
from conda.gateways.connection.session import CondaHttpAuth
from conda.models.channel import Channel as CondaChannel
from conda.models.enums import PackageType
from conda.models.prefix_graph import PrefixGraph
from conda.models.records import PackageRecord

Expand Down Expand Up @@ -352,7 +353,7 @@ def compute_final_precs(
to_unlink_records.append(i_rec)
except KeyError:
# virtual packages cannot be unlinked as they do not exist
if i_rec.package_type == "virtual_system":
if i_rec.package_type is PackageType.VIRTUAL_SYSTEM:
continue
raise
break
Expand All @@ -377,7 +378,7 @@ def compute_final_precs(
rec.noarch = ipkg.noarch

# virtual packages cannot be linked as they do not exist
if rec.package_type == "virtual_system":
if rec.package_type is PackageType.VIRTUAL_SYSTEM:
continue

final_precs.add(rec)
Expand Down
18 changes: 18 additions & 0 deletions mamba/tests/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,3 +319,21 @@ def test_info(use_json):
assert output["mamba_version"] == __version__
else:
assert "mamba version : " + __version__ in output


@pytest.mark.skipif(
platform.system() != "Darwin",
reason="__osx is a platform specific virtual package from conda-forge",
)
def test_remove_virtual_package():
# non-regression test for https://github.com/mamba-org/mamba/issues/2129
with Environment("bash") as env:
# The virtual package __osx is installed by default on macOS:
out = env.mamba("info -q")
assert "__osx" in "\n".join(out)

# Attempting to remove it should not fail (but should not remove it
# either).
env.mamba("remove -q -y __osx")
out = env.mamba("info -q")
assert "__osx" in "\n".join(out)