diff --git a/conan/tools/cmake/cmake.py b/conan/tools/cmake/cmake.py index 9f2a31d14de..4139447819d 100644 --- a/conan/tools/cmake/cmake.py +++ b/conan/tools/cmake/cmake.py @@ -10,7 +10,7 @@ from conans.client.tools.oss import cpu_count, args_to_string from conans.errors import ConanException from conans.model.version import Version -from conans.util.conan_v2_mode import conan_v2_behavior +from conans.util.conan_v2_mode import conan_v2_error from conans.util.files import mkdir @@ -101,9 +101,7 @@ def _build(self, build_type=None, target=None): "single-config build systems") bt = build_type or self._conanfile.settings.get_safe("build_type") - if not bt: - conan_v2_behavior("build_type setting should be defined.", - v1_behavior=self._conanfile.output.warn) + conan_v2_error("build_type setting should be defined.", not bt) if bt and self._is_multiconfiguration: build_config = "--config %s" % bt diff --git a/conans/client/api/conan_api.py b/conans/client/api/conan_api.py index d2de4e0f845..a15470633f5 100644 --- a/conans/client/api/conan_api.py +++ b/conans/client/api/conan_api.py @@ -1,5 +1,4 @@ import os -import sys import time from tqdm import tqdm @@ -10,11 +9,9 @@ from conans.client.migrations import ClientMigrator from conans.client.tools.env import environment_append from conans.client.userio import UserIO -from conans.errors import NoRemoteAvailable, ConanException +from conans.errors import NoRemoteAvailable from conans.model.version import Version from conans.paths import get_conan_user_home -from conans.util.conan_v2_mode import CONAN_V2_MODE_ENVVAR -from conans.util.env_reader import get_env from conans.util.files import exception_message_safe @@ -55,9 +52,6 @@ def __init__(self, cache_folder=None, quiet=True, user_io=None, http_requester=N # Migration system migrator = ClientMigrator(self.cache_folder, Version(client_version), self.out) migrator.migrate() - if not get_env(CONAN_V2_MODE_ENVVAR, False): - # FIXME Remove in Conan 2.0 - sys.path.append(os.path.join(self.cache_folder, "python")) @api_method def user_list(self, remote_name=None): diff --git a/conans/client/build/autotools_environment.py b/conans/client/build/autotools_environment.py index 3585aa3ee83..8f0271bb5b2 100644 --- a/conans/client/build/autotools_environment.py +++ b/conans/client/build/autotools_environment.py @@ -18,7 +18,7 @@ from conans.client.tools.win import unix_path from conans.errors import ConanException from conans.model.build_info import DEFAULT_BIN, DEFAULT_INCLUDE, DEFAULT_LIB, DEFAULT_SHARE -from conans.util.conan_v2_mode import conan_v2_behavior +from conans.util.conan_v2_mode import conan_v2_error from conans.util.files import get_abs_path @@ -49,9 +49,7 @@ def __init__(self, conanfile, win_bash=False, include_rpath_flags=False): self._build_type = conanfile.settings.get_safe("build_type") self._compiler = conanfile.settings.get_safe("compiler") - if not self._compiler: - conan_v2_behavior("compiler setting should be defined.", - v1_behavior=self._conanfile.output.warn) + conan_v2_error("compiler setting should be defined.", not self._compiler) self._compiler_version = conanfile.settings.get_safe("compiler.version") self._compiler_runtime = conanfile.settings.get_safe("compiler.runtime") @@ -235,9 +233,7 @@ def _is_flag_in_args(varname, args): def make(self, args="", make_program=None, target=None, vars=None): if not self._conanfile.should_build: return - if not self._build_type: - conan_v2_behavior("build_type setting should be defined.", - v1_behavior=self._conanfile.output.warn) + conan_v2_error("build_type setting should be defined.", not self._build_type) make_program = os.getenv("CONAN_MAKE_PROGRAM") or make_program or "make" with environment_append(vars or self.vars): str_args = args_to_string(args) diff --git a/conans/client/build/cmake.py b/conans/client/build/cmake.py index 64ba34c693f..e6000fc97fe 100644 --- a/conans/client/build/cmake.py +++ b/conans/client/build/cmake.py @@ -19,7 +19,7 @@ from conans.client.tools.oss import cpu_count, args_to_string from conans.errors import ConanException from conans.model.version import Version -from conans.util.conan_v2_mode import conan_v2_behavior +from conans.util.conan_v2_mode import conan_v2_error from conans.util.config_parser import get_bool_from_text from conans.util.files import mkdir, get_abs_path, walk, decode_text from conans.util.runners import version_runner @@ -258,9 +258,7 @@ def get_dir(folder, origin): def _run(self, command): compiler = self._settings.get_safe("compiler") - if not compiler: - conan_v2_behavior("compiler setting should be defined.", - v1_behavior=self._conanfile.output.warn) + conan_v2_error("compiler setting should be defined.", not compiler) the_os = self._settings.get_safe("os") is_clangcl = the_os == "Windows" and compiler == "clang" is_msvc = compiler == "Visual Studio" @@ -323,9 +321,7 @@ def configure(self, args=None, defs=None, source_dir=None, build_dir=None, def build(self, args=None, build_dir=None, target=None): if not self._conanfile.should_build: return - if not self._build_type: - conan_v2_behavior("build_type setting should be defined.", - v1_behavior=self._conanfile.output.warn) + conan_v2_error("build_type setting should be defined.", not self._build_type) self._build(args, build_dir, target) def _build(self, args=None, build_dir=None, target=None): diff --git a/conans/client/build/meson.py b/conans/client/build/meson.py index 4128837952b..6a8960d17f9 100644 --- a/conans/client/build/meson.py +++ b/conans/client/build/meson.py @@ -11,7 +11,7 @@ from conans.errors import ConanException from conans.model.build_info import DEFAULT_BIN, DEFAULT_INCLUDE, DEFAULT_LIB from conans.model.version import Version -from conans.util.conan_v2_mode import conan_v2_behavior +from conans.util.conan_v2_mode import conan_v2_error from conans.util.files import decode_text, get_abs_path, mkdir from conans.util.runners import version_runner @@ -32,9 +32,7 @@ def __init__(self, conanfile, backend=None, build_type=None, append_vcvars=False self._os = self._ss("os") self._compiler = self._ss("compiler") - if not self._compiler: - conan_v2_behavior("compiler setting should be defined.", - v1_behavior=self._conanfile.output.warn) + conan_v2_error("compiler setting should be defined.", not self._compiler) self._compiler_version = self._ss("compiler.version") @@ -214,9 +212,7 @@ def _run_meson_command(self, subcommand=None, args=None, build_dir=None): def build(self, args=None, build_dir=None, targets=None): if not self._conanfile.should_build: return - if not self._build_type: - conan_v2_behavior("build_type setting should be defined.", - v1_behavior=self._conanfile.output.warn) + conan_v2_error("build_type setting should be defined.", not self._build_type) self._run_ninja_targets(args=args, build_dir=build_dir, targets=targets) def install(self, args=None, build_dir=None): diff --git a/conans/client/conan_api.py b/conans/client/conan_api.py index 341181d6da0..b05725e838a 100644 --- a/conans/client/conan_api.py +++ b/conans/client/conan_api.py @@ -63,8 +63,7 @@ from conans.search.search import search_recipes from conans.tools import set_global_instances from conans.unicode import get_cwd -from conans.util.conan_v2_mode import CONAN_V2_MODE_ENVVAR -from conans.util.env_reader import get_env +from conans.util.conan_v2_mode import conan_v2_error from conans.util.files import exception_message_safe, mkdir, save_files, load, save from conans.util.log import configure_logger from conans.util.tracer import log_command, log_exception @@ -237,9 +236,9 @@ def __init__(self, cache_folder=None, output=None, user_io=None, http_requester= migrator = ClientMigrator(self.cache_folder, Version(client_version), self.out) migrator.migrate() check_required_conan_version(self.cache_folder, self.out) - if not get_env(CONAN_V2_MODE_ENVVAR, False): - # FIXME Remove in Conan 2.0 - sys.path.append(os.path.join(self.cache_folder, "python")) + python_folder = os.path.join(self.cache_folder, "python") + conan_v2_error("Using code from cache/python not allowed", os.path.isdir(python_folder)) + sys.path.append(python_folder) def create_app(self, quiet_output=None): self.app = ConanApp(self.cache_folder, self.user_io, self.http_requester, @@ -295,8 +294,8 @@ def inspect(self, path, attributes, remote_name=None): conanfile_path, _, _, ref = result conanfile = self.app.loader.load_basic(conanfile_path) conanfile.name = ref.name - conanfile.version = str(ref.version) \ - if os.environ.get(CONAN_V2_MODE_ENVVAR, False) else ref.version + # FIXME: Conan 2.0, this should be a string, not a Version object + conanfile.version = ref.version result = OrderedDict() if not attributes: diff --git a/conans/client/conanfile/configure.py b/conans/client/conanfile/configure.py index 95c46f1d5c9..922e2607440 100644 --- a/conans/client/conanfile/configure.py +++ b/conans/client/conanfile/configure.py @@ -1,7 +1,6 @@ -from conans.errors import (conanfile_exception_formatter, ConanInvalidConfiguration) +from conans.errors import conanfile_exception_formatter from conans.model.conan_file import get_env_context_manager -from conans.util.conan_v2_mode import conan_v2_behavior, CONAN_V2_MODE_ENVVAR -from conans.util.env_reader import get_env +from conans.util.conan_v2_mode import conan_v2_error from conans.util.misc import make_tuple @@ -11,9 +10,7 @@ def run_configure_method(conanfile, down_options, down_ref, ref): # Avoid extra time manipulating the sys.path for python with get_env_context_manager(conanfile, without_python=True): if hasattr(conanfile, "config"): - conan_v2_behavior("config() has been deprecated. " - "Use config_options() and configure()", - v1_behavior=conanfile.output.warn) + conan_v2_error("config() has been deprecated. Use config_options() and configure()") with conanfile_exception_formatter(str(conanfile), "config"): conanfile.config() @@ -34,8 +31,6 @@ def run_configure_method(conanfile, down_options, down_ref, ref): # Recipe provides its own name if nothing else is defined conanfile.provides = make_tuple(conanfile.provides or conanfile.name) - _validate_fpic(conanfile) - if conanfile.deprecated: from six import string_types message = "Recipe '%s' is deprecated" % conanfile.display_name @@ -43,27 +38,3 @@ def run_configure_method(conanfile, down_options, down_ref, ref): message += " in favor of '%s'" % conanfile.deprecated message += ". Please, consider changing your requirements." conanfile.output.warn(message) - - -def _validate_fpic(conanfile): - v2_mode = get_env(CONAN_V2_MODE_ENVVAR, False) - # FIXME: The toolchain() has dissapeared, but now it is integrated with generators. - # FIXME: Not sure this check should be here, this could raise before the graph is fully evaluated - toolchain = hasattr(conanfile, "toolchain") - - if not (toolchain or v2_mode): - return - fpic = conanfile.options.get_safe("fPIC") - if fpic is None: - return - os_ = conanfile.settings.get_safe("os") - if os_ and "Windows" in os_: - if v2_mode: - raise ConanInvalidConfiguration("fPIC option defined for Windows") - conanfile.output.error("fPIC option defined for Windows") - return - shared = conanfile.options.get_safe("shared") - if shared: - if v2_mode: - raise ConanInvalidConfiguration("fPIC option defined for a shared library") - conanfile.output.error("fPIC option defined for a shared library") diff --git a/conans/client/conf/__init__.py b/conans/client/conf/__init__.py index bb31ba1b41c..884663c1d69 100644 --- a/conans/client/conf/__init__.py +++ b/conans/client/conf/__init__.py @@ -8,7 +8,6 @@ from conans.errors import ConanException from conans.model.env_info import unquote from conans.paths import DEFAULT_PROFILE_NAME, conan_expand_user, CACERT_FILE -from conans.util.conan_v2_mode import CONAN_V2_MODE_ENVVAR from conans.util.dates import timedelta_from_text from conans.util.env_reader import get_env from conans.util.files import load @@ -128,15 +127,13 @@ build_type: [None, Debug, Release, RelWithDebInfo, MinSizeRel] - {% if not conan_v2 %} + cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17, 20, gnu20] # Deprecated, use compiler.cppstd - {% endif %} """)) -def get_default_settings_yml(force_v1=False): - conan_v2 = not force_v1 and os.environ.get(CONAN_V2_MODE_ENVVAR, False) - return _t_default_settings_yml.render(conan_v2=conan_v2) +def get_default_settings_yml(): + return _t_default_settings_yml.render() _t_default_client_conf = Template(textwrap.dedent(""" @@ -193,9 +190,6 @@ def get_default_settings_yml(force_v1=False): # cacert_path # environment CONAN_CACERT_PATH # scm_to_conandata # environment CONAN_SCM_TO_CONANDATA - {% if conan_v2 %} - revisions_enabled = 1 - {% endif %} # config_install_interval = 1h # required_conan_version = >=1.26 @@ -221,18 +215,14 @@ def get_default_settings_yml(force_v1=False): # You can skip the proxy for the matching (fnmatch) urls (comma-separated) # no_proxy_match = *bintray.com*, https://myserver.* - {% if not conan_v2 %}{# no hooks by default in Conan v2 #} [hooks] # environment CONAN_HOOKS attribute_checker - {% endif %} - # Default settings now declared in the default profile """)) def get_default_client_conf(force_v1=False): - conan_v2 = not force_v1 and os.environ.get(CONAN_V2_MODE_ENVVAR, False) - return _t_default_client_conf.render(conan_v2=conan_v2, default_profile=DEFAULT_PROFILE_NAME) + return _t_default_client_conf.render(default_profile=DEFAULT_PROFILE_NAME) class ConanClientConfigParser(ConfigParser, object): @@ -444,7 +434,7 @@ def revisions_enabled(self): revisions_enabled = self.get_item("general.revisions_enabled") return revisions_enabled.lower() in ("1", "true") except ConanException: - return True if os.environ.get(CONAN_V2_MODE_ENVVAR, False) else False + return False @property def parallel_download(self): @@ -474,7 +464,7 @@ def scm_to_conandata(self): scm_to_conandata = self.get_item("general.scm_to_conandata") return scm_to_conandata.lower() in ("1", "true") except ConanException: - return True if os.environ.get(CONAN_V2_MODE_ENVVAR, False) else False + return False @property def default_package_id_mode(self): diff --git a/conans/client/graph/python_requires.py b/conans/client/graph/python_requires.py index 904f4fbbef2..8f2576200df 100644 --- a/conans/client/graph/python_requires.py +++ b/conans/client/graph/python_requires.py @@ -7,8 +7,7 @@ from conans.errors import ConanException, NotFoundException from conans.model.ref import ConanFileReference from conans.model.requires import Requirement -from conans.util.conan_v2_mode import CONAN_V2_MODE_ENVVAR -from conans.util.conan_v2_mode import conan_v2_behavior +from conans.util.conan_v2_mode import conan_v2_error PythonRequire = namedtuple("PythonRequire", ["ref", "module", "conanfile", "exports_folder", "exports_sources_folder"]) @@ -135,8 +134,8 @@ def _load_pyreq_conanfile(self, loader, lock_python_requires, ref): conanfile, module = loader.load_basic_module(path, lock_python_requires, user=new_ref.user, channel=new_ref.channel) conanfile.name = new_ref.name - conanfile.version = str(new_ref.version) \ - if os.environ.get(CONAN_V2_MODE_ENVVAR, False) else new_ref.version + # FIXME Conan 2.0 version should be a string, not a Version object + conanfile.version = new_ref.version if getattr(conanfile, "alias", None): ref = ConanFileReference.loads(conanfile.alias) @@ -203,7 +202,7 @@ def _look_for_require(self, reference): return python_require def __call__(self, reference): - conan_v2_behavior("Old syntax for python_requires is deprecated") + conan_v2_error("Old syntax for python_requires is deprecated") if not self.valid: raise ConanException("Invalid use of python_requires(%s)" % reference) try: diff --git a/conans/client/installer.py b/conans/client/installer.py index 0c2681b168e..3adadb812ed 100644 --- a/conans/client/installer.py +++ b/conans/client/installer.py @@ -31,7 +31,6 @@ from conans.model.user_info import DepsUserInfo from conans.model.user_info import UserInfo from conans.paths import BUILD_INFO, CONANINFO, RUN_LOG_NAME -from conans.util.conan_v2_mode import CONAN_V2_MODE_ENVVAR from conans.util.env_reader import get_env from conans.util.files import clean_dirty, is_dirty, make_read_only, mkdir, rmdir, save, set_dirty from conans.util.log import logger @@ -613,9 +612,9 @@ def _call_package_info(self, conanfile, package_folder, ref): conanfile.cpp_info.public_deps = public_deps # Once the node is build, execute package info, so it has access to the # package folder and artifacts - conan_v2 = get_env(CONAN_V2_MODE_ENVVAR, False) # Minimal pythonpath, not the whole context, make it 50% slower - with pythonpath(conanfile) if not conan_v2 else no_op(): + # FIXME Conan 2.0, Remove old ways of reusing python code + with pythonpath(conanfile): with tools.chdir(package_folder): with conanfile_exception_formatter(str(conanfile), "package_info"): conanfile.package_folder = package_folder diff --git a/conans/client/loader.py b/conans/client/loader.py index 64cfdebf85e..9851fb6e42e 100644 --- a/conans/client/loader.py +++ b/conans/client/loader.py @@ -18,7 +18,6 @@ from conans.model.ref import ConanFileReference from conans.model.settings import Settings from conans.paths import DATA_YML -from conans.util.conan_v2_mode import CONAN_V2_MODE_ENVVAR from conans.util.files import load @@ -161,8 +160,7 @@ def load_export(self, conanfile_path, name, version, user, channel, lock_python_ if not conanfile.version: raise ConanException("conanfile didn't specify version") - if os.environ.get(CONAN_V2_MODE_ENVVAR, False): - conanfile.version = str(conanfile.version) + # FIXME Conan 2.0, conanfile.version should be a string, not a version object ref = ConanFileReference(conanfile.name, conanfile.version, user, channel) conanfile.display_name = str(ref) @@ -236,8 +234,8 @@ def load_conanfile(self, conanfile_path, profile, ref, lock_python_requires=None raise ConanException("%s: Cannot load recipe.\n%s" % (str(ref), str(e))) conanfile.name = ref.name - conanfile.version = str(ref.version) \ - if os.environ.get(CONAN_V2_MODE_ENVVAR, False) else ref.version + # FIXME Conan 2.0, version should be a string not a Version object + conanfile.version = ref.version if profile.dev_reference and profile.dev_reference == ref: conanfile.develop = True diff --git a/conans/client/printer.py b/conans/client/printer.py index 06c0bf638d7..972784b5ff1 100644 --- a/conans/client/printer.py +++ b/conans/client/printer.py @@ -4,7 +4,7 @@ from conans.client.output import Color from conans.model.options import OptionsValues from conans.model.ref import ConanFileReference -from conans.util.conan_v2_mode import conan_v2_behavior +from conans.util.conan_v2_mode import conan_v2_error class Printer(object): @@ -24,8 +24,7 @@ def __init__(self, out): def print_inspect(self, inspect, raw=False): for k, v in inspect.items(): if k == "default_options": - if not isinstance(v, dict): - conan_v2_behavior("Declare 'default_options' as a dictionary") + conan_v2_error("Declare 'default_options' as a dictionary", not isinstance(v, dict)) if isinstance(v, str): v = OptionsValues.loads(v) diff --git a/conans/client/settings_preprocessor.py b/conans/client/settings_preprocessor.py index 8730b765959..9e71e8f91a7 100644 --- a/conans/client/settings_preprocessor.py +++ b/conans/client/settings_preprocessor.py @@ -1,6 +1,6 @@ from conans.client.build.cppstd_flags import cppstd_flag from conans.errors import ConanException -from conans.util.conan_v2_mode import conan_v2_behavior +from conans.util.conan_v2_mode import conan_v2_error from conans.util.log import logger @@ -23,8 +23,7 @@ def _check_cppstd(settings): raise ConanException("Do not use settings 'compiler.cppstd' together with 'cppstd'." " Use only the former one.") - if cppstd: - conan_v2_behavior("Setting 'cppstd' is deprecated in favor of 'compiler.cppstd'") + conan_v2_error("Setting 'cppstd' is deprecated in favor of 'compiler.cppstd'", cppstd) if compiler not in ("gcc", "clang", "apple-clang", "Visual Studio"): return diff --git a/conans/client/tools/win.py b/conans/client/tools/win.py index 8852245ee0b..48f5343a8a4 100644 --- a/conans/client/tools/win.py +++ b/conans/client/tools/win.py @@ -13,7 +13,7 @@ from conans.errors import ConanException from conans.model.version import Version from conans.unicode import get_cwd -from conans.util.conan_v2_mode import conan_v2_behavior +from conans.util.conan_v2_mode import conan_v2_error from conans.util.env_reader import get_env from conans.util.fallbacks import default_output from conans.util.files import mkdir_tmp, save @@ -163,7 +163,7 @@ def msvc_build_command(settings, sln_path, targets=None, upgrade_project=True, b output=None): """ Do both: set the environment variables and call the .sln build """ - conan_v2_behavior("'tools.msvc_build_command' is deprecated, use 'MSBuild()' helper instead") + conan_v2_error("'tools.msvc_build_command' is deprecated, use 'MSBuild()' helper instead") vcvars_cmd = vcvars_command(settings, force=force_vcvars, output=output) build = build_sln_command(settings, sln_path, targets, upgrade_project, build_type, arch, parallel, toolset=toolset, platforms=platforms, output=output) @@ -180,7 +180,7 @@ def build_sln_command(settings, sln_path, targets=None, upgrade_project=True, bu command = "%s && %s" % (tools.vcvars_command(self.settings), build_command) self.run(command) """ - conan_v2_behavior("'tools.build_sln_command' is deprecated, use 'MSBuild()' helper instead") + conan_v2_error("'tools.build_sln_command' is deprecated, use 'MSBuild()' helper instead") from conans.client.build.msbuild import MSBuildHelper tmp = MSBuildHelper(settings) output = default_output(output, fn_name='conans.client.tools.win.build_sln_command') diff --git a/conans/model/build_info.py b/conans/model/build_info.py index 7cf2b58fb74..50284ca1757 100644 --- a/conans/model/build_info.py +++ b/conans/model/build_info.py @@ -3,7 +3,7 @@ from copy import copy from conans.errors import ConanException -from conans.util.conan_v2_mode import conan_v2_behavior +from conans.util.conan_v2_mode import conan_v2_error DEFAULT_INCLUDE = "include" DEFAULT_LIB = "lib" @@ -54,13 +54,13 @@ def _append(self, item): self["cmake_find_package_multi"].append(item) def append(self, item): - conan_v2_behavior("Use 'self.cpp_info.build_modules[\"\"].append(\"{item}\")' " - 'instead'.format(item=item)) + conan_v2_error("Use 'self.cpp_info.build_modules[\"\"].append(\"{item}\")' " + 'instead'.format(item=item)) self._append(item) def extend(self, items): - conan_v2_behavior("Use 'self.cpp_info.build_modules[\"\"].extend({items})' " - "instead".format(items=items)) + conan_v2_error("Use 'self.cpp_info.build_modules[\"\"].extend({items})' " + "instead".format(items=items)) for item in items: self._append(item) @@ -151,8 +151,8 @@ def _filter_paths(self, paths): def build_modules_paths(self): if self._build_modules_paths is None: if isinstance(self.build_modules, list): # FIXME: This should be just a plain dict - conan_v2_behavior("Use 'self.cpp_info.build_modules[\"\"] = " - "{the_list}' instead".format(the_list=self.build_modules)) + conan_v2_error("Use 'self.cpp_info.build_modules[\"\"] = " + "{the_list}' instead".format(the_list=self.build_modules)) self.build_modules = BuildModulesDict.from_list(self.build_modules) tmp = dict_to_abs_paths(BuildModulesDict(self.build_modules), self.rootpath) self._build_modules_paths = tmp @@ -202,7 +202,7 @@ def framework_paths(self): @property def name(self): - conan_v2_behavior("Use 'get_name(generator)' instead") + conan_v2_error("Use 'get_name(generator)' instead") return self._name @name.setter @@ -220,11 +220,11 @@ def get_filename(self, generator): # Compatibility for 'cppflags' (old style property to allow decoration) def get_cppflags(self): - conan_v2_behavior("'cpp_info.cppflags' is deprecated, use 'cxxflags' instead") + conan_v2_error("'cpp_info.cppflags' is deprecated, use 'cxxflags' instead") return self.cxxflags def set_cppflags(self, value): - conan_v2_behavior("'cpp_info.cppflags' is deprecated, use 'cxxflags' instead") + conan_v2_error("'cpp_info.cppflags' is deprecated, use 'cxxflags' instead") self.cxxflags = value cppflags = property(get_cppflags, set_cppflags) @@ -279,10 +279,10 @@ def get_name(self, generator): if generator == PkgConfigGenerator.name: fallback = self._name.lower() if self._name != self._ref_name else self._ref_name if PkgConfigGenerator.name not in self.names and self._name != self._name.lower(): - conan_v2_behavior("Generated file and name for {gen} generator will change in" - " Conan v2 to '{name}'. Use 'self.cpp_info.names[\"{gen}\"]" - " = \"{fallback}\"' in your recipe to continue using current name." - .format(gen=PkgConfigGenerator.name, name=name, fallback=fallback)) + conan_v2_error("Generated file and name for {gen} generator will change in" + " Conan v2 to '{name}'. Use 'self.cpp_info.names[\"{gen}\"]" + " = \"{fallback}\"' in your recipe to continue using current name." + .format(gen=PkgConfigGenerator.name, name=name, fallback=fallback)) name = self.names.get(generator, fallback) return name diff --git a/conans/model/conan_file.py b/conans/model/conan_file.py index 67b46010768..4358621a9f0 100644 --- a/conans/model/conan_file.py +++ b/conans/model/conan_file.py @@ -16,9 +16,7 @@ from conans.model.requires import Requirements from conans.model.user_info import DepsUserInfo from conans.paths import RUN_LOG_NAME -from conans.util.conan_v2_mode import CONAN_V2_MODE_ENVVAR -from conans.util.conan_v2_mode import conan_v2_behavior -from conans.util.env_reader import get_env +from conans.util.conan_v2_mode import conan_v2_error def create_options(conanfile): @@ -31,10 +29,10 @@ def create_options(conanfile): if isinstance(default_options, dict): default_values = OptionsValues(default_options) elif isinstance(default_options, (list, tuple)): - conan_v2_behavior("Declare 'default_options' as a dictionary") + conan_v2_error("Declare 'default_options' as a dictionary") default_values = OptionsValues(default_options) elif isinstance(default_options, six.string_types): - conan_v2_behavior("Declare 'default_options' as a dictionary") + conan_v2_error("Declare 'default_options' as a dictionary") default_values = OptionsValues.loads(default_options) else: raise ConanException("Please define your default_options as list, " @@ -76,11 +74,9 @@ def create_settings(conanfile, settings): @contextmanager def _env_and_python(conanfile): with environment_append(conanfile.env): - if get_env(CONAN_V2_MODE_ENVVAR, False): + # FIXME Conan 2.0, Remove old ways of reusing python code + with pythonpath(conanfile): yield - else: - with pythonpath(conanfile): - yield def get_env_context_manager(conanfile, without_python=False): @@ -158,9 +154,8 @@ def initialize(self, settings, env): self.requires = create_requirements(self) self.settings = create_settings(self, settings) - if 'cppstd' in self.settings.fields: - conan_v2_behavior("Setting 'cppstd' is deprecated in favor of 'compiler.cppstd'," - " please update your recipe.", v1_behavior=self.output.warn) + conan_v2_error("Setting 'cppstd' is deprecated in favor of 'compiler.cppstd'," + " please update your recipe.", 'cppstd' in self.settings.fields) # needed variables to pack the project self.cpp_info = None # Will be initialized at processing time @@ -231,8 +226,7 @@ def env(self): def channel(self): if not self._conan_channel: _env_channel = os.getenv("CONAN_CHANNEL") - if _env_channel: - conan_v2_behavior("Environment variable 'CONAN_CHANNEL' is deprecated") + conan_v2_error("Environment variable 'CONAN_CHANNEL' is deprecated", _env_channel) self._conan_channel = _env_channel or self.default_channel if not self._conan_channel: raise ConanException("channel not defined, but self.channel is used in conanfile") @@ -242,16 +236,14 @@ def channel(self): def user(self): if not self._conan_user: _env_username = os.getenv("CONAN_USERNAME") - if _env_username: - conan_v2_behavior("Environment variable 'CONAN_USERNAME' is deprecated") + conan_v2_error("Environment variable 'CONAN_USERNAME' is deprecated", _env_username) self._conan_user = _env_username or self.default_user if not self._conan_user: raise ConanException("user not defined, but self.user is used in conanfile") return self._conan_user def collect_libs(self, folder=None): - conan_v2_behavior("'self.collect_libs' is deprecated, use 'tools.collect_libs(self)' instead", - v1_behavior=self.output.warn) + conan_v2_error("'self.collect_libs' is deprecated, use 'tools.collect_libs(self)' instead") return tools.collect_libs(self, folder=folder) @property @@ -313,8 +305,8 @@ def _run(): return tools.run_in_windows_bash(self, bashcmd=command, cwd=cwd, subsystem=subsystem, msys_mingw=msys_mingw, with_login=with_login) if run_environment: - # When using_build_profile the required environment is already applied through 'conanfile.env' - # in the contextmanager 'get_env_context_manager' + # When using_build_profile the required environment is already applied through + # 'conanfile.env' in the contextmanager 'get_env_context_manager' with tools.run_environment(self) if not self._conan_using_build_profile else no_op(): if OSInfo().is_macos and isinstance(command, string_types): # Security policy on macOS clears this variable when executing /bin/sh. To diff --git a/conans/test/functional/build_helpers/cmake_flags_test.py b/conans/test/functional/build_helpers/cmake_flags_test.py index 73124bf9c25..8dfb849eb29 100644 --- a/conans/test/functional/build_helpers/cmake_flags_test.py +++ b/conans/test/functional/build_helpers/cmake_flags_test.py @@ -10,7 +10,6 @@ from conans.client.build.cmake import CMakeBuildHelper from conans.model.version import Version -from conans.test.utils.deprecation import catch_deprecation_warning from conans.test.utils.tools import TestClient conanfile_py = """ @@ -359,22 +358,19 @@ def build(self): """}) if platform.system() != "Windows": - with catch_deprecation_warning(self): - client.run("install . --install-folder=build -s cppstd=gnu98") + client.run("install . --install-folder=build -s cppstd=gnu98") client.run("build . --build-folder=build", assert_error=True) self.assertIn("Error in build()", client.out) # Now specify c++14 - with catch_deprecation_warning(self): - client.run("install . --install-folder=build -s cppstd=gnu14") + client.run("install . --install-folder=build -s cppstd=gnu14") client.run("build . --build-folder=build") self.assertIn("CPP STANDARD: 14 WITH EXTENSIONS ON", client.out) libname = "libmylib.a" if platform.system() != "Windows" else "mylib.lib" libpath = os.path.join(client.current_folder, "build", "lib", libname) self.assertTrue(os.path.exists(libpath)) - with catch_deprecation_warning(self): - client.run("install . --install-folder=build -s cppstd=14") + client.run("install . --install-folder=build -s cppstd=14") client.run("build . --build-folder=build") self.assertIn("CPP STANDARD: 14 WITH EXTENSIONS OFF", client.out) self.assertNotIn("Conan setting CXX_FLAGS flags", client.out) @@ -415,17 +411,15 @@ def conan_set_std_branch(): cmake_version = CMakeBuildHelper.get_version() return cmake_version < Version("3.12") - with catch_deprecation_warning(self): - client.run("create . user/channel -s cppstd=gnu20 -s compiler=gcc " - "-s compiler.version=8 -s compiler.libcxx=libstdc++11") + client.run("create . user/channel -s cppstd=gnu20 -s compiler=gcc " + "-s compiler.version=8 -s compiler.libcxx=libstdc++11") if conan_set_std_branch(): self.assertIn("Conan setting CXX_FLAGS flags: -std=gnu++2a", client.out) else: self.assertIn("Conan setting CPP STANDARD: 20 WITH EXTENSIONS ON", client.out) - with catch_deprecation_warning(self): - client.run("create . user/channel -s cppstd=20 -s compiler=gcc -s compiler.version=8 " - "-s compiler.libcxx=libstdc++11") + client.run("create . user/channel -s cppstd=20 -s compiler=gcc -s compiler.version=8 " + "-s compiler.libcxx=libstdc++11") if conan_set_std_branch(): self.assertIn("Conan setting CXX_FLAGS flags: -std=c++2a", client.out) else: diff --git a/conans/test/functional/build_helpers/msbuild_test.py b/conans/test/functional/build_helpers/msbuild_test.py index 47856d7a886..1d7f884d3ac 100644 --- a/conans/test/functional/build_helpers/msbuild_test.py +++ b/conans/test/functional/build_helpers/msbuild_test.py @@ -12,7 +12,6 @@ from conans.client.tools.files import replace_in_file from conans.model.ref import PackageReference from conans.paths import CONANFILE -from conans.test.utils.deprecation import catch_deprecation_warning from conans.test.utils.tools import TestClient from conans.test.assets.visual_project_files import get_vs_project_files from conans.util.files import load @@ -54,12 +53,11 @@ def package(self): files[CONANFILE] = conan_build_vs client.save(files) - with catch_deprecation_warning(self): - client.run('create . Hello/1.2.1@lasote/stable -s cppstd=11 -s ' - 'compiler="Visual Studio" -s compiler.version=14', assert_error=True) - with catch_deprecation_warning(self, n=2): - client.run('create . Hello/1.2.1@lasote/stable -s cppstd=17 ' - '-s compiler="Visual Studio" -s compiler.version=14') + client.run('create . Hello/1.2.1@lasote/stable -s cppstd=11 -s ' + 'compiler="Visual Studio" -s compiler.version=14', assert_error=True) + + client.run('create . Hello/1.2.1@lasote/stable -s cppstd=17 ' + '-s compiler="Visual Studio" -s compiler.version=14') self.assertIn("Packaged 1 '.exe' file: MyProject.exe", client.out) files = get_vs_project_files() @@ -387,7 +385,8 @@ def __call__(self, *args, **kwargs): self.assertIn('/p:PlatformToolset="mytoolset"', runner.commands[0]) @pytest.mark.tool_visual_studio - @pytest.mark.skipif(platform.system() != "Windows", reason="Requires Visual Studio installation path") + @pytest.mark.skipif(platform.system() != "Windows", + reason="Requires Visual Studio installation path") def test_arch_override(self): settings = MockSettings({"build_type": "Release", "compiler": "Visual Studio", diff --git a/conans/test/functional/conan_v2/test_default_config.py b/conans/test/functional/conan_v2/test_default_config.py index cc129395b46..35cba76b6d3 100644 --- a/conans/test/functional/conan_v2/test_default_config.py +++ b/conans/test/functional/conan_v2/test_default_config.py @@ -1,5 +1,4 @@ import platform -import unittest import pytest @@ -7,17 +6,6 @@ class DefaultConfigTestCase(ConanV2ModeTestCase): - def test_revisions_enabled(self): - t = self.get_client() - self.assertEqual(t.cache.config.revisions_enabled, True) - t.run('config get general.revisions_enabled') - self.assertEqual(str(t.out).strip(), "1") - - def test_scm_to_conandata(self): - t = self.get_client() - self.assertEqual(t.cache.config.scm_to_conandata, True) - # t.run('config get general.scm_to_conandata') # FIXME: This should return a value - # self.assertEqual(str(t.out).strip(), "1") @pytest.mark.xfail def test_package_id_mode(self): diff --git a/conans/test/functional/settings/cppstd/compiler_cppstd_test.py b/conans/test/functional/settings/cppstd/compiler_cppstd_test.py index d95bd7fdb9e..81671063ac3 100644 --- a/conans/test/functional/settings/cppstd/compiler_cppstd_test.py +++ b/conans/test/functional/settings/cppstd/compiler_cppstd_test.py @@ -8,7 +8,6 @@ from parameterized.parameterized import parameterized_class from conans.client.tools import environment_append, save -from conans.test.utils.deprecation import catch_deprecation_warning from conans.test.utils.test_files import temp_folder from conans.test.utils.tools import TestClient @@ -64,11 +63,10 @@ def test_value_different_with_scoped_setting(self): def test_value_different_with_general_setting(self): deprecation_number = 1 if self.recipe_cppstd else 0 - with catch_deprecation_warning(self, n=deprecation_number): - self.t.run("create . hh/0.1@user/channel" - " -s cppstd=17" - " -s hh:compiler=gcc" - " -s hh:compiler.cppstd=14", assert_error=True) + self.t.run("create . hh/0.1@user/channel" + " -s cppstd=17" + " -s hh:compiler=gcc" + " -s hh:compiler.cppstd=14", assert_error=True) self.assertIn("ERROR: Error in resulting settings for package 'hh': Do not use settings" " 'compiler.cppstd' together with 'cppstd'", self.t.out) @@ -82,12 +80,11 @@ class Lib(ConanFile): t = TestClient(cache_folder=temp_folder()) t.save({'conanfile.py': conanfile}) - with catch_deprecation_warning(self): - # No mismatch, because settings for this conanfile does not include `compiler` - t.run("create . hh/0.1@user/channel" - " -s cppstd=17" - " -s hh:compiler=gcc" - " -s hh:compiler.cppstd=14", assert_error=True) + # No mismatch, because settings for this conanfile does not include `compiler` + t.run("create . hh/0.1@user/channel" + " -s cppstd=17" + " -s hh:compiler=gcc" + " -s hh:compiler.cppstd=14", assert_error=True) self.assertIn("ERROR: Error in resulting settings for package 'hh': Do not use settings" " 'compiler.cppstd' together with 'cppstd'", t.out) @@ -104,12 +101,11 @@ def configure(self): t = TestClient(cache_folder=temp_folder()) t.save({'conanfile.py': conanfile}, clean_first=True) - with catch_deprecation_warning(self): - # No mismatch, because settings for this conanfile does not include `compiler` - t.run("create . hh/0.1@user/channel" - " -s cppstd=17" - " -s hh:compiler=gcc" - " -s hh:compiler.cppstd=14", assert_error=True) + # No mismatch, because settings for this conanfile does not include `compiler` + t.run("create . hh/0.1@user/channel" + " -s cppstd=17" + " -s hh:compiler=gcc" + " -s hh:compiler.cppstd=14", assert_error=True) self.assertIn("ERROR: Error in resulting settings for package 'hh': Do not use settings" " 'compiler.cppstd' together with 'cppstd'", t.out) @@ -132,14 +128,8 @@ def setUp(self): self.t = TestClient() self.t.save({'conanfile.py': self.conanfile}) - def test_user_notice(self): - self.t.run("info .") - self.assertIn("WARN: Setting 'cppstd' is deprecated in favor of 'compiler.cppstd'," - " please update your recipe.", self.t.out) - def test_only_cppstd(self): - with catch_deprecation_warning(self): - self.t.run("info . -s cppstd=14") + self.t.run("info . -s cppstd=14") self.assertNotIn(">>> compiler.cppstd: 14", self.t.out) self.assertIn(">>> cppstd: 14", self.t.out) self.assertIn(">>> compiler.cppstd: None", self.t.out) diff --git a/conans/test/functional/util/tools_test.py b/conans/test/functional/util/tools_test.py index 23c86b5f46e..6565a1f3d2e 100644 --- a/conans/test/functional/util/tools_test.py +++ b/conans/test/functional/util/tools_test.py @@ -4,7 +4,6 @@ import platform import subprocess import unittest -import warnings import pytest import six @@ -26,7 +25,8 @@ class FunctionalToolsTest(unittest.TestCase): output = TestBufferConanOutput() @pytest.mark.tool_file # Needs the "file" command, not by default in linux - @pytest.mark.skipif(which("file") is None, reason="Needs the 'file' command, not by default in linux") + @pytest.mark.skipif(which("file") is None, + reason="Needs the 'file' command, not by default in linux") def test_unix_to_dos_unit(self): def save_file(contents): tmp = temp_folder() @@ -86,38 +86,23 @@ def test_msvc_build_command(self): settings.compiler.version = "14" # test build_type and arch override, for multi-config packages - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter("always") - cmd = tools.msvc_build_command(settings, "project.sln", build_type="Debug", - arch="x86", output=self.output) - self.assertEqual(len(w), 3) - self.assertTrue(issubclass(w[0].category, DeprecationWarning)) + cmd = tools.msvc_build_command(settings, "project.sln", build_type="Debug", + arch="x86", output=self.output) self.assertIn('msbuild "project.sln" /p:Configuration="Debug" ' '/p:UseEnv=false /p:Platform="x86"', cmd) self.assertIn('vcvarsall.bat', cmd) # tests errors if args not defined with six.assertRaisesRegex(self, ConanException, "Cannot build_sln_command"): - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter("always") - tools.msvc_build_command(settings, "project.sln", output=self.output) - self.assertEqual(len(w), 2) - self.assertTrue(issubclass(w[0].category, DeprecationWarning)) + tools.msvc_build_command(settings, "project.sln", output=self.output) + settings.arch = "x86" with six.assertRaisesRegex(self, ConanException, "Cannot build_sln_command"): - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter("always") - tools.msvc_build_command(settings, "project.sln", output=self.output) - self.assertEqual(len(w), 2) - self.assertTrue(issubclass(w[0].category, DeprecationWarning)) + tools.msvc_build_command(settings, "project.sln", output=self.output) # successful definition via settings settings.build_type = "Debug" - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter("always") - cmd = tools.msvc_build_command(settings, "project.sln", output=self.output) - self.assertEqual(len(w), 3) - self.assertTrue(issubclass(w[0].category, DeprecationWarning)) + cmd = tools.msvc_build_command(settings, "project.sln", output=self.output) self.assertIn('msbuild "project.sln" /p:Configuration="Debug" ' '/p:UseEnv=false /p:Platform="x86"', cmd) self.assertIn('vcvarsall.bat', cmd) diff --git a/conans/test/integration/conan_v2/conanfile/test_version_type.py b/conans/test/integration/conan_v2/conanfile/test_version_type.py deleted file mode 100644 index 50eec66e299..00000000000 --- a/conans/test/integration/conan_v2/conanfile/test_version_type.py +++ /dev/null @@ -1,119 +0,0 @@ -import textwrap - -from jinja2 import Template - -from conans.test.utils.conan_v2_tests import ConanV2ModeTestCase - - -class VersionTypeTestCase(ConanV2ModeTestCase): - - conanfile_tpl = Template(textwrap.dedent(""" - import six - from conans import ConanFile - from conans.errors import ConanException - from conans.model.version import Version - - class Recipe(ConanFile): - name = "name" - {% if not use_set_version and version %}version = {{ version }}{% endif %} - - {% if use_set_version %} - def set_version(self): - self.version = {{ version }} - {% endif %} - - def _checks(self, function_name): - version_is_str = isinstance(self.version, six.string_types) - if version_is_str: - self.output.info("> {}: version ok".format(function_name)) - else: - v_type = type(self.version) - raise ConanException("> {}: version is type '{}'".format(function_name, v_type)) - - if isinstance(self.version, Version): - raise ConanException("> {}: version is type 'Version'".format(function_name)) - - # Functions ordered according to documentation - - def source(self): - self._checks("source") - - def build(self): - self._checks("build") - - def package(self): - self._checks("package") - - def package_info(self): - self._checks("package_info") - - def configure(self): - self._checks("configure") - - def config_options(self): - self._checks("config_options") - - def requirements(self): - self._checks("requirements") - - def build_requirements(self): - self._checks("build_requirements") - - def system_requirements(self): - self._checks("system_requirements") - - def imports(self): - self._checks("imports") - - def package_id(self): - self._checks("package_id") - - def build_id(self): - self._checks("build_id") - - def deploy(self): - self._checks("deploy") - - def init(self): - #self._checks("init") - pass - """)) - - def _run_testing(self, conanfile, ref_create=None, ref_install=None): - t = self.get_client() - t.save({"conanfile.py": conanfile}) - ref_create = ref_create or "" - t.run("create . {}".format(ref_create)) - - for func in ("source", "build", "package", "package_info", "configure", "config_options", - "requirements", "build_requirements", "system_requirements", "imports", - "package_id", "build_id", ): # TODO: `init()` not here - self.assertIn("> {}: version ok".format(func), t.out) - - ref_install = ref_install or ref_create - t.run("install {} -g deploy".format(ref_install)) - self.assertIn("> deploy: version ok", t.out) - - def test_cli(self): - conanfile = self.conanfile_tpl.render() - self._run_testing(conanfile, ref_create="name/42@") - - def test_recipe_attribute(self): - conanfile = self.conanfile_tpl.render(version='"42"') - self._run_testing(conanfile, ref_create="name/42@") - - conanfile = self.conanfile_tpl.render(version='42') - self._run_testing(conanfile, ref_create=None, ref_install="name/42@") - - conanfile = self.conanfile_tpl.render(version='42.23') - self._run_testing(conanfile, ref_create=None, ref_install="name/42.23@") - - def test_set_functions(self): - conanfile = self.conanfile_tpl.render(version='"42"', use_set_version=True) - self._run_testing(conanfile, ref_create="name/42@") - - conanfile = self.conanfile_tpl.render(version='42', use_set_version=True) - self._run_testing(conanfile, ref_create=None, ref_install="name/42@") - - conanfile = self.conanfile_tpl.render(version='42.23', use_set_version=True) - self._run_testing(conanfile, ref_create=None, ref_install="name/42.23@") diff --git a/conans/test/integration/conan_v2/settings_model/test_cppstd.py b/conans/test/integration/conan_v2/settings_model/test_cppstd.py index c91bfa0af7e..cf64d7cd0ad 100644 --- a/conans/test/integration/conan_v2/settings_model/test_cppstd.py +++ b/conans/test/integration/conan_v2/settings_model/test_cppstd.py @@ -1,11 +1,10 @@ import textwrap import six -from parameterized import parameterized from conans.client import settings_preprocessor from conans.client.conf import get_default_settings_yml -from conans.errors import ConanV2Exception, ConanException +from conans.errors import ConanV2Exception from conans.model.settings import Settings from conans.test.utils.conan_v2_tests import ConanV2ModeTestCase @@ -15,42 +14,30 @@ class SettingsCppstdTestCase(ConanV2ModeTestCase): and will fail if used in any recipe or command line """ - @parameterized.expand([(True,), (False,)]) - def test_recipe_invalid(self, use_settings_v1): + def test_recipe_invalid(self): # If a recipe declares 'settings = "os", ..., "cppstd", it fails conanfile = textwrap.dedent(""" from conans import ConanFile - + class Recipe(ConanFile): settings = "os", "cppstd" """) - t = self.get_client(use_settings_v1=use_settings_v1) + t = self.get_client() t.save({'conanfile.py': conanfile}) t.run("create . name/version@", assert_error=True) - if use_settings_v1: - self.assertIn("Conan v2 incompatible: Setting 'cppstd' is deprecated", t.out) - else: - self.assertIn("ERROR: The recipe is constraining settings. 'settings.cppstd' doesn't exist", t.out) - @parameterized.expand([(True,), (False,)]) - def test_settings_model(self, use_settings_v1): + self.assertIn("Conan v2 incompatible: Setting 'cppstd' is deprecated", t.out) + + def test_settings_model(self): # First level setting 'cppstd' is no longer supported - settings = Settings.loads(get_default_settings_yml(force_v1=use_settings_v1)) - if use_settings_v1: - settings.cppstd = "11" - with six.assertRaisesRegex(self, ConanV2Exception, "Setting 'cppstd' is deprecated"): - settings_preprocessor.preprocess(settings=settings) - else: - with six.assertRaisesRegex(self, ConanException, "'settings.cppstd' doesn't exist"): - settings.cppstd = "11" + settings = Settings.loads(get_default_settings_yml()) + settings.cppstd = "11" + with six.assertRaisesRegex(self, ConanV2Exception, "Setting 'cppstd' is deprecated"): settings_preprocessor.preprocess(settings=settings) - @parameterized.expand([(True,), (False,)]) - def test_search(self, use_settings_v1): + + def test_search(self): # First level setting 'cppstd' is no longer supported - t = self.get_client(use_settings_v1=use_settings_v1) + t = self.get_client() t.run("info name/version@ -s cppstd=14", assert_error=True) - if use_settings_v1: - self.assertIn("Conan v2 incompatible: Setting 'cppstd' is deprecated", t.out) - else: - self.assertIn("ERROR: 'settings.cppstd' doesn't exist", t.out) + self.assertIn("Conan v2 incompatible: Setting 'cppstd' is deprecated", t.out) diff --git a/conans/test/integration/conan_v2/test_pythonpath.py b/conans/test/integration/conan_v2/test_pythonpath.py index c53dd5b884c..91c550eccb7 100644 --- a/conans/test/integration/conan_v2/test_pythonpath.py +++ b/conans/test/integration/conan_v2/test_pythonpath.py @@ -43,21 +43,3 @@ def package_info(self): import tooling tooling.bar(self.output) """) - - def test_deprecate_pythonpath(self): - conantool_ref = ConanFileReference.loads("conantool/1.0@conan/stable") - # Create a package that exports python code - t = self.get_client() - t.save({'conanfile.py': self.conanfile, - 'tooling.py': self.tooling}) - t.run("export . conan/stable") - - # Try to reuse it - t.save({'conanfile.py': self.reuse}, clean_first=True) - t.run("create .", assert_error=True) - packages_path = t.cache.package_layout(conantool_ref).packages().replace('\\', '/') - self.assertIn("consumer/0.1: PYTHONPATH: ['{}".format(packages_path), t.out) - if six.PY2: - self.assertIn("ImportError: No module named tooling", t.out) - else: - self.assertIn("ModuleNotFoundError: No module named 'tooling'", t.out) diff --git a/conans/test/integration/package_id/package_id_requires_modes_test.py b/conans/test/integration/package_id/package_id_requires_modes_test.py index 2c632d2d2dd..152221083f4 100644 --- a/conans/test/integration/package_id/package_id_requires_modes_test.py +++ b/conans/test/integration/package_id/package_id_requires_modes_test.py @@ -7,7 +7,6 @@ from conans.model.info import ConanInfo from conans.model.ref import ConanFileReference, PackageReference from conans.paths import CONANINFO -from conans.test.utils.deprecation import catch_deprecation_warning from conans.test.utils.tools import TestClient, GenConanfile from conans.util.env_reader import get_env from conans.util.files import load @@ -397,22 +396,19 @@ def test_standard_version_default_matching(self): channel="user/testing", settings=["compiler", "cppstd", ]) - with catch_deprecation_warning(self): - self.client.run('info Hello/1.2.0@user/testing -s compiler="gcc" ' - '-s compiler.libcxx=libstdc++11 -s compiler.version=7.2 ' - '-s cppstd=gnu14') - with catch_deprecation_warning(self): - self.client.run('install Hello/1.2.0@user/testing' - ' -s compiler="gcc" -s compiler.libcxx=libstdc++11' - ' -s compiler.version=7.2 -s cppstd=gnu14') # Default, already built + self.client.run('info Hello/1.2.0@user/testing -s compiler="gcc" ' + '-s compiler.libcxx=libstdc++11 -s compiler.version=7.2 ' + '-s cppstd=gnu14') - # Should NOT have binary available - with catch_deprecation_warning(self): - self.client.run('install Hello/1.2.0@user/testing' - ' -s compiler="gcc" -s compiler.libcxx=libstdc++11' - ' -s compiler.version=7.2 -s cppstd=gnu11', - assert_error=True) + self.client.run('install Hello/1.2.0@user/testing' + ' -s compiler="gcc" -s compiler.libcxx=libstdc++11' + ' -s compiler.version=7.2 -s cppstd=gnu14') # Default, already built + # Should NOT have binary available + self.client.run('install Hello/1.2.0@user/testing' + ' -s compiler="gcc" -s compiler.libcxx=libstdc++11' + ' -s compiler.version=7.2 -s cppstd=gnu11', + assert_error=True) self.assertIn("Missing prebuilt package for 'Hello/1.2.0@user/testing'", self.client.out) def test_std_non_matching_with_cppstd(self): @@ -424,11 +420,10 @@ def test_std_non_matching_with_cppstd(self): ' -s compiler="gcc" -s compiler.libcxx=libstdc++11' ' -s compiler.version=7.2 --build') - with catch_deprecation_warning(self, n=1): - self.client.run('install Hello/1.2.0@user/testing' - ' -s compiler="gcc" -s compiler.libcxx=libstdc++11' - ' -s compiler.version=7.2 -s cppstd=gnu14', - assert_error=True) # Default + self.client.run('install Hello/1.2.0@user/testing' + ' -s compiler="gcc" -s compiler.libcxx=libstdc++11' + ' -s compiler.version=7.2 -s cppstd=gnu14', + assert_error=True) # Default self.assertIn("Missing prebuilt package for 'Hello/1.2.0@user/testing'", self.client.out) def test_std_non_matching_with_compiler_cppstd(self): diff --git a/conans/test/integration/settings/cppstd/default_cppstd_test.py b/conans/test/integration/settings/cppstd/default_cppstd_test.py index 84e070d1d4f..689f4fdfb0c 100644 --- a/conans/test/integration/settings/cppstd/default_cppstd_test.py +++ b/conans/test/integration/settings/cppstd/default_cppstd_test.py @@ -9,7 +9,6 @@ from conans.client.conf import get_default_settings_yml from conans.client.tools import environment_append, save, load from conans.model.settings import Settings -from conans.test.utils.deprecation import catch_deprecation_warning from conans.test.utils.test_files import temp_folder from conans.test.utils.tools import TestClient @@ -114,8 +113,7 @@ def test_value_none(self): def test_value_default(self): # Explicit value (equals to default) passed to setting 'cppstd' cppstd = _make_cppstd_default(self.compiler, self.compiler_version) - with catch_deprecation_warning(self): - id_with, output = self._get_id(with_cppstd=True, settings_values={"cppstd": cppstd}) + id_with, output = self._get_id(with_cppstd=True, settings_values={"cppstd": cppstd}) self.assertIn(">>>> settings: ['compiler', 'cppstd', 'os']", output) self.assertIn(">>>> cppstd: gnu14", output) self.assertIn(">>>> compiler.cppstd: None", output) @@ -123,8 +121,7 @@ def test_value_default(self): def test_value_non_default(self): # Explicit value (not the default) passed to setting 'cppstd' - with catch_deprecation_warning(self): - id_with, output = self._get_id(with_cppstd=True, settings_values={"cppstd": "14"}) + id_with, output = self._get_id(with_cppstd=True, settings_values={"cppstd": "14"}) self.assertIn(">>>> settings: ['compiler', 'cppstd', 'os']", output) self.assertIn(">>>> cppstd: 14", output) self.assertIn(">>>> compiler.cppstd: None", output) @@ -178,8 +175,7 @@ class SettingsCompareCppStdApproaches(DefaultCppTestCase): def test_cppstd_non_defaults(self): cppstd_value = "14" # Not the default - with catch_deprecation_warning(self): - id_with_old, _ = self._get_id(with_cppstd=True, settings_values={"cppstd": cppstd_value}) + id_with_old, _ = self._get_id(with_cppstd=True, settings_values={"cppstd": cppstd_value}) id_with_new, _ = self._get_id(with_cppstd=False, settings_values={'compiler.cppstd': cppstd_value}) diff --git a/conans/test/integration/settings/cppstd_test.py b/conans/test/integration/settings/cppstd_test.py index 0df4bfa42cc..6924e090512 100644 --- a/conans/test/integration/settings/cppstd_test.py +++ b/conans/test/integration/settings/cppstd_test.py @@ -1,7 +1,6 @@ import unittest from conans.paths import CONANFILE -from conans.test.utils.deprecation import catch_deprecation_warning from conans.test.utils.tools import TestClient @@ -19,17 +18,15 @@ class TestConan(ConanFile): """ client.save({CONANFILE: conanfile}) - with catch_deprecation_warning(self): - client.run('create . user/testing -s compiler="gcc" ' - '-s compiler.libcxx="libstdc++11" ' - '-s compiler.version="4.6" -s cppstd=17', assert_error=True) + client.run('create . user/testing -s compiler="gcc" ' + '-s compiler.libcxx="libstdc++11" ' + '-s compiler.version="4.6" -s cppstd=17', assert_error=True) self.assertIn("The specified 'cppstd=17' is not available for 'gcc 4.6'", client.out) self.assertIn("Possible values are ['11', '98', 'gnu11', 'gnu98']", client.out) - with catch_deprecation_warning(self): - client.run('create . user/testing -s compiler="gcc" -s compiler.libcxx="libstdc++11" ' - '-s compiler.version="6.3" -s cppstd=17') + client.run('create . user/testing -s compiler="gcc" -s compiler.libcxx="libstdc++11" ' + '-s compiler.version="6.3" -s cppstd=17') def test_gcc_8_std_20(self): client = TestClient() @@ -43,10 +40,9 @@ class TestConan(ConanFile): """ client.save({CONANFILE: conanfile}) - with catch_deprecation_warning(self): - client.run('create . user/testing -s compiler="gcc" ' - '-s compiler.libcxx="libstdc++11" ' - '-s compiler.version="8" -s cppstd=20') + client.run('create . user/testing -s compiler="gcc" ' + '-s compiler.libcxx="libstdc++11" ' + '-s compiler.version="8" -s cppstd=20') def test_set_default_package_id(self): client = TestClient() @@ -69,11 +65,10 @@ def build(self): # Add the setting but with the default value, should not build again client.save({CONANFILE: conanfile % '"cppstd"'}) # With the setting - with catch_deprecation_warning(self): - client.run('create . user/testing -s compiler="gcc" -s compiler.version="7.1" ' - '-s compiler.libcxx="libstdc++" ' - '-s cppstd=gnu14 ' - '--build missing') + client.run('create . user/testing -s compiler="gcc" -s compiler.version="7.1" ' + '-s compiler.libcxx="libstdc++" ' + '-s cppstd=gnu14 ' + '--build missing') if client.cache.config.revisions_enabled: self.assertIn("doesn't belong to the installed recipe revision, removing folder", @@ -83,10 +78,9 @@ def build(self): self.assertNotIn("BUILDING!", client.out) # Add the setting but with a non-default value, should build again - client.save({CONANFILE: conanfile % '"cppstd"'}) # With the setting - with catch_deprecation_warning(self): - client.run('create . user/testing -s compiler="gcc" -s compiler.version="7.1" ' - '-s compiler.libcxx="libstdc++" ' - '-s cppstd=gnu17 ' - '--build missing') + client.save({CONANFILE: conanfile % '"cppstd"'}) # With the setting: + client.run('create . user/testing -s compiler="gcc" -s compiler.version="7.1" ' + '-s compiler.libcxx="libstdc++" ' + '-s cppstd=gnu17 ' + '--build missing') self.assertIn("BUILDING!", client.out) diff --git a/conans/test/unittests/client/profile_loader/compiler_cppstd_test.py b/conans/test/unittests/client/profile_loader/compiler_cppstd_test.py index f903b105d9a..e9805de20b6 100644 --- a/conans/test/unittests/client/profile_loader/compiler_cppstd_test.py +++ b/conans/test/unittests/client/profile_loader/compiler_cppstd_test.py @@ -11,7 +11,6 @@ from conans.client.migrations_settings import settings_1_14_0 from conans.client.profile_loader import profile_from_args from conans.errors import ConanException -from conans.test.utils.deprecation import catch_deprecation_warning from conans.test.utils.test_files import temp_folder from conans.test.utils.mocks import TestBufferConanOutput from conans.util.files import save @@ -107,8 +106,7 @@ def test_value_duplicated(self): with six.assertRaisesRegex(self, ConanException, "Do not use settings 'compiler.cppstd'" " together with 'cppstd'. Use only the" " former one."): - with catch_deprecation_warning(self): - r.process_settings(self.cache) + r.process_settings(self.cache) self.assertEqual(r.settings["compiler.cppstd"], "11") self.assertEqual(r.settings["cppstd"], "11") @@ -119,14 +117,12 @@ def test_value_different(self): with six.assertRaisesRegex(self, ConanException, "Do not use settings 'compiler.cppstd'" " together with 'cppstd'. Use only the" " former one"): - with catch_deprecation_warning(self): - r.process_settings(self.cache) + r.process_settings(self.cache) def test_value_from_cppstd(self): self._save_profile(cppstd="11") r = profile_from_args(["default", ], [], [], [], cwd=self.tmp_folder, cache=self.cache) - with catch_deprecation_warning(self): - r.process_settings(self.cache) + r.process_settings(self.cache) self.assertNotIn('compiler.cppstd', r.settings) self.assertEqual(r.settings["cppstd"], "11") diff --git a/conans/test/unittests/model/build_info/cppflags_test.py b/conans/test/unittests/model/build_info/cppflags_test.py index 53fdce74324..e87801523ca 100644 --- a/conans/test/unittests/model/build_info/cppflags_test.py +++ b/conans/test/unittests/model/build_info/cppflags_test.py @@ -1,7 +1,6 @@ # coding=utf-8 import unittest -import warnings from conans.model.build_info import _CppInfo @@ -11,38 +10,23 @@ class CppFlagsTest(unittest.TestCase): def test_use_cxxflags(self): """ Changes in cxxflags get reflected in cppflags """ + cpp_info = _CppInfo() + cpp_info.cxxflags = "flags" + self.assertEqual(cpp_info.cppflags, "flags") + self.assertEqual(cpp_info.cxxflags, cpp_info.cppflags) - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter("always") - - cpp_info = _CppInfo() - cpp_info.cxxflags = "flags" - self.assertEqual(cpp_info.cppflags, "flags") - self.assertEqual(cpp_info.cxxflags, cpp_info.cppflags) - - cpp_info.cxxflags = None - self.assertEqual(cpp_info.cppflags, None) - self.assertEqual(cpp_info.cxxflags, cpp_info.cppflags) - - self.assertEqual(len(w), 4) - self.assertTrue(issubclass(w[0].category, DeprecationWarning)) + cpp_info.cxxflags = None + self.assertEqual(cpp_info.cppflags, None) + self.assertEqual(cpp_info.cxxflags, cpp_info.cppflags) def test_use_cppflags(self): """ Changes in cppflags get reflected in cxxflags """ + cpp_info = _CppInfo() - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter("always") - - cpp_info = _CppInfo() - - cpp_info.cppflags = "flags" - self.assertEqual(cpp_info.cxxflags, "flags") - self.assertEqual(cpp_info.cxxflags, cpp_info.cppflags) - - cpp_info.cppflags = None - self.assertEqual(cpp_info.cxxflags, None) - self.assertEqual(cpp_info.cxxflags, cpp_info.cppflags) - - self.assertEqual(len(w), 4) - self.assertTrue(issubclass(w[0].category, DeprecationWarning)) + cpp_info.cppflags = "flags" + self.assertEqual(cpp_info.cxxflags, "flags") + self.assertEqual(cpp_info.cxxflags, cpp_info.cppflags) + cpp_info.cppflags = None + self.assertEqual(cpp_info.cxxflags, None) + self.assertEqual(cpp_info.cxxflags, cpp_info.cppflags) diff --git a/conans/test/unittests/model/other_settings_test.py b/conans/test/unittests/model/other_settings_test.py index 562fbf97537..ed75cefd388 100644 --- a/conans/test/unittests/model/other_settings_test.py +++ b/conans/test/unittests/model/other_settings_test.py @@ -6,7 +6,6 @@ from conans.model.ref import PackageReference from conans.model.settings import bad_value_msg, undefined_value from conans.paths import CONANFILE, CONANINFO -from conans.test.utils.deprecation import catch_deprecation_warning from conans.test.assets.genconanfile import GenConanfile from conans.test.utils.tools import TestClient from conans.util.files import load, save @@ -49,8 +48,7 @@ class Pkg(ConanFile): settings = "compiler", "cppstd" """ client.save({"conanfile.py": conanfile}) - with catch_deprecation_warning(self): - client.run("create . Pkg/0.1@lasote/testing") + client.run("create . Pkg/0.1@lasote/testing") self.assertIn("""Configuration: [settings] compiler=mycomp diff --git a/conans/test/unittests/model/transitive_reqs_test.py b/conans/test/unittests/model/transitive_reqs_test.py index de855677775..67e2a928631 100644 --- a/conans/test/unittests/model/transitive_reqs_test.py +++ b/conans/test/unittests/model/transitive_reqs_test.py @@ -1754,8 +1754,6 @@ def config(self): """ deps_graph = self.build_graph(content, settings="os=Windows\n compiler=gcc\narch=x86\n" "compiler.libcxx=libstdc++") - self.assertIn("WARN: config() has been deprecated. Use config_options() and configure()", - self.output) self.assertEqual(_get_edges(deps_graph), set()) self.assertEqual(1, len(deps_graph.nodes)) node = _get_nodes(deps_graph, "Say")[0] diff --git a/conans/test/unittests/util/build_sln_command_test.py b/conans/test/unittests/util/build_sln_command_test.py index 7131376240a..d2897deb9e6 100644 --- a/conans/test/unittests/util/build_sln_command_test.py +++ b/conans/test/unittests/util/build_sln_command_test.py @@ -2,11 +2,9 @@ # -*- coding: utf-8 -*- import os -import platform import unittest import warnings -import pytest from six import StringIO from conans.client import tools @@ -36,32 +34,20 @@ def test_no_configuration(self): path = os.path.join(folder, "dummy.sln") save(path, dummy) - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter("always") - - new_out = StringIO() - command = build_sln_command(Settings({}), sln_path=path, targets=None, upgrade_project=False, - build_type='Debug', arch="x86", parallel=False, - output=ConanOutput(new_out)) - - self.assertEqual(len(w), 1) - self.assertTrue(issubclass(w[0].category, DeprecationWarning)) + new_out = StringIO() + command = build_sln_command(Settings({}), sln_path=path, targets=None, upgrade_project=False, + build_type='Debug', arch="x86", parallel=False, + output=ConanOutput(new_out)) self.assertIn('/p:Configuration="Debug" /p:UseEnv=false /p:Platform="x86"', command) self.assertIn("WARN: ***** The configuration Debug|x86 does not exist in this solution *****", new_out.getvalue()) # use platforms - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter("always") - - new_out = StringIO() - command = build_sln_command(Settings({}), sln_path=path, targets=None, upgrade_project=False, - build_type='Debug', arch="x86", parallel=False, - platforms={"x86": "Win32"}, output=ConanOutput(new_out)) - - self.assertEqual(len(w), 1) - self.assertTrue(issubclass(w[0].category, DeprecationWarning)) + new_out = StringIO() + command = build_sln_command(Settings({}), sln_path=path, targets=None, upgrade_project=False, + build_type='Debug', arch="x86", parallel=False, + platforms={"x86": "Win32"}, output=ConanOutput(new_out)) self.assertIn('/p:Configuration="Debug" /p:UseEnv=false /p:Platform="Win32"', command) self.assertNotIn("WARN", new_out.getvalue()) @@ -94,16 +80,10 @@ def test_no_build_type(self): self.assertTrue(issubclass(w[0].category, DeprecationWarning)) def test_positive(self): - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter("always") - - output = ConanOutput(StringIO()) - command = build_sln_command(Settings({}), sln_path='dummy.sln', targets=None, - upgrade_project=False, build_type='Debug', arch='x86', - parallel=False, output=output) - - self.assertEqual(len(w), 1) - self.assertTrue(issubclass(w[0].category, DeprecationWarning)) + output = ConanOutput(StringIO()) + command = build_sln_command(Settings({}), sln_path='dummy.sln', targets=None, + upgrade_project=False, build_type='Debug', arch='x86', + parallel=False, output=output) self.assertIn('msbuild "dummy.sln"', command) self.assertIn('/p:Platform="x86"', command) @@ -112,16 +92,10 @@ def test_positive(self): self.assertNotIn('/target:teapot', command) def test_upgrade(self): - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter("always") - - output = ConanOutput(StringIO()) - command = build_sln_command(Settings({}), sln_path='dummy.sln', targets=None, - upgrade_project=True, build_type='Debug', arch='x86_64', - parallel=False, output=output) - - self.assertEqual(len(w), 1) - self.assertTrue(issubclass(w[0].category, DeprecationWarning)) + output = ConanOutput(StringIO()) + command = build_sln_command(Settings({}), sln_path='dummy.sln', targets=None, + upgrade_project=True, build_type='Debug', arch='x86_64', + parallel=False, output=output) self.assertIn('msbuild "dummy.sln"', command) self.assertIn('/p:Platform="x64"', command) @@ -130,16 +104,10 @@ def test_upgrade(self): self.assertNotIn('/target:teapot', command) with tools.environment_append({"CONAN_SKIP_VS_PROJECTS_UPGRADE": "1"}): - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter("always") - - output = ConanOutput(StringIO()) - command = build_sln_command(Settings({}), sln_path='dummy.sln', targets=None, - upgrade_project=True, build_type='Debug', arch='x86_64', - parallel=False, output=output) - - self.assertEqual(len(w), 1) - self.assertTrue(issubclass(w[0].category, DeprecationWarning)) + output = ConanOutput(StringIO()) + command = build_sln_command(Settings({}), sln_path='dummy.sln', targets=None, + upgrade_project=True, build_type='Debug', arch='x86_64', + parallel=False, output=output) self.assertIn('msbuild "dummy.sln"', command) self.assertIn('/p:Platform="x64"', command) @@ -148,30 +116,18 @@ def test_upgrade(self): self.assertNotIn('/target:teapot', command) with tools.environment_append({"CONAN_SKIP_VS_PROJECTS_UPGRADE": "False"}): - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter("always") - - output = ConanOutput(StringIO()) - command = build_sln_command(Settings({}), sln_path='dummy.sln', targets=None, - upgrade_project=True, build_type='Debug', arch='x86_64', - parallel=False, output=output) - - self.assertEqual(len(w), 1) - self.assertTrue(issubclass(w[0].category, DeprecationWarning)) - - self.assertIn('devenv "dummy.sln" /upgrade', command) - - def test_parallel(self): - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter("always") - output = ConanOutput(StringIO()) command = build_sln_command(Settings({}), sln_path='dummy.sln', targets=None, - upgrade_project=True, build_type='Debug', arch='armv7', + upgrade_project=True, build_type='Debug', arch='x86_64', parallel=False, output=output) - self.assertEqual(len(w), 1) - self.assertTrue(issubclass(w[0].category, DeprecationWarning)) + self.assertIn('devenv "dummy.sln" /upgrade', command) + + def test_parallel(self): + output = ConanOutput(StringIO()) + command = build_sln_command(Settings({}), sln_path='dummy.sln', targets=None, + upgrade_project=True, build_type='Debug', arch='armv7', + parallel=False, output=output) self.assertIn('msbuild "dummy.sln"', command) self.assertIn('/p:Platform="ARM"', command) @@ -180,16 +136,10 @@ def test_parallel(self): self.assertNotIn('/target:teapot', command) def test_target(self): - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter("always") - - output = ConanOutput(StringIO()) - command = build_sln_command(Settings({}), sln_path='dummy.sln', targets=['teapot'], - upgrade_project=False, build_type='Debug', arch='armv8', - parallel=False, output=output) - - self.assertEqual(len(w), 1) - self.assertTrue(issubclass(w[0].category, DeprecationWarning)) + output = ConanOutput(StringIO()) + command = build_sln_command(Settings({}), sln_path='dummy.sln', targets=['teapot'], + upgrade_project=False, build_type='Debug', arch='armv8', + parallel=False, output=output) self.assertIn('msbuild "dummy.sln"', command) self.assertIn('/p:Platform="ARM64"', command) @@ -198,21 +148,15 @@ def test_target(self): self.assertIn('/target:teapot', command) def test_toolset(self): - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter("always") - - new_out = StringIO() - command = build_sln_command(MockSettings({"compiler": "Visual Studio", - "compiler.version": "17", - "build_type": "Debug", - "compiler.runtime": "MDd", - "cppstd": "17"}), - sln_path='dummy.sln', targets=None, - upgrade_project=False, build_type='Debug', arch='armv7', - parallel=False, toolset="v110", output=ConanOutput(new_out)) - - self.assertEqual(len(w), 1) - self.assertTrue(issubclass(w[0].category, DeprecationWarning)) + new_out = StringIO() + command = build_sln_command(MockSettings({"compiler": "Visual Studio", + "compiler.version": "17", + "build_type": "Debug", + "compiler.runtime": "MDd", + "cppstd": "17"}), + sln_path='dummy.sln', targets=None, + upgrade_project=False, build_type='Debug', arch='armv7', + parallel=False, toolset="v110", output=ConanOutput(new_out)) self.assertTrue(command.startswith('msbuild "dummy.sln" /p:Configuration="Debug" ' '/p:UseEnv=false ' @@ -222,21 +166,15 @@ def test_toolset(self): '/p:ForceImportBeforeCppTargets='), command) def test_properties_file(self): - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter("always") - - new_out = StringIO() - command = build_sln_command(MockSettings({"compiler": "Visual Studio", - "compiler.version": "17", - "build_type": "Debug", - "compiler.runtime": "MDd", - "cppstd": "17"}), - sln_path='dummy.sln', targets=None, - upgrade_project=False, build_type='Debug', arch='armv7', - parallel=False, output=ConanOutput(new_out)) - - self.assertEqual(len(w), 1) - self.assertTrue(issubclass(w[0].category, DeprecationWarning)) + new_out = StringIO() + command = build_sln_command(MockSettings({"compiler": "Visual Studio", + "compiler.version": "17", + "build_type": "Debug", + "compiler.runtime": "MDd", + "cppstd": "17"}), + sln_path='dummy.sln', targets=None, + upgrade_project=False, build_type='Debug', arch='armv7', + parallel=False, output=ConanOutput(new_out)) self.assertTrue(command.startswith('msbuild "dummy.sln" /p:Configuration="Debug" ' '/p:UseEnv=false ' diff --git a/conans/test/unittests/util/tools_test.py b/conans/test/unittests/util/tools_test.py index 1908524624f..0dec5f948b5 100644 --- a/conans/test/unittests/util/tools_test.py +++ b/conans/test/unittests/util/tools_test.py @@ -855,8 +855,6 @@ def test_self_collect_libs(self): conanfile.package_folder = None result = conanfile.collect_libs() self.assertEqual([], result) - self.assertIn("'self.collect_libs' is deprecated, use 'tools.collect_libs(self)' instead", - conanfile.output) # Default behavior conanfile.package_folder = temp_folder() diff --git a/conans/test/utils/conan_v2_tests.py b/conans/test/utils/conan_v2_tests.py index 218422543af..19d9c8ecfd9 100644 --- a/conans/test/utils/conan_v2_tests.py +++ b/conans/test/utils/conan_v2_tests.py @@ -11,12 +11,9 @@ class ConanV2ModeTestCase(unittest.TestCase): @staticmethod - def get_client(use_settings_v1=False, *args, **kwargs): + def get_client(*args, **kwargs): # TODO: Initialize with the default behavior for Conan v2 t = TestClient(*args, **kwargs) - if use_settings_v1: - t.save({os.path.join(t.cache_folder, CONAN_SETTINGS): - get_default_settings_yml(force_v1=True)}) return t def run(self, *args, **kwargs): diff --git a/conans/test/utils/deprecation.py b/conans/test/utils/deprecation.py deleted file mode 100644 index c495d5fccf8..00000000000 --- a/conans/test/utils/deprecation.py +++ /dev/null @@ -1,14 +0,0 @@ -# coding=utf-8 - -import warnings -from contextlib import contextmanager - - -@contextmanager -def catch_deprecation_warning(test_suite, n=1): - with warnings.catch_warnings(record=True) as w: - warnings.filterwarnings("always", module="(.*\.)?conans\..*") - yield - if n: - test_suite.assertEqual(len(w), n) - test_suite.assertTrue(issubclass(w[0].category, DeprecationWarning)) diff --git a/conans/test/utils/tools.py b/conans/test/utils/tools.py index c12d8d22387..d340acb55e8 100644 --- a/conans/test/utils/tools.py +++ b/conans/test/utils/tools.py @@ -460,8 +460,8 @@ def package_revision_time(self, pref): def _copy_cache_folder(target_folder): # Some variables affect to cache population (take a different default folder) - vars = [CONAN_V2_MODE_ENVVAR, 'CC', 'CXX', 'PATH'] - cache_key = hash('|'.join(map(str, [os.environ.get(it, None) for it in vars]))) + vars_ = [CONAN_V2_MODE_ENVVAR, 'CC', 'CXX', 'PATH'] + cache_key = hash('|'.join(map(str, [os.environ.get(it, None) for it in vars_]))) master_folder = _copy_cache_folder.master.setdefault(cache_key, temp_folder(create_dir=False)) if not os.path.exists(master_folder): # Create and populate the cache folder with the defaults diff --git a/conans/util/conan_v2_mode.py b/conans/util/conan_v2_mode.py index 2ca59ba408f..2bf329f2540 100644 --- a/conans/util/conan_v2_mode.py +++ b/conans/util/conan_v2_mode.py @@ -1,5 +1,4 @@ import os -import warnings from contextlib import contextmanager from conans.errors import ConanV2Exception @@ -7,15 +6,11 @@ CONAN_V2_MODE_ENVVAR = "CONAN_V2_MODE" -def conan_v2_behavior(msg, v1_behavior=None): +def conan_v2_error(msg, condition=True): # FIXME: to deprecate replace this by a "conan_v2_deprecate" that only raises if enabled - if os.environ.get(CONAN_V2_MODE_ENVVAR, False): - raise ConanV2Exception(msg) - else: - if v1_behavior is None: - warnings.warn(message=msg, stacklevel=2, category=DeprecationWarning) - else: - v1_behavior(msg) + if condition: + if os.environ.get(CONAN_V2_MODE_ENVVAR, False): + raise ConanV2Exception(msg) @contextmanager