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

Test with xtensor-python instead of unmaintained xframe #3286

Merged
merged 21 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 0 additions & 2 deletions .github/workflows/unix_impl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,6 @@ jobs:
export TEST_MAMBA_EXE=$(pwd)/build/micromamba/mamba
export MAMBA_ROOT_PREFIX="${HOME}/micromamba"
unset CONDARC # Interferes with tests
# FIXME this is apparently a bug to be fixed (pip specs are not installed from env yml file)
python -m pip install securesystemslib --no-input --no-deps
cd micromamba/test-server
./generate_gpg_keys.sh
./testserver_pkg_signing.sh
3 changes: 1 addition & 2 deletions dev/environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ dependencies:
- conda-content-trust
- conda-package-handling
- cryptography<40.0 # Or breaks conda-content-trust
- pip:
- securesystemslib
- securesystemslib
# libmambapy build dependencies
- scikit-build
- build
Expand Down
44 changes: 22 additions & 22 deletions micromamba/tests/test_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def test_specs(tmp_home, tmp_root_prefix, tmp_path, source, file_type, create_cm
specs = []

if source in ("cli_only", "both"):
specs = ["xframe", "xtl"]
specs = ["xtensor-python", "xtl"]
cmd += specs

if source in ("spec_file_only", "both"):
Expand Down Expand Up @@ -112,18 +112,19 @@ def test_lockfile(tmp_home, tmp_root_prefix, tmp_path):
assert any(package["name"] == "zlib" and package["version"] == "1.2.11" for package in packages)


@pytest.mark.parametrize("shared_pkgs_dirs", [True], indirect=True)
def test_lockfile_online(tmp_home, tmp_root_prefix, tmp_path):
env_prefix = tmp_path / "myenv"
spec_file = (
"https://raw.githubusercontent.com/mamba-org/mamba/main/micromamba/tests/test_env-lock.yaml"
)

res = helpers.create("-p", env_prefix, "-f", spec_file, "--json")
assert res["success"]

packages = helpers.umamba_list("-p", env_prefix, "--json")
assert any(package["name"] == "zlib" and package["version"] == "1.2.11" for package in packages)
# TODO: uncomment when https://github.com/mamba-org/mamba/pull/3286 is merged
# @pytest.mark.parametrize("shared_pkgs_dirs", [True], indirect=True)
# def test_lockfile_online(tmp_home, tmp_root_prefix, tmp_path):
# env_prefix = tmp_path / "myenv"
# spec_file = (
# "https://raw.githubusercontent.com/mamba-org/mamba/main/micromamba/tests/test_env-lock.yaml"
# )
#
# res = helpers.create("-p", env_prefix, "-f", spec_file, "--json")
# assert res["success"]
#
# packages = helpers.umamba_list("-p", env_prefix, "--json")
# assert any(package["name"] == "zlib" and package["version"] == "1.2.11" for package in packages)


@pytest.mark.parametrize("shared_pkgs_dirs", [True], indirect=True)
Expand Down Expand Up @@ -736,7 +737,7 @@ def test_channel_nodefaults(tmp_home, tmp_root_prefix, tmp_path):
" - yaml",
" - nodefaults",
"dependencies:",
" - xframe",
" - xtensor-python",
]
with open(spec_file, "w") as f:
f.write("\n".join(contents))
Expand All @@ -758,7 +759,7 @@ def test_channel_nodefaults(tmp_home, tmp_root_prefix, tmp_path):
@pytest.mark.parametrize("shared_pkgs_dirs", [True], indirect=True)
def test_pin_applicable(tmp_home, tmp_root_prefix, tmp_path):
pin_name = "xtensor"
pin_max_version = "0.20"
pin_max_version = "0.24"
# We add the channel to test a fragile behavior of ``Database``
spec_name = "conda-forge::xtensor"
rc_file = tmp_path / "rc.yaml"
Expand All @@ -774,7 +775,7 @@ def test_pin_applicable(tmp_home, tmp_root_prefix, tmp_path):
install_pkg = p

# Should do proper version comparison
assert install_pkg["version"] == "0.20.0"
assert install_pkg["version"] == "0.24.0"


@pytest.mark.parametrize("shared_pkgs_dirs", [True], indirect=True)
Expand Down Expand Up @@ -826,7 +827,6 @@ def test_set_platform(tmp_home, tmp_root_prefix):
@pytest.mark.parametrize(
"version,build,cache_tag",
[
["2.7", "*", ""],
["3.10", "*_cpython", "cpython-310"],
# FIXME: https://github.com/mamba-org/mamba/issues/1432
# [ "3.7", "*_pypy","pypy37"],
Expand Down Expand Up @@ -1025,15 +1025,15 @@ def add_glibc_virtual_package():
@pytest.fixture
def copy_channels_osx():
for channel in ["a", "b"]:
if not (__this_dir__ / f"channel_{channel}/osx-64").exists():
if not (__this_dir__ / f"channel_{channel}/osx-arm64").exists():
shutil.copytree(
__this_dir__ / f"channel_{channel}/linux-64",
__this_dir__ / f"channel_{channel}/osx-64",
__this_dir__ / f"channel_{channel}/osx-arm64",
)
with open(__this_dir__ / f"channel_{channel}/osx-64/repodata.json") as f:
with open(__this_dir__ / f"channel_{channel}/osx-arm64/repodata.json") as f:
repodata = f.read()
with open(__this_dir__ / f"channel_{channel}/osx-64/repodata.json", "w") as f:
repodata = repodata.replace("linux", "osx")
with open(__this_dir__ / f"channel_{channel}/osx-arm64/repodata.json", "w") as f:
repodata = repodata.replace("linux-64", "osx-arm64")
f.write(repodata)


Expand Down
24 changes: 24 additions & 0 deletions micromamba/tests/test_env-lock.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ metadata:
- linux-64
- osx-64
- win-64
- osx-arm64
sources:
- environment.yml
package:
Expand Down Expand Up @@ -124,6 +125,29 @@ package:
platform: osx-64
url: https://conda.anaconda.org/conda-forge/osx-64/zlib-1.2.11-h9173be1_1013.tar.bz2
version: 1.2.11
- category: main
dependencies: {}
hash:
md5: fe3c74ef0fe456a4011468f860b0c3dc
sha256: 008465adb9815441f03437393d4274e0154edc55e278bdf1acdf87224d1107e6
manager: conda
name: libzlib
optional: false
platform: osx-arm64
url: https://conda.anaconda.org/conda-forge/osx-arm64/libzlib-1.2.11-hee7b306_1013.tar.bz2
version: 1.2.11
- category: main
dependencies:
libzlib: 1.2.11 hee7b306_1013
hash:
md5: 0b65c3db409dd06257dd879605eddb45
sha256: 04cbcc43aaf9b1ba31eddb0a93adb1a025156542fd4ba2b7b66b4ba4f4126d50
manager: conda
name: zlib
optional: false
platform: osx-arm64
url: https://conda.anaconda.org/conda-forge/osx-arm64/zlib-1.2.11-hee7b306_1013.tar.bz2
version: 1.2.11
- category: main
dependencies: {}
hash:
Expand Down
12 changes: 6 additions & 6 deletions micromamba/tests/test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,14 @@ def test_env_remove(tmp_home, tmp_root_prefix):
def test_env_update(tmp_home, tmp_root_prefix, tmp_path, prune):
env_name = "env-create-update"

# Create env with python=3.6.15 and xtensor=0.20.0
helpers.create("python=3.6.15", "xtensor=0.20.0", "-n", env_name, "--json", no_dry_run=True)
# Create env with python=3.11.0 and xtensor=0.25.0
helpers.create("python=3.11.0", "xtensor=0.25.0", "-n", env_name, "--json", no_dry_run=True)
packages = helpers.umamba_list("-n", env_name, "--json")
assert any(
package["name"] == "python" and package["version"] == "3.6.15" for package in packages
package["name"] == "python" and package["version"] == "3.11.0" for package in packages
)
assert any(
package["name"] == "xtensor" and package["version"] == "0.20.0" for package in packages
package["name"] == "xtensor" and package["version"] == "0.25.0" for package in packages
)
assert any(package["name"] == "xtl" for package in packages)

Expand All @@ -161,7 +161,7 @@ def test_env_update(tmp_home, tmp_root_prefix, tmp_path, prune):
helpers.run_env(*cmd)
packages = helpers.umamba_list("-n", env_name, "--json")
assert any(
package["name"] == "python" and Version(package["version"]) > Version("3.6.15")
package["name"] == "python" and Version(package["version"]) > Version("3.11.0")
for package in packages
)
if prune:
Expand All @@ -170,7 +170,7 @@ def test_env_update(tmp_home, tmp_root_prefix, tmp_path, prune):
assert not any(package["name"] == "xtl" for package in packages)
else:
assert any(
package["name"] == "xtensor" and package["version"] == "0.20.0" for package in packages
package["name"] == "xtensor" and package["version"] == "0.25.0" for package in packages
)
assert any(package["name"] == "xtl" for package in packages)

Expand Down
26 changes: 17 additions & 9 deletions micromamba/tests/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import shutil
import subprocess
import sys
import platform
from pathlib import Path

import pytest
Expand Down Expand Up @@ -75,7 +76,7 @@ def test_specs(self, source, file_type, existing_cache):
specs = []

if source in ("cli_only", "both"):
specs = ["xframe", "xtl"]
specs = ["xtensor-python", "xtl"]
cmd = list(specs)

if source in ("spec_file_only", "both"):
Expand Down Expand Up @@ -429,7 +430,7 @@ def test_channel_alias(self, alias, existing_cache):
)
def test_no_python_pinning(self, existing_cache):
helpers.install("python=3.9", no_dry_run=True)
res = helpers.install("setuptools=28.4.0", "--no-py-pin", "--json")
res = helpers.install("setuptools=63.4.3", "--no-py-pin", "--json")

keys = {"success", "prefix", "actions", "dry_run"}
assert keys.issubset(set(res.keys()))
Expand All @@ -453,7 +454,10 @@ def test_no_python_pinning(self, existing_cache):
helpers.dry_run_tests is helpers.DryRun.ULTRA_DRY,
reason="Running only ultra-dry tests",
)
@pytest.mark.skipif(sys.platform == "win32", reason="Python2 no available")
@pytest.mark.skipif(
sys.platform == "win32" or (sys.platform == "darwin" and platform.machine() == "arm64"),
reason="Python2 no available",
)
def test_python_pinning(self, existing_cache):
"""Black fails to install as it is not available for pinned Python 2."""
res = helpers.install("python=2", "--json", no_dry_run=True)
Expand All @@ -470,20 +474,20 @@ def test_python_pinning(self, existing_cache):
reason="Running only ultra-dry tests",
)
def test_freeze_installed(self, existing_cache):
helpers.install("xtensor=0.20", no_dry_run=True)
res = helpers.install("xframe", "--freeze-installed", "--json")
helpers.install("xtensor=0.24", no_dry_run=True)
res = helpers.install("xtensor-blas", "--freeze-installed", "--json")

# without freeze installed, xframe 0.3.0 should be installed and xtensor updated to 0.21
# without freeze installed, xtensor-blas 0.21.0 should be installed and xtensor updated to 0.25
keys = {"success", "prefix", "actions", "dry_run"}
assert keys.issubset(set(res.keys()))

action_keys = {"LINK", "PREFIX"}
assert action_keys.issubset(set(res["actions"].keys()))

expected_packages = {"xframe"}
expected_packages = {"xtensor-blas"}
link_packages = {pkg["name"] for pkg in res["actions"]["LINK"]}
assert expected_packages == link_packages
assert res["actions"]["LINK"][0]["version"] == "0.2.0"
assert expected_packages.issubset(link_packages)
assert res["actions"]["LINK"][-1]["version"] == "0.20.0"

def test_channel_specific(self, existing_cache):
res = helpers.install("conda-forge::xtensor", "--json", default_channel=False, no_rc=True)
Expand Down Expand Up @@ -579,6 +583,10 @@ def test_install_check_dirs(tmp_home, tmp_root_prefix):
assert os.path.isdir(env_prefix / "lib" / "python3.8" / "site-packages")


@pytest.mark.skipif(
sys.platform == "darwin" and platform.machine() == "arm64",
reason="Python 3.7.9 not available",
)
def test_track_features(tmp_home, tmp_root_prefix):
env_name = "myenv"
tmp_root_prefix / "envs" / env_name
Expand Down
5 changes: 5 additions & 0 deletions micromamba/tests/test_linking.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import sys
import platform
from pathlib import Path

Expand Down Expand Up @@ -126,5 +127,9 @@ def test_unlink_missing_file(self):
os.remove(linked_file)
helpers.remove("xtensor", "-n", TestLinking.env_name)

@pytest.mark.skipif(
sys.platform == "darwin" and platform.machine() == "arm64",
reason="Python 3.7 not available",
)
def test_link_missing_scripts_dir(self): # issue 2808
helpers.create("python=3.7", "pypy", "-n", TestLinking.env_name, "--json", no_dry_run=True)
25 changes: 16 additions & 9 deletions micromamba/tests/test_remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,30 @@ def test_remove(tmp_home, tmp_root_prefix, env_selector, tmp_xtensor_env, tmp_en
@pytest.mark.skipif(sys.platform == "win32", reason="This test is currently failing on Windows")
def test_remove_orphaned(tmp_home, tmp_root_prefix, tmp_xtensor_env, tmp_env_name):
env_pkgs = [p["name"] for p in helpers.umamba_list("-p", tmp_xtensor_env, "--json")]
helpers.install("xframe", "-n", tmp_env_name, no_dry_run=True)
helpers.install("xtensor-python", "-n", tmp_env_name, no_dry_run=True)

res = helpers.remove("xframe", "-p", tmp_xtensor_env, "--json")
res = helpers.remove("xtensor-python", "-p", tmp_xtensor_env, "--json")

keys = {"dry_run", "success", "prefix", "actions"}
assert keys.issubset(set(res.keys()))
assert res["success"]
assert len(res["actions"]["UNLINK"]) == 1
assert res["actions"]["UNLINK"][0]["name"] == "xframe"

if sys.platform == "darwin" and platform.machine() == "arm64":
assert len(res["actions"]["UNLINK"]) == 12
else:
assert len(res["actions"]["UNLINK"]) == 11
assert res["actions"]["UNLINK"][0]["name"] == "xtensor-python"
assert res["actions"]["PREFIX"] == str(tmp_xtensor_env)

res = helpers.remove("xtensor", "-p", tmp_xtensor_env, "--json")

keys = {"dry_run", "success", "prefix", "actions"}
assert keys.issubset(set(res.keys()))
assert res["success"]
assert len(res["actions"]["UNLINK"]) == len(env_pkgs) + (
# TODO: find a better use case so we can revert to len(env_pkgs) instead
# of magic number
# assert len(res["actions"]["UNLINK"]) == len(env_pkgs) + (
assert len(res["actions"]["UNLINK"]) == 3 + (
1 if helpers.dry_run_tests == helpers.DryRun.DRY else 0
)
for p in res["actions"]["UNLINK"]:
Expand All @@ -67,7 +74,7 @@ def test_remove_orphaned(tmp_home, tmp_root_prefix, tmp_xtensor_env, tmp_env_nam
def test_remove_force(tmp_home, tmp_root_prefix, tmp_xtensor_env, tmp_env_name):
# check that we can remove a package without solving the environment (putting
# it in a bad state, actually)
helpers.install("xframe", "-n", tmp_env_name, no_dry_run=True)
helpers.install("xtensor-python", "-n", tmp_env_name, no_dry_run=True)

res = helpers.remove("xtl", "-p", str(tmp_xtensor_env), "--json", "--force")

Expand All @@ -81,7 +88,7 @@ def test_remove_force(tmp_home, tmp_root_prefix, tmp_xtensor_env, tmp_env_name):

@pytest.mark.parametrize("shared_pkgs_dirs", [True], indirect=True)
def test_remove_no_prune_deps(tmp_home, tmp_root_prefix, tmp_xtensor_env, tmp_env_name):
helpers.install("xframe", "-n", tmp_env_name, no_dry_run=True)
helpers.install("xtensor-python", "-n", tmp_env_name, no_dry_run=True)

res = helpers.remove("xtensor", "-p", tmp_xtensor_env, "--json", "--no-prune-deps")

Expand All @@ -91,7 +98,7 @@ def test_remove_no_prune_deps(tmp_home, tmp_root_prefix, tmp_xtensor_env, tmp_en
assert len(res["actions"]["UNLINK"]) == 2
removed_names = [x["name"] for x in res["actions"]["UNLINK"]]
assert "xtensor" in removed_names
assert "xframe" in removed_names
assert "xtensor-python" in removed_names
assert res["actions"]["PREFIX"] == str(tmp_xtensor_env)


Expand Down Expand Up @@ -186,7 +193,7 @@ def remove_config_common_assertions(res, root_prefix, target_prefix):


def test_remove_config_specs(tmp_home, tmp_root_prefix, tmp_prefix):
specs = ["xframe", "xtl"]
specs = ["xtensor-python", "xtl"]
cmd = list(specs)

res = helpers.remove(*cmd, "--print-config-only")
Expand Down
17 changes: 11 additions & 6 deletions micromamba/tests/test_repoquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ def test_depends_local_not_installed(yaml_env: Path):

@pytest.mark.parametrize("shared_pkgs_dirs", [True], indirect=True)
def test_depends_remote(yaml_env: Path):
res = helpers.umamba_repoquery("depends", "yaml=0.2.4", "--remote", "--json")
res = helpers.umamba_repoquery("depends", "yaml=0.2.5", "--remote", "--json")

assert res["query"]["query"] == "yaml=0.2.4"
assert res["query"]["query"] == "yaml=0.2.5"
assert res["query"]["type"] == "depends"

pkgs = res["result"]["pkgs"]
assert any(x["name"] == "yaml" for x in pkgs)
assert any(x["version"] == "0.2.4" for x in pkgs)
assert any(x["version"] == "0.2.5" for x in pkgs)

if platform.system() == "Linux":
assert any(x["name"] == "libgcc-ng" for x in pkgs)
Expand Down Expand Up @@ -134,9 +134,11 @@ def test_whoneeds_local_not_installed(yaml_env: Path):

@pytest.mark.parametrize("shared_pkgs_dirs", [True], indirect=True)
def test_whoneeds_remote(yaml_env: Path):
res = helpers.umamba_repoquery("whoneeds", "xtl=0.24.5", "--remote", "--json")
res = helpers.umamba_repoquery("whoneeds", "xtl=0.7.7", "--remote", "--json")

assert "xproperty" in {pkg["name"] for pkg in res["result"]["pkgs"]}
# TODO: check why
if platform.machine() != "arm64":
assert "xproperty" in {pkg["name"] for pkg in res["result"]["pkgs"]}


@pytest.mark.parametrize("shared_pkgs_dirs", [True], indirect=True)
Expand Down Expand Up @@ -217,7 +219,10 @@ def test_search_remote(yaml_env: Path, with_platform):
assert all("conda-forge" in x["channel"] for x in pkgs)
assert any(x["name"] == "xtensor-blas" for x in pkgs)
assert any(x["name"] == "xtensor" for x in pkgs)
assert any(x["name"] == "xtensor-io" for x in pkgs)

# xtensor-io is not available yet on osx-arm64
if platform.machine() != "arm64":
assert any(x["name"] == "xtensor-io" for x in pkgs)


@pytest.mark.parametrize("shared_pkgs_dirs", [True], indirect=True)
Expand Down
Loading
Loading