From d332420fc2c764e0077e2b02071469a6f0b73d23 Mon Sep 17 00:00:00 2001 From: Wolf Vollprecht Date: Wed, 6 Sep 2023 16:45:44 +0200 Subject: [PATCH] fix up some deprecation warnings and test with latest versions of conda and libmambapy --- boa/core/recipe_output.py | 4 ++-- boa/core/run_build.py | 4 ++-- boa/core/solver.py | 5 +++-- boa/core/test.py | 36 +++++++++++------------------------- setup.py | 1 + tests/env.yml | 2 +- 6 files changed, 20 insertions(+), 32 deletions(-) diff --git a/boa/core/recipe_output.py b/boa/core/recipe_output.py index 6fbeeff8..3801b339 100644 --- a/boa/core/recipe_output.py +++ b/boa/core/recipe_output.py @@ -536,10 +536,10 @@ def _solve_env(self, env, all_outputs): subdir, output_folder=self.config.output_folder ) if env == "host": - MambaContext().target_prefix = self.config.host_prefix + MambaContext().prefix_params.target_prefix = self.config.host_prefix # solver.replace_installed(self.config.host_prefix) elif env == "build": - MambaContext().target_prefix = self.config.build_prefix + MambaContext().prefix_params.target_prefix = self.config.build_prefix # solver.replace_installed(self.config.build_prefix) t = solver.solve(specs, [pkg_cache]) diff --git a/boa/core/run_build.py b/boa/core/run_build.py index 4ff3aed6..77262e5f 100644 --- a/boa/core/run_build.py +++ b/boa/core/run_build.py @@ -333,7 +333,7 @@ def build_recipe( rm_rf(o.config.build_prefix) mkdir_p(os.path.join(o.config.build_prefix, "conda-meta")) try: - MambaContext().target_prefix = o.config.build_prefix + MambaContext().prefix_params.target_prefix = o.config.build_prefix o.transactions["build"]["transaction"].print() o.transactions["build"]["transaction"].execute( PrefixData(o.config.build_prefix), @@ -344,7 +344,7 @@ def build_recipe( if "host" in o.transactions: mkdir_p(os.path.join(o.config.host_prefix, "conda-meta")) - MambaContext().target_prefix = o.config.host_prefix + MambaContext().prefix_params.target_prefix = o.config.host_prefix o.transactions["host"]["transaction"].print() o.transactions["host"]["transaction"].execute( PrefixData(o.config.host_prefix) diff --git a/boa/core/solver.py b/boa/core/solver.py index ef7cf9d1..d405baf3 100644 --- a/boa/core/solver.py +++ b/boa/core/solver.py @@ -9,7 +9,6 @@ from conda.common.serialize import json_dump from conda.models.prefix_graph import PrefixGraph from conda.core.prefix_data import PrefixData -from conda._vendor.boltons.setutils import IndexedSet from conda.models.match_spec import MatchSpec from conda.common.url import remove_auth, split_anaconda_token from conda.core.index import _supplement_index_with_system @@ -19,6 +18,8 @@ from conda_build.conda_interface import pkgs_dirs from conda.core.package_cache_data import PackageCacheData +from boltons.setutils import IndexedSet + import libmambapy import mamba from mamba.utils import get_index, load_channels, to_package_record_from_subjson @@ -238,7 +239,7 @@ def solve(self, specs, pkg_cache_path=None): pkg_cache_path = pkgs_dirs package_cache = libmambapy.MultiPackageCache(pkg_cache_path) - return libmambapy.Transaction(api_solver, package_cache) + return libmambapy.Transaction(self.pool, api_solver, package_cache) def solve_for_action(self, specs, prefix): t = self.solve(specs) diff --git a/boa/core/test.py b/boa/core/test.py index 9cdebfe6..c59bb274 100644 --- a/boa/core/test.py +++ b/boa/core/test.py @@ -408,18 +408,14 @@ def check_file_existence(f_paths, check_parent_dir=False): for each_f in f_paths: if check_parent_dir and os.path.isdir(Path(each_f).parent): console.print( - f"[green]\N{check mark} {Path(each_f).parent} (directory)[/green]".encode( - "utf-8" - ) + f"[green]\N{check mark} {Path(each_f).parent} (directory)[/green]" ) if os.path.isdir(each_f): - console.print( - f"[green]\N{check mark} {each_f} (directory)[/green]".encode("utf-8") - ) + console.print(f"[green]\N{check mark} {each_f} (directory)[/green]") elif os.path.isfile(each_f): - console.print(f"[green]\N{check mark} {each_f}[/green]".encode("utf-8")) + console.print(f"[green]\N{check mark} {each_f}[/green]") else: - console.print(f"[red]\N{multiplication x} {each_f}[/red]".encode("utf-8")) + console.print(f"[red]\N{multiplication x} {each_f}[/red]") all_exist = False return all_exist @@ -519,13 +515,9 @@ def check_cmake(prefix, cmake_find): stderr=subprocess.DEVNULL, ) if cmake_check.returncode == 0: - console.print( - f"[green]\N{check mark} {each_f}[/green]".encode("utf-8") - ) + console.print(f"[green]\N{check mark} {each_f}[/green]") else: - console.print( - f"[red]\N{multiplication x} {each_f}[/red]".encode("utf-8") - ) + console.print(f"[red]\N{multiplication x} {each_f}[/red]") test_cmake = False return test_cmake @@ -552,11 +544,9 @@ def check_pkg_config(prefix, pkg_config): pkg_config_exists.returncode == 0 and pkg_config_validate.returncode == 0 ): - console.print(f"[green]\N{check mark} {each_f}[/green]".encode("utf-8")) + console.print(f"[green]\N{check mark} {each_f}[/green]") else: - console.print( - f"[red]\N{multiplication x} {each_f}[/red]".encode("utf-8") - ) + console.print(f"[red]\N{multiplication x} {each_f}[/red]") test_pkg_config = False return test_pkg_config @@ -578,13 +568,9 @@ def check_glob(prefix, glob_paths): each_glob_path = os.path.join(prefix, each_f) if glob(each_glob_path): for each_gp in glob(each_glob_path): - console.print( - f"[green]\N{check mark} {each_gp}[/green]".encode("utf-8") - ) + console.print(f"[green]\N{check mark} {each_gp}[/green]") else: - console.print( - f"[red]\N{multiplication x} {each_glob_path}[/red]".encode("utf-8") - ) + console.print(f"[red]\N{multiplication x} {each_glob_path}[/red]") test_glob = False return test_glob @@ -818,7 +804,7 @@ def run_test( pkg_cache_path = PackageCacheData.first_writable().pkgs_dir solver.replace_channels() - MambaContext().target_prefix = metadata.config.test_prefix + MambaContext().prefix_params.target_prefix = metadata.config.test_prefix transaction = solver.solve(specs, [pkg_cache_path]) downloaded = transaction.fetch_extract_packages() diff --git a/setup.py b/setup.py index d3d741e6..7c40a5b1 100644 --- a/setup.py +++ b/setup.py @@ -20,6 +20,7 @@ "prompt-toolkit", "joblib", "beautifulsoup4", + "boltons", ] setup( diff --git a/tests/env.yml b/tests/env.yml index c71c80d2..18cf0572 100644 --- a/tests/env.yml +++ b/tests/env.yml @@ -5,7 +5,7 @@ dependencies: - python>=3.7 - pip - mamba - - libmambapy <=1.4.2 + - libmambapy - pytest - "conda-build>=3.20" - ruamel