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

sys.exit removals from build.py #5402

Merged
merged 12 commits into from
Jul 12, 2024
13 changes: 6 additions & 7 deletions conda_build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -1663,7 +1663,7 @@ def post_process_files(m: MetaData, initial_prefix_files):
meta_files = (
tuple(f for f in new_files if m.config.meta_dir in join(host_prefix, f)),
)
sys.exit(
CondaBuildUserError(
beeankha marked this conversation as resolved.
Show resolved Hide resolved
f"Error: Untracked file(s) {meta_files} found in conda-meta directory. This error usually comes "
"from using conda in the build script. Avoid doing this, as it can lead to packages "
"that include their dependencies."
Expand Down Expand Up @@ -3608,12 +3608,11 @@ def check_external():
if on_linux:
patchelf = external.find_executable("patchelf")
if patchelf is None:
sys.exit(
"Error:\n"
f" Did not find 'patchelf' in: {os.pathsep.join(external.dir_paths)}\n"
" 'patchelf' is necessary for building conda packages on Linux with\n"
" relocatable ELF libraries. You can install patchelf using conda install\n"
" patchelf.\n"
raise CondaBuildUserError(
f"Did not find 'patchelf' in: {os.pathsep.join(external._DIR_PATHS)} "
f"'patchelf' is necessary for building conda packages on Linux with "
f"relocatable ELF libraries. You can install patchelf using conda install "
f"patchelf."
)


Expand Down
4 changes: 2 additions & 2 deletions conda_build/cli/main_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import argparse
import logging
import sys
import warnings
from glob import glob
from itertools import chain
Expand All @@ -22,6 +21,7 @@
get_or_merge_config,
zstd_compression_level_default,
)
from ..exceptions import CondaBuildUserError
from ..utils import LoggingContext
from .actions import KeyValueAction
from .main_render import get_render_parser
Expand Down Expand Up @@ -576,7 +576,7 @@ def execute(args: Sequence[str] | None = None) -> int:
if failed_recipes:
print("Failed recipes:")
dashlist(failed_recipes)
sys.exit(len(failed_recipes))
raise CondaBuildUserError(len(failed_recipes))
else:
print("All tests passed")
elif parsed.source:
Expand Down
5 changes: 3 additions & 2 deletions conda_build/features.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Copyright (C) 2014 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
import os
import sys

from .exceptions import CondaBuildUserError

env_vars = [
"FEATURE_DEBUG",
Expand All @@ -15,7 +16,7 @@
for key, value in os.environ.items():
if key in env_vars:
if value not in ("0", "1"):
sys.exit(
raise CondaBuildUserError(
f"Error: did not expect environment variable '{key}' "
f"being set to '{value}' (not '0' or '1')"
)
Expand Down
6 changes: 4 additions & 2 deletions tests/cli/test_main_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ def test_slash_in_recipe_arg_keeps_build_id(

@pytest.mark.sanity
@pytest.mark.skipif(on_win, reason="prefix is always short on win.")
def test_build_long_test_prefix_default_enabled(mocker, testing_workdir):
def test_build_long_test_prefix_default_enabled(
mocker: MockerFixture, testing_workdir: str
) -> None:
recipe_path = os.path.join(metadata_dir, "_test_long_test_prefix")
args = [recipe_path, "--no-anaconda-upload"]
main_build.execute(args)
Expand Down Expand Up @@ -472,7 +474,7 @@ def test_relative_path_test_recipe(conda_build_test_recipe_envvar: str):
main_build.execute(args)


def test_test_extra_dep(testing_metadata):
def test_test_extra_dep(testing_metadata: MetaData) -> None:
testing_metadata.meta["test"]["imports"] = ["imagesize"]
api.output_yaml(testing_metadata, "meta.yaml")
output = api.build(testing_metadata, notest=True, anaconda_upload=False)[0]
Expand Down
Loading