Skip to content

Commit

Permalink
Fix support for the PackageType.VIRTUAL_SYSTEM enum (#2923)
Browse files Browse the repository at this point in the history
  • Loading branch information
ogrisel authored Oct 20, 2023
1 parent 00dd002 commit d0b3ea0
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
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
40 changes: 40 additions & 0 deletions mamba/tests/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,3 +319,43 @@ def test_info(use_json):
assert output["mamba_version"] == __version__
else:
assert "mamba version : " + __version__ in output


@pytest.mark.parametrize(
"virtual_package_name",
[
pytest.param(
"__osx",
marks=pytest.mark.skipif(
platform.system() != "Darwin",
reason="__osx package defined for macOS only",
),
),
pytest.param(
"__linux",
marks=pytest.mark.skipif(
platform.system() != "Linux",
reason="__linux package defined for Linux only",
),
),
pytest.param(
"__win",
marks=pytest.mark.skipif(
platform.system() != "Windows",
reason="__win package defined for Windows only",
),
),
],
)
def test_remove_virtual_package(virtual_package_name):
# non-regression test for https://github.com/mamba-org/mamba/issues/2129
with Environment("bash") as env:
# The platform specific virtual package should be "installed" by default.
out = env.mamba("info -q")
assert virtual_package_name in "\n".join(out)

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

0 comments on commit d0b3ea0

Please sign in to comment.