Skip to content

Commit

Permalink
Replace logger.warn w/ logger.warning (#5364)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
zklaus and pre-commit-ci[bot] authored Jun 7, 2024
1 parent 2ada61d commit fc9a9f6
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 54 deletions.
32 changes: 17 additions & 15 deletions conda_build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,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":
Expand Down Expand Up @@ -1817,7 +1817,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")
Expand Down Expand Up @@ -1855,7 +1855,9 @@ 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":
Expand Down Expand Up @@ -1914,7 +1916,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."
)
Expand All @@ -1931,7 +1933,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}"
)
Expand Down Expand Up @@ -2158,7 +2160,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"
)
Expand Down Expand Up @@ -2376,7 +2378,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.",
Expand Down Expand Up @@ -2838,7 +2840,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."
)
Expand Down Expand Up @@ -2888,7 +2890,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 "
Expand Down Expand Up @@ -3142,7 +3144,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":
Expand Down Expand Up @@ -3327,7 +3329,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"
)
Expand Down Expand Up @@ -3391,7 +3393,7 @@ def test(
CondaError,
AssertionError,
) as exc:
log.warn(
log.warning(
"failed to get package records, retrying. exception was: %s", str(exc)
)
tests_failed(
Expand Down Expand Up @@ -3518,7 +3520,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:
Expand Down Expand Up @@ -3688,7 +3690,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..."
)
Expand Down Expand Up @@ -3727,7 +3729,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}"
)
Expand Down
4 changes: 2 additions & 2 deletions conda_build/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand All @@ -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 "
Expand Down
28 changes: 14 additions & 14 deletions conda_build/environ.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)
Expand All @@ -923,15 +923,15 @@ 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,
)
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),
)
Expand Down Expand Up @@ -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
Expand All @@ -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),
)
Expand All @@ -1125,15 +1125,15 @@ 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,
)
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),
)
Expand Down Expand Up @@ -1164,15 +1164,15 @@ 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,
)
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(
Expand Down
8 changes: 4 additions & 4 deletions conda_build/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
)
Expand Down Expand Up @@ -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."
)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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."
)
Expand Down
2 changes: 1 addition & 1 deletion conda_build/os_utils/macho.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions conda_build/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions conda_build/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions conda_build/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."
)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions conda_build/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."
)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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 "
Expand Down
Loading

0 comments on commit fc9a9f6

Please sign in to comment.