From ae499a38bc303c55ecd866d25131e32bf4c2ebe9 Mon Sep 17 00:00:00 2001 From: Klaus Zimmermann Date: Fri, 7 Jun 2024 10:40:15 +0000 Subject: [PATCH] Replace logger.warn w/ logger.warning --- conda_build/build.py | 30 +++++++++++++++--------------- conda_build/config.py | 4 ++-- conda_build/environ.py | 28 ++++++++++++++-------------- conda_build/metadata.py | 8 ++++---- conda_build/os_utils/macho.py | 2 +- conda_build/post.py | 4 ++-- conda_build/render.py | 6 +++--- conda_build/source.py | 8 ++++---- conda_build/utils.py | 8 ++++---- conda_build/windows.py | 6 +++--- tests/test_utils.py | 4 ++-- 11 files changed, 54 insertions(+), 54 deletions(-) diff --git a/conda_build/build.py b/conda_build/build.py index ae2c79983f..4501e384a6 100644 --- a/conda_build/build.py +++ b/conda_build/build.py @@ -924,7 +924,7 @@ def copy_test_source_files(m, destination): ) except OSError as e: log = utils.get_logger(__name__) - log.warn( + log.warning( f"Failed to copy {f} into test files. Error was: {str(e)}" ) for ext in ".pyc", ".pyo": @@ -1816,7 +1816,7 @@ def bundle_conda(output, metadata: MetaData, env, stats, **kw): } elif not output.get("script"): if not metadata.always_include_files(): - log.warn( + log.warning( "No files or script found for output {}".format(output.get("name")) ) build_deps = metadata.get_value("requirements/build") @@ -1854,7 +1854,7 @@ def bundle_conda(output, metadata: MetaData, env, stats, **kw): initial_files.remove(f) has_matches = True if not has_matches: - log.warn("Glob %s from always_include_files does not match any files", pat) + log.warning("Glob %s from always_include_files does not match any files", pat) files = post_process_files(metadata, initial_files) if output.get("name") and output.get("name") != "conda": @@ -1913,7 +1913,7 @@ def bundle_conda(output, metadata: MetaData, env, stats, **kw): from conda_verify.verify import Verify except ImportError: Verify = None - log.warn( + log.warning( "Importing conda-verify failed. Please be sure to test your packages. " "conda install conda-verify to make this message go away." ) @@ -1930,7 +1930,7 @@ def bundle_conda(output, metadata: MetaData, env, stats, **kw): exit_on_error=metadata.config.exit_on_verify_error, ) except KeyError as e: - log.warn( + log.warning( "Package doesn't have necessary files. It might be too old to inspect." f"Legacy noarch packages are known to fail. Full message was {e}" ) @@ -2157,7 +2157,7 @@ def _write_activation_text(script_path, m): _write_sh_activation_text(fh, m) else: log = utils.get_logger(__name__) - log.warn( + log.warning( f"not adding activation to {script_path} - I don't know how to do so for " "this file type" ) @@ -2375,7 +2375,7 @@ def build( ): specs.append(vcs_source) - log.warn( + log.warning( "Your recipe depends on %s at build time (for templates), " "but you have not listed it as a build dependency. Doing " "so for this build.", @@ -2837,7 +2837,7 @@ def _construct_metadata_for_test_from_recipe(recipe_dir, config): render_recipe(recipe_dir, config=config, reset_build_id=False) )[0][1] log = utils.get_logger(__name__) - log.warn( + log.warning( "Testing based on recipes is deprecated as of conda-build 3.16.0. Please adjust " "your code to pass your desired conda package to test instead." ) @@ -2887,7 +2887,7 @@ def _construct_metadata_for_test_from_package(package, config): is_channel = True if not is_channel: - log.warn( + log.warning( "Copying package to conda-build croot. No packages otherwise alongside yours will" " be available unless you specify -c local. To avoid this warning, your package " "must reside in a channel structure with platform-subfolders. See more info on " @@ -3141,7 +3141,7 @@ def _write_test_run_script( tf.write(f'call "{shell_file}"\n') tf.write("IF %ERRORLEVEL% NEQ 0 exit /B 1\n") else: - log.warn( + log.warning( "Found sh test file on windows. Ignoring this for now (PRs welcome)" ) elif os.path.splitext(shell_file)[1] == ".sh": @@ -3326,7 +3326,7 @@ def test( # Needs to come after create_files in case there's test/source_files shutil_move_more_retrying(config.work_dir, dest, "work") else: - log.warn( + log.warning( "Not moving work directory after build. Your package may depend on files " "in the work directory that are not included with your package" ) @@ -3390,7 +3390,7 @@ def test( CondaError, AssertionError, ) as exc: - log.warn( + log.warning( "failed to get package records, retrying. exception was: %s", str(exc) ) tests_failed( @@ -3517,7 +3517,7 @@ def tests_failed(package_or_metadata, move_broken, broken_dir, config): log = utils.get_logger(__name__) try: shutil.move(pkg, dest) - log.warn( + log.warning( f"Tests failed for {os.path.basename(pkg)} - moving package to {broken_dir}" ) except OSError: @@ -3687,7 +3687,7 @@ def build_tree( # downstreams can be a dict, for adding capability for worker labels if hasattr(downstreams, "keys"): downstreams = list(downstreams.keys()) - log.warn( + log.warning( "Dictionary keys for downstreams are being " "ignored right now. Coming soon..." ) @@ -3726,7 +3726,7 @@ def build_tree( UnsatisfiableError, DependencyNeedsBuildingError, ) as e: - log.warn( + log.warning( f"Skipping downstream test for spec {dep}; was " f"unsatisfiable. Error was {e}" ) diff --git a/conda_build/config.py b/conda_build/config.py index 8e444c1a42..86fbe438d1 100644 --- a/conda_build/config.py +++ b/conda_build/config.py @@ -324,7 +324,7 @@ def arch(self): @arch.setter def arch(self, value): log = get_logger(__name__) - log.warn( + log.warning( "Setting build arch. This is only useful when pretending to be on another " "arch, such as for rendering necessary dependencies on a non-native arch. " "I trust that you know what you're doing." @@ -340,7 +340,7 @@ def platform(self): @platform.setter def platform(self, value): log = get_logger(__name__) - log.warn( + log.warning( "Setting build platform. This is only useful when " "pretending to be on another platform, such as " "for rendering necessary dependencies on a non-native " diff --git a/conda_build/environ.py b/conda_build/environ.py index 0ce38d1668..3113ec7f8a 100644 --- a/conda_build/environ.py +++ b/conda_build/environ.py @@ -902,7 +902,7 @@ def get_install_actions( BuildLockError, ) as exc: if "lock" in str(exc): - log.warn( + log.warning( "failed to get package records, retrying. exception was: %s", str(exc), ) @@ -923,7 +923,7 @@ def get_install_actions( ): pkg_dir = os.path.dirname(pkg_dir) folder += 1 - log.warn( + log.warning( "I think conda ended up with a partial extraction for %s. " "Removing the folder and retrying", pkg_dir, @@ -931,7 +931,7 @@ def get_install_actions( if pkg_dir in context.pkgs_dirs and os.path.isdir(pkg_dir): utils.rm_rf(pkg_dir) if retries < max_env_retry: - log.warn( + log.warning( "failed to get package records, retrying. exception was: %s", str(exc), ) @@ -1064,20 +1064,20 @@ def create_env( or isinstance(exc, PaddingError) ) and config.prefix_length > 80: if config.prefix_length_fallback: - log.warn( + log.warning( "Build prefix failed with prefix length %d", config.prefix_length, ) - log.warn("Error was: ") - log.warn(str(exc)) - log.warn( + log.warning("Error was: ") + log.warning(str(exc)) + log.warning( "One or more of your package dependencies needs to be rebuilt " "with a longer prefix length." ) - log.warn( + log.warning( "Falling back to legacy prefix length of 80 characters." ) - log.warn( + log.warning( "Your package will not install into prefixes > 80 characters." ) config.prefix_length = 80 @@ -1099,7 +1099,7 @@ def create_env( raise elif "lock" in str(exc): if retry < config.max_env_retry: - log.warn( + log.warning( "failed to create env, retrying. exception was: %s", str(exc), ) @@ -1125,7 +1125,7 @@ def create_env( ): pkg_dir = os.path.dirname(pkg_dir) folder += 1 - log.warn( + log.warning( "I think conda ended up with a partial extraction for %s. " "Removing the folder and retrying", pkg_dir, @@ -1133,7 +1133,7 @@ def create_env( if os.path.isdir(pkg_dir): utils.rm_rf(pkg_dir) if retry < config.max_env_retry: - log.warn( + log.warning( "failed to create env, retrying. exception was: %s", str(exc), ) @@ -1164,7 +1164,7 @@ def create_env( if isinstance(exc, AssertionError): with utils.try_acquire_locks(locks, timeout=config.timeout): pkg_dir = os.path.dirname(os.path.dirname(str(exc))) - log.warn( + log.warning( "I think conda ended up with a partial extraction for %s. " "Removing the folder and retrying", pkg_dir, @@ -1172,7 +1172,7 @@ def create_env( if os.path.isdir(pkg_dir): utils.rm_rf(pkg_dir) if retry < config.max_env_retry: - log.warn( + log.warning( "failed to create env, retrying. exception was: %s", str(exc) ) create_env( diff --git a/conda_build/metadata.py b/conda_build/metadata.py index 3b29e70d4c..d41e81a6db 100644 --- a/conda_build/metadata.py +++ b/conda_build/metadata.py @@ -1127,7 +1127,7 @@ def finalize_outputs_pass( raise else: log = utils.get_logger(__name__) - log.warn( + log.warning( "Could not finalize metadata due to missing dependencies: " f"{e.packages}" ) @@ -1348,7 +1348,7 @@ def parse_again( log = utils.get_logger(__name__) if kw: - log.warn( + log.warning( "using unsupported internal conda-build function `parse_again`. Please use " "conda_build.api.render instead." ) @@ -1562,7 +1562,7 @@ def get_value(self, name, default=None, autotype=True): # is passed in with an index, e.g. get_value('source/0/git_url') if index is None: log = utils.get_logger(__name__) - log.warn( + log.warning( f"No index specified in get_value('{name}'). Assuming index 0." ) index = 0 @@ -3019,7 +3019,7 @@ def _get_used_vars_output_script(self): ) else: log = utils.get_logger(__name__) - log.warn( + log.warning( f"Not detecting used variables in output script {script}; conda-build only knows " "how to search .sh and .bat files right now." ) diff --git a/conda_build/os_utils/macho.py b/conda_build/os_utils/macho.py index 17fc5d5a13..8e02c8ee86 100644 --- a/conda_build/os_utils/macho.py +++ b/conda_build/os_utils/macho.py @@ -258,7 +258,7 @@ def _chmod(filename, mode): os.chmod(filename, mode) except (OSError, utils.PermissionError) as e: log = utils.get_logger(__name__) - log.warn(str(e)) + log.warning(str(e)) def install_name_tool(args, build_prefix=None, verbose=False): diff --git a/conda_build/post.py b/conda_build/post.py index 67c6a355a7..7ed419eebf 100644 --- a/conda_build/post.py +++ b/conda_build/post.py @@ -1595,7 +1595,7 @@ def post_process_shared_lib(m, f, files, host_prefix=None): elif codefile == machofile: if m.config.host_platform != "osx": log = utils.get_logger(__name__) - log.warn( + log.warning( "Found Mach-O file but patching is only supported on macOS, skipping: %s", path, ) @@ -1631,7 +1631,7 @@ def fix_permissions(files, prefix): lchmod(path, new_mode) except (OSError, utils.PermissionError) as e: log = utils.get_logger(__name__) - log.warn(str(e)) + log.warning(str(e)) def check_menuinst_json(files, prefix) -> None: diff --git a/conda_build/render.py b/conda_build/render.py index cc3bcd87c0..919e33ef1e 100644 --- a/conda_build/render.py +++ b/conda_build/render.py @@ -739,14 +739,14 @@ def finalize_metadata( if build_unsat or host_unsat: m.final = False log = utils.get_logger(__name__) - log.warn( + log.warning( f"Returning non-final recipe for {m.dist()}; one or more dependencies " "was unsatisfiable:" ) if build_unsat: - log.warn(f"Build: {build_unsat}") + log.warning(f"Build: {build_unsat}") if host_unsat: - log.warn(f"Host: {host_unsat}") + log.warning(f"Host: {host_unsat}") else: m.final = True if is_top_level: diff --git a/conda_build/source.py b/conda_build/source.py index 903f5d7ca0..983188dd5a 100644 --- a/conda_build/source.py +++ b/conda_build/source.py @@ -74,7 +74,7 @@ def download_to_cache(cache_folder, recipe_path, source_dict, verbose=False): hash_added = True break else: - log.warn( + log.warning( f"No hash (md5, sha1, sha256) provided for {unhashed_fn}. Source download forced. " "Add hash to recipe to use source cache." ) @@ -102,10 +102,10 @@ def download_to_cache(cache_folder, recipe_path, source_dict, verbose=False): with LoggingContext(): download(url, path) except CondaHTTPError as e: - log.warn(f"Error: {str(e).strip()}") + log.warning(f"Error: {str(e).strip()}") rm_rf(path) except RuntimeError as e: - log.warn(f"Error: {str(e).strip()}") + log.warning(f"Error: {str(e).strip()}") rm_rf(path) else: if verbose: @@ -467,7 +467,7 @@ def git_info(src_dir, build_prefix, git=None, verbose=True, fo=None): if not git: git = external.find_executable("git", build_prefix) if not git: - log.warn( + log.warning( "git not installed in root environment. Skipping recording of git info." ) return diff --git a/conda_build/utils.py b/conda_build/utils.py index a2c456c66e..17d1c1f031 100644 --- a/conda_build/utils.py +++ b/conda_build/utils.py @@ -257,8 +257,8 @@ def _execute(self, *args, **kwargs): psutil = None psutil_exceptions = (OSError, ValueError) log = get_logger(__name__) - log.warn(f"psutil import failed. Error was {e}") - log.warn( + log.warning(f"psutil import failed. Error was {e}") + log.warning( "only disk usage and time statistics will be available. Install psutil to " "get CPU time and memory usage statistics." ) @@ -594,7 +594,7 @@ def copy_into( src_folder = os.getcwd() if os.path.islink(src) and not os.path.exists(os.path.realpath(src)): - log.warn("path %s is a broken symlink - ignoring copy", src) + log.warning("path %s is a broken symlink - ignoring copy", src) return if not lock and locking: @@ -1890,7 +1890,7 @@ def ensure_valid_spec(spec: str | MatchSpec, warn: bool = False) -> str | MatchS if "*" not in spec: if match.group(1) not in ("python", "vc") and warn: log = get_logger(__name__) - log.warn( + log.warning( f"Adding .* to spec '{spec}' to ensure satisfiability. Please " "consider putting {{{{ var_name }}}}.* or some relational " "operator (>/=/<=) on this spec in meta.yaml, or if req is " diff --git a/conda_build/windows.py b/conda_build/windows.py index 00287c50bf..8643431a5b 100644 --- a/conda_build/windows.py +++ b/conda_build/windows.py @@ -102,16 +102,16 @@ def msvc_env_cmd(bits, config, override=None): # there's clear user demand, it's not clear that we should invest the # effort into updating a known deprecated function for a new platform. log = get_logger(__name__) - log.warn( + log.warning( "Using legacy MSVC compiler setup. This will be removed in conda-build 4.0. " "If this recipe does not use a compiler, this message is safe to ignore. " "Otherwise, use {{compiler('')}} jinja2 in requirements/build." ) if bits not in ["64", "32"]: - log.warn(f"The legacy MSVC compiler setup does not support {bits} builds. ") + log.warning(f"The legacy MSVC compiler setup does not support {bits} builds. ") return "" if override: - log.warn( + log.warning( "msvc_compiler key in meta.yaml is deprecated. Use the new" "variant-powered compiler configuration instead. Note that msvc_compiler" "is incompatible with the new {{{{compiler('c')}}}} jinja scheme." diff --git a/tests/test_utils.py b/tests/test_utils.py index 70a2981203..98733546b5 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -163,7 +163,7 @@ def test_logger_filtering(caplog, capfd): log.info("test info message") log.info("test duplicate message") log.info("test duplicate message") - log.warn("test warn message") + log.warning("test warn message") log.error("test error message") out, err = capfd.readouterr() assert "test debug message" in out @@ -211,7 +211,7 @@ def test_logger_config_from_file(testing_workdir, capfd, mocker): ) log = utils.get_logger(__name__) # default log level is INFO, but our config file should set level to DEBUG - log.warn("test message") + log.warning("test message") # output should have gone to stdout according to config above. out, err = capfd.readouterr() assert "test message" in out