Test with xtensor-python instead of unmaintained xframe (#3286)

Upgraded tests to use packages available on osx-arm64
This commit is contained in:
Johan Mabille 2024-05-03 18:02:33 +02:00 committed by GitHub
parent 46036e1917
commit dcd777fbd1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 105 additions and 59 deletions

View File

@ -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

View File

@ -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

View File

@ -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"):
@ -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)
@ -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))
@ -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"
@ -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)
@ -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"],
@ -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)

View File

@ -24,6 +24,7 @@ metadata:
- linux-64
- osx-64
- win-64
- osx-arm64
sources:
- environment.yml
package:
@ -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:

View File

@ -138,14 +138,14 @@ dependencies:
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)
@ -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:
@ -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)

View File

@ -2,6 +2,7 @@ import os
import shutil
import subprocess
import sys
import platform
from pathlib import Path
import pytest
@ -75,7 +76,7 @@ class TestInstall:
specs = []
if source in ("cli_only", "both"):
specs = ["xframe", "xtl"]
specs = ["xtensor-python", "xtl"]
cmd = list(specs)
if source in ("spec_file_only", "both"):
@ -429,7 +430,7 @@ class TestInstall:
)
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()))
@ -453,7 +454,10 @@ class TestInstall:
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)
@ -470,20 +474,20 @@ class TestInstall:
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)
@ -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

View File

@ -1,4 +1,5 @@
import os
import sys
import platform
from pathlib import Path
@ -126,5 +127,9 @@ class TestLinking:
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)

View File

@ -39,15 +39,19 @@ 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")
@ -55,7 +59,10 @@ def test_remove_orphaned(tmp_home, tmp_root_prefix, tmp_xtensor_env, tmp_env_nam
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"]:
@ -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")
@ -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")
@ -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)
@ -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")

View File

@ -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)
@ -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)
@ -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)

View File

@ -123,12 +123,12 @@ class TestUpdate:
assert requests_link["build_string"] == prev_requests["build_string"]
def test_further_constrained_update(self, env_created):
update_res = helpers.update("xtensor==0.21.1=*_0", "--json")
update_res = helpers.update("xtensor==0.24.5=*_0", "--json")
xtensor_link = [
to_link for to_link in update_res["actions"]["LINK"] if to_link["name"] == "xtensor"
][0]
assert xtensor_link["version"] == "0.21.1"
assert xtensor_link["version"] == "0.24.5"
assert xtensor_link["build_number"] == 0
def test_classic_spec(self, env_created):
@ -269,7 +269,7 @@ class TestUpdateConfig:
specs = []
if source in ("cli_only", "both"):
specs = ["xframe", "xtl"]
specs = ["xtensor-python", "xtl"]
cmd = list(specs)
if source in ("spec_file_only", "both"):