From dea3eaaf349de81ea5a8d39637b3f50475fc81c3 Mon Sep 17 00:00:00 2001 From: czoido Date: Wed, 11 Sep 2024 07:34:26 +0200 Subject: [PATCH 01/12] Conan 2.7.1 --- conans/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conans/__init__.py b/conans/__init__.py index f8ffad79318..6ae3d06b88a 100644 --- a/conans/__init__.py +++ b/conans/__init__.py @@ -2,4 +2,4 @@ REVISIONS = "revisions" # Only when enabled in config, not by default look at server_launcher.py OAUTH_TOKEN = "oauth_token" -__version__ = '2.7.0' +__version__ = '2.7.1' From 7d9faabfc176b689e54f6c3dcc73ea5094161c9b Mon Sep 17 00:00:00 2001 From: Carlos Zoido Date: Wed, 11 Sep 2024 08:20:41 +0200 Subject: [PATCH 02/12] Add apple-clang 16 to settings (#16972) Signed-off-by: Rui Chen Co-authored-by: Rui Chen --- conans/client/conf/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conans/client/conf/__init__.py b/conans/client/conf/__init__.py index d7c64340776..28f89d142b0 100644 --- a/conans/client/conf/__init__.py +++ b/conans/client/conf/__init__.py @@ -124,7 +124,7 @@ cstd: [null, 99, gnu99, 11, gnu11, 17, gnu17, 23, gnu23] apple-clang: version: ["5.0", "5.1", "6.0", "6.1", "7.0", "7.3", "8.0", "8.1", "9.0", "9.1", - "10.0", "11.0", "12.0", "13", "13.0", "13.1", "14", "14.0", "15", "15.0"] + "10.0", "11.0", "12.0", "13", "13.0", "13.1", "14", "14.0", "15", "15.0", "16", "16.0"] libcxx: [libstdc++, libc++] cppstd: [null, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17, 20, gnu20, 23, gnu23] cstd: [null, 99, gnu99, 11, gnu11, 17, gnu17, 23, gnu23] From 26c8fdfbd55b98144465a7e6bcb1e18630cd58cb Mon Sep 17 00:00:00 2001 From: Carlos Zoido Date: Wed, 11 Sep 2024 08:21:13 +0200 Subject: [PATCH 03/12] Revert "Define compiler variables in CMakePresets.json (#16762)" (#16971) This reverts commit 60df72cf75254608ebe6a447106e60be4d8c05a4. --- conan/tools/cmake/presets.py | 9 +------ conan/tools/cmake/toolchain/blocks.py | 10 +++----- .../toolchains/cmake/test_cmaketoolchain.py | 24 ------------------- 3 files changed, 4 insertions(+), 39 deletions(-) diff --git a/conan/tools/cmake/presets.py b/conan/tools/cmake/presets.py index 43739a955ca..b7e616150e2 100644 --- a/conan/tools/cmake/presets.py +++ b/conan/tools/cmake/presets.py @@ -5,7 +5,7 @@ from conan.api.output import ConanOutput, Color from conan.tools.cmake.layout import get_build_folder_custom_vars -from conan.tools.cmake.toolchain.blocks import GenericSystemBlock, CompilersBlock +from conan.tools.cmake.toolchain.blocks import GenericSystemBlock from conan.tools.cmake.utils import is_multi_configuration from conan.tools.build import build_jobs from conan.tools.microsoft import is_msvc @@ -158,13 +158,6 @@ def _configure_preset(conanfile, generator, cache_variables, toolchain_file, mul "strategy": "external" } - # Set the compiler like in the toolchain. Some IDEs like VS or VSCode require the compiler - # being set to cl.exe in order to activate the environment using vcvarsall.bat according to - # the toolset and architecture settings. - compilers = CompilersBlock.get_compilers(conanfile) - for lang, compiler in compilers.items(): - ret["cacheVariables"][f"CMAKE_{lang}_COMPILER"] = compiler.replace("\\", "/") - ret["toolchainFile"] = toolchain_file if conanfile.build_folder: # If we are installing a ref: "conan install ", we don't have build_folder, because diff --git a/conan/tools/cmake/toolchain/blocks.py b/conan/tools/cmake/toolchain/blocks.py index 5549fdf1dcc..cc24c45c44b 100644 --- a/conan/tools/cmake/toolchain/blocks.py +++ b/conan/tools/cmake/toolchain/blocks.py @@ -865,13 +865,9 @@ class CompilersBlock(Block): """) def context(self): - return {"compilers": self.get_compilers(self._conanfile)} - - @staticmethod - def get_compilers(conanfile): # Reading configuration from "tools.build:compiler_executables" -> {"C": "/usr/bin/gcc"} - compilers_by_conf = conanfile.conf.get("tools.build:compiler_executables", default={}, - check_type=dict) + compilers_by_conf = self._conanfile.conf.get("tools.build:compiler_executables", default={}, + check_type=dict) # Map the possible languages compilers = {} # Allowed variables (and _LAUNCHER) @@ -882,7 +878,7 @@ def get_compilers(conanfile): # To set CMAKE__COMPILER if comp in compilers_by_conf: compilers[lang] = compilers_by_conf[comp] - return compilers + return {"compilers": compilers} class GenericSystemBlock(Block): diff --git a/test/integration/toolchains/cmake/test_cmaketoolchain.py b/test/integration/toolchains/cmake/test_cmaketoolchain.py index 2b6c8ac4025..753083ff8ec 100644 --- a/test/integration/toolchains/cmake/test_cmaketoolchain.py +++ b/test/integration/toolchains/cmake/test_cmaketoolchain.py @@ -1046,30 +1046,6 @@ def test_set_cmake_lang_compilers_and_launchers(): assert 'set(CMAKE_RC_COMPILER "C:/local/rc.exe")' in toolchain -def test_cmake_presets_compiler(): - profile = textwrap.dedent(r""" - [settings] - os=Windows - arch=x86_64 - compiler=msvc - compiler.version=193 - compiler.runtime=dynamic - [conf] - tools.build:compiler_executables={"c": "cl", "cpp": "cl.exe", "rc": "C:\\local\\rc.exe"} - """) - client = TestClient() - conanfile = GenConanfile().with_settings("os", "arch", "compiler")\ - .with_generator("CMakeToolchain") - client.save({"conanfile.py": conanfile, - "profile": profile}) - client.run("install . -pr:b profile -pr:h profile") - presets = json.loads(client.load("CMakePresets.json")) - cache_variables = presets["configurePresets"][0]["cacheVariables"] - assert cache_variables["CMAKE_C_COMPILER"] == "cl" - assert cache_variables["CMAKE_CXX_COMPILER"] == "cl.exe" - assert cache_variables["CMAKE_RC_COMPILER"] == "C:/local/rc.exe" - - def test_cmake_layout_toolchain_folder(): """ in single-config generators, the toolchain is a different file per configuration https://github.com/conan-io/conan/issues/12827 From e96a7b0c0b6cf4eb8189334a8c4050ee16acd339 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abril=20Rinc=C3=B3n=20Blanco?= Date: Wed, 11 Sep 2024 10:34:40 +0200 Subject: [PATCH 04/12] Fix c++23 flag for apple-clang 16 (#16973) apple-clang 16 allows c++23 flag --- conan/tools/build/flags.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/conan/tools/build/flags.py b/conan/tools/build/flags.py index aecaa0931d7..9805622f4e4 100644 --- a/conan/tools/build/flags.py +++ b/conan/tools/build/flags.py @@ -264,7 +264,10 @@ def _cppstd_apple_clang(clang_version, cppstd): v20 = "c++2a" vgnu20 = "gnu++2a" - if clang_version >= "13.0": + if clang_version >= "16.0": + v23 = "c++23" + vgnu23 = "gnu++23" + elif clang_version >= "13.0": v23 = "c++2b" vgnu23 = "gnu++2b" From 7244cb7a3fe0a5f6c2e83017b378233c4bf03201 Mon Sep 17 00:00:00 2001 From: Carlos Zoido Date: Wed, 11 Sep 2024 11:22:22 +0200 Subject: [PATCH 05/12] Add test for #19960 (#16974) --- .../toolchains/cmake/test_cmake_toolchain.py | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/test/functional/toolchains/cmake/test_cmake_toolchain.py b/test/functional/toolchains/cmake/test_cmake_toolchain.py index 2bff994123b..b3173091bb9 100644 --- a/test/functional/toolchains/cmake/test_cmake_toolchain.py +++ b/test/functional/toolchains/cmake/test_cmake_toolchain.py @@ -14,6 +14,7 @@ from conan.test.utils.test_files import temp_folder from conan.test.utils.tools import TestClient, TurboTestClient from conans.util.files import save, load, rmdir +from test.conftest import tools_locations @pytest.mark.skipif(platform.system() != "Windows", reason="Only for windows") @@ -2041,3 +2042,73 @@ def test_cxx_version_not_overriden_if_hardcoded(): tc.run("create . -s=compiler.cppstd=17") assert "Conan toolchain: C++ Standard 17 with extensions OFF" in tc.out assert "Warning: Standard CMAKE_CXX_STANDARD value defined in conan_toolchain.cmake to 17 has been modified to 17" not in tc.out + + +@pytest.mark.tool("cmake", "3.23") # Android complains if <3.19 +@pytest.mark.tool("android_ndk") +@pytest.mark.skipif(platform.system() != "Darwin", reason="NDK only installed on MAC") +def test_cmake_toolchain_crossbuild_set_cmake_compiler(): + # To reproduce https://github.com/conan-io/conan/issues/16960 + # the issue happens when you set CMAKE_CXX_COMPILER and CMAKE_C_COMPILER as cache variables + # and then cross-build + c = TestClient() + + ndk_path = tools_locations["android_ndk"]["system"]["path"][platform.system()] + bin_path = ndk_path + ( + "/toolchains/llvm/prebuilt/darwin-x86_64/bin" if platform.machine() == "x86_64" else + "/toolchains/llvm/prebuilt/darwin-arm64/bin" + ) + + android = textwrap.dedent(f""" + [settings] + os=Android + os.api_level=23 + arch=x86_64 + compiler=clang + compiler.version=12 + compiler.libcxx=c++_shared + build_type=Release + [conf] + tools.android:ndk_path={ndk_path} + tools.build:compiler_executables = {{"c": "{bin_path}/x86_64-linux-android23-clang", "cpp": "{bin_path}/x86_64-linux-android23-clang++"}} + """) + + conanfile = textwrap.dedent(f""" + from conan import ConanFile + from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout + from conan.tools.build import check_min_cppstd + class SDKConan(ConanFile): + name = "sdk" + version = "1.0" + generators = "CMakeDeps", "VirtualBuildEnv" + settings = "os", "compiler", "arch", "build_type" + exports_sources = "CMakeLists.txt" + def layout(self): + cmake_layout(self) + def generate(self): + tc = CMakeToolchain(self) + tc.cache_variables["SDK_VERSION"] = str(self.version) + tc.generate() + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + """) + + cmake = textwrap.dedent(f""" + cmake_minimum_required(VERSION 3.23) + project(sdk VERSION ${{SDK_VERSION}}.0) + message("sdk: ${{SDK_VERSION}}.0") + """) + + c.save({"android": android, + "conanfile.py": conanfile, + "CMakeLists.txt": cmake,}) + # first run works ok + c.run('build . --profile:host=android') + assert 'sdk: 1.0.0' in c.out + # in second run CMake says that you have changed variables that require your cache to be deleted. + # and deletes the cache and fails + c.run('build . --profile:host=android') + assert 'VERSION ".0" format invalid.' not in c.out + assert 'sdk: 1.0.0' in c.out From b31af6f9a81f19f47aa0439555c9642963f0c984 Mon Sep 17 00:00:00 2001 From: PerseoGI Date: Fri, 13 Sep 2024 01:12:12 +0200 Subject: [PATCH 06/12] Make conf.get with a check_type=bool raise exception if invalid value (#16976) * Make conf.get with a check_type=bool raise exception if invalid value --------- Co-authored-by: AbrilRBS * Added test cases and improved conditional check on true values --------- Co-authored-by: AbrilRBS --- conans/model/conf.py | 9 +++++++-- test/unittests/model/test_conf.py | 17 +++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/conans/model/conf.py b/conans/model/conf.py index c04e48d951f..f8e1924e571 100644 --- a/conans/model/conf.py +++ b/conans/model/conf.py @@ -272,6 +272,7 @@ def set_relative_base_folder(self, folder): class Conf: # Putting some default expressions to check that any value could be false boolean_false_expressions = ("0", '"0"', "false", '"false"', "off") + boolean_true_expressions = ("1", '"1"', "true", '"true"', "on") def __init__(self): # It being ordered allows for Windows case-insensitive composition @@ -321,8 +322,12 @@ def get(self, conf_name, default=None, check_type=None, choices=None): raise ConanException(f"Unknown value '{v}' for '{conf_name}'") # Some smart conversions if check_type is bool and not isinstance(v, bool): - # Perhaps, user has introduced a "false", "0" or even "off" - return str(v).lower() not in Conf.boolean_false_expressions + if str(v).lower() in Conf.boolean_false_expressions: + return False + if str(v).lower() in Conf.boolean_true_expressions: + return True + raise ConanException(f"[conf] {conf_name} must be a boolean-like object " + f"(true/false, 1/0, on/off) and value '{v}' does not match it.") elif check_type is str and not isinstance(v, str): return str(v) elif v is None: # value was unset diff --git a/test/unittests/model/test_conf.py b/test/unittests/model/test_conf.py index 042f74463cc..e73870a457a 100644 --- a/test/unittests/model/test_conf.py +++ b/test/unittests/model/test_conf.py @@ -221,10 +221,15 @@ def test_conf_get_check_type_and_default(): zlib:user.company.check:static_str=off user.company.list:newnames+=myname core.download:parallel=True + user:bad_value_0=Fasle + user:bad_value_1=ture + user:bad_value_2=10 + user:bad_value_3='00' """) c = ConfDefinition() c.loads(text) assert c.get("user.company.cpu:jobs", check_type=int) == 5 + assert c.get("user.company.cpu:jobs", check_type=None) == 5 assert c.get("user.company.cpu:jobs", check_type=str) == "5" # smart conversion with pytest.raises(ConanException) as exc_info: c.get("user.company.cpu:jobs", check_type=list) @@ -243,6 +248,18 @@ def test_conf_get_check_type_and_default(): c.get("core.download:parallel", check_type=int) assert ("[conf] core.download:parallel must be a int-like object. " "The value 'True' introduced is a bool object") in str(exc_info.value) + with pytest.raises(ConanException) as exc_info: + c.get("user:bad_value_0", check_type=bool) + assert ("[conf] user:bad_value_0 must be a boolean-like object (true/false, 1/0, on/off) and value 'Fasle' does not match it.") in str(exc_info.value) + with pytest.raises(ConanException) as exc_info: + c.get("user:bad_value_1", check_type=bool) + assert ("[conf] user:bad_value_1 must be a boolean-like object (true/false, 1/0, on/off) and value 'ture' does not match it.") in str(exc_info.value) + with pytest.raises(ConanException) as exc_info: + c.get("user:bad_value_2", check_type=bool) + assert ("[conf] user:bad_value_2 must be a boolean-like object (true/false, 1/0, on/off) and value '10' does not match it.") in str(exc_info.value) + with pytest.raises(ConanException) as exc_info: + c.get("user:bad_value_3", check_type=bool) + assert ("[conf] user:bad_value_3 must be a boolean-like object (true/false, 1/0, on/off) and value '\'00\'' does not match it.") in str(exc_info.value) def test_conf_pop(): From 733941c1da1103be25ed2e09fc0ab166e78af85d Mon Sep 17 00:00:00 2001 From: James Date: Mon, 16 Sep 2024 07:53:11 +0200 Subject: [PATCH 07/12] Feature/upload progress (#16913) * wip * wip * wip * review --- conans/client/rest/file_uploader.py | 29 ++++++++++++++++--- conans/client/rest/rest_client_v2.py | 8 ++--- .../command/upload/upload_complete_test.py | 1 - 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/conans/client/rest/file_uploader.py b/conans/client/rest/file_uploader.py index f8635315b00..025f445959e 100644 --- a/conans/client/rest/file_uploader.py +++ b/conans/client/rest/file_uploader.py @@ -1,7 +1,8 @@ +import os import time from copy import copy -from conan.api.output import ConanOutput +from conan.api.output import ConanOutput, TimedOutput from conans.client.rest import response_to_str from conans.errors import AuthenticationException, ConanException, \ NotFoundException, ForbiddenException, RequestErrorException, InternalErrorException @@ -53,7 +54,7 @@ def exists(self, url, auth): return bool(response.ok) def upload(self, url, abs_path, auth=None, dedup=False, retry=None, retry_wait=None, - headers=None): + headers=None, ref=None): retry = retry if retry is not None else self._config.get("core.upload:retry", default=1, check_type=int) retry_wait = retry_wait if retry_wait is not None else \ @@ -69,7 +70,7 @@ def upload(self, url, abs_path, auth=None, dedup=False, retry=None, retry_wait=N for counter in range(retry + 1): try: - return self._upload_file(url, abs_path, headers, auth) + return self._upload_file(url, abs_path, headers, auth, ref) except (NotFoundException, ForbiddenException, AuthenticationException, RequestErrorException): raise @@ -82,8 +83,28 @@ def upload(self, url, abs_path, auth=None, dedup=False, retry=None, retry_wait=N self._output.info("Waiting %d seconds to retry..." % retry_wait) time.sleep(retry_wait) - def _upload_file(self, url, abs_path, headers, auth): + def _upload_file(self, url, abs_path, headers, auth, ref): + class FileProgress: # Wrapper just to provide an upload progress every 10 seconds + def __init__(self, f, total_size): + self._f = f + self._total = total_size + self._name = os.path.basename(f.name) + self._t = TimedOutput(interval=10) + self._read = 0 + + def __getattr__(self, item): + return getattr(self._f, item) + + def read(self, n=-1): + read_bytes = self._f.read(n) + self._read += len(read_bytes) + self._t.info(f"{ref}: Uploading {self._name}: {int(self._read*100/self._total)}%") + return read_bytes + + filesize = os.path.getsize(abs_path) with open(abs_path, mode='rb') as file_handler: + big_file = filesize > 100000000 # 100 MB + file_handler = FileProgress(file_handler, filesize) if big_file else file_handler try: response = self._requester.put(url, data=file_handler, verify=self._verify_ssl, headers=headers, auth=auth, diff --git a/conans/client/rest/rest_client_v2.py b/conans/client/rest/rest_client_v2.py index 2e46de8de02..0002e7f05a0 100644 --- a/conans/client/rest/rest_client_v2.py +++ b/conans/client/rest/rest_client_v2.py @@ -123,14 +123,14 @@ def _upload_recipe(self, ref, files_to_upload): # Direct upload the recipe urls = {fn: self.router.recipe_file(ref, fn) for fn in files_to_upload} - self._upload_files(files_to_upload, urls) + self._upload_files(files_to_upload, urls, str(ref)) def _upload_package(self, pref, files_to_upload): urls = {fn: self.router.package_file(pref, fn) for fn in files_to_upload} - self._upload_files(files_to_upload, urls) + self._upload_files(files_to_upload, urls, str(pref)) - def _upload_files(self, files, urls): + def _upload_files(self, files, urls, ref): failed = [] uploader = FileUploader(self.requester, self.verify_ssl, self._config) # conan_package.tgz and conan_export.tgz are uploaded first to avoid uploading conaninfo.txt @@ -143,7 +143,7 @@ def _upload_files(self, files, urls): headers = {} uploader.upload(resource_url, files[filename], auth=self.auth, dedup=self._checksum_deploy, - headers=headers) + headers=headers, ref=ref) except (AuthenticationException, ForbiddenException): raise except Exception as exc: diff --git a/test/integration/command/upload/upload_complete_test.py b/test/integration/command/upload/upload_complete_test.py index f800957fdf8..24d6c837fb3 100644 --- a/test/integration/command/upload/upload_complete_test.py +++ b/test/integration/command/upload/upload_complete_test.py @@ -56,7 +56,6 @@ def test_upload_with_pattern(): client.run("export . --user=frodo --channel=stable") client.run("upload hello* --confirm -r default") - print(client.out) for num in range(3): assert "Uploading recipe 'hello%s/1.2.1@frodo/stable" % num in client.out From 23c1c271cd35a2dc5e47721a15d09f846ae5e192 Mon Sep 17 00:00:00 2001 From: James Date: Mon, 16 Sep 2024 07:55:12 +0200 Subject: [PATCH 08/12] more easy refactors conans->conan (#16998) --- conan/api/conan_api.py | 8 ++-- conan/api/subapi/config.py | 5 ++- conan/api/subapi/upload.py | 4 +- conan/internal/api/detect/__init__.py | 0 conan/internal/api/{ => detect}/detect_api.py | 4 +- .../internal/api/detect}/detect_vs.py | 0 conan/internal/api/profile/detect.py | 2 +- conan/internal/api/profile/profile_loader.py | 2 +- conan/internal/api/uploader.py | 35 +++++++++++++++++ .../internal/default_settings.py | 4 -- conan/internal/upload_metadata.py | 38 ------------------- conan/tools/build/cppstd.py | 2 +- conan/tools/microsoft/visual.py | 2 +- conans/client/conf/required_version.py | 30 --------------- conans/client/loader.py | 2 +- conans/client/migrations.py | 2 +- conans/model/version_range.py | 11 ++++++ test/conftest.py | 2 +- test/functional/test_profile_detect_api.py | 2 +- .../test_cmakedeps_custom_configs.py | 4 +- .../toolchains/microsoft/test_msbuild.py | 2 +- test/functional/util/tools_test.py | 2 +- .../conanfile/required_conan_version_test.py | 4 +- .../configuration/conf/test_conf.py | 4 +- .../configuration/required_version_test.py | 8 ++-- .../graph/core/graph_manager_base.py | 2 +- .../client/build/cpp_std_flags_test.py | 2 +- .../client/conf/detect/test_gcc_compiler.py | 4 +- .../profile_loader/compiler_cppstd_test.py | 2 +- test/unittests/model/settings_test.py | 2 +- test/unittests/tools/build/test_cppstd.py | 2 +- .../tools/cmake/test_cmake_install.py | 10 ++--- test/unittests/tools/cmake/test_cmake_test.py | 6 +-- .../tools/cmake/test_cmaketoolchain.py | 8 ++-- test/unittests/util/detect_libc_test.py | 2 +- test/unittests/util/detect_test.py | 8 ++-- .../util/detected_architecture_test.py | 6 +-- 37 files changed, 105 insertions(+), 128 deletions(-) create mode 100644 conan/internal/api/detect/__init__.py rename conan/internal/api/{ => detect}/detect_api.py (99%) rename {conans/client/conf => conan/internal/api/detect}/detect_vs.py (100%) rename conans/client/conf/__init__.py => conan/internal/default_settings.py (99%) delete mode 100644 conan/internal/upload_metadata.py delete mode 100644 conans/client/conf/required_version.py diff --git a/conan/api/conan_api.py b/conan/api/conan_api.py index 0a922501fbc..604e205e85e 100644 --- a/conan/api/conan_api.py +++ b/conan/api/conan_api.py @@ -17,15 +17,15 @@ from conan.api.subapi.remove import RemoveAPI from conan.api.subapi.search import SearchAPI from conan.api.subapi.upload import UploadAPI -from conans.client.conf.required_version import check_required_conan_version from conans.client.migrations import ClientMigrator from conans.client.userio import init_colorama from conans.errors import ConanException from conans.model.version import Version from conan.internal.paths import get_conan_user_home +from conans.model.version_range import validate_conan_version -class ConanAPI(object): +class ConanAPI: def __init__(self, cache_folder=None): version = sys.version_info @@ -59,4 +59,6 @@ def __init__(self, cache_folder=None): self.lockfile = LockfileAPI(self) self.local = LocalAPI(self) - check_required_conan_version(self.config.global_conf) + required_range_new = self.config.global_conf.get("core:required_conan_version") + if required_range_new: + validate_conan_version(required_range_new) diff --git a/conan/api/subapi/config.py b/conan/api/subapi/config.py index 05d64f02050..c3ba8032ca9 100644 --- a/conan/api/subapi/config.py +++ b/conan/api/subapi/config.py @@ -7,10 +7,11 @@ from conan import conan_version from conan.api.output import ConanOutput -from conans.client.conf import default_settings_yml -from conan.internal.api import detect_api + +from conan.internal.api.detect import detect_api from conan.internal.cache.home_paths import HomePaths from conan.internal.conan_app import ConanApp +from conan.internal.default_settings import default_settings_yml from conans.client.graph.graph import CONTEXT_HOST, RECIPE_VIRTUAL, Node from conans.client.graph.graph_builder import DepsGraphBuilder from conans.client.graph.profile_node_definer import consumer_definer diff --git a/conan/api/subapi/upload.py b/conan/api/subapi/upload.py index cc151a761cc..47bf8b1c376 100644 --- a/conan/api/subapi/upload.py +++ b/conan/api/subapi/upload.py @@ -4,8 +4,8 @@ from conan.api.output import ConanOutput from conan.internal.conan_app import ConanApp -from conan.internal.upload_metadata import gather_metadata -from conan.internal.api.uploader import PackagePreparator, UploadExecutor, UploadUpstreamChecker +from conan.internal.api.uploader import PackagePreparator, UploadExecutor, UploadUpstreamChecker, \ + gather_metadata from conans.client.pkg_sign import PkgSignaturesPlugin from conans.client.rest.file_uploader import FileUploader from conans.errors import ConanException, AuthenticationException, ForbiddenException diff --git a/conan/internal/api/detect/__init__.py b/conan/internal/api/detect/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/conan/internal/api/detect_api.py b/conan/internal/api/detect/detect_api.py similarity index 99% rename from conan/internal/api/detect_api.py rename to conan/internal/api/detect/detect_api.py index 0701a56b3f4..96879adf6f6 100644 --- a/conan/internal/api/detect_api.py +++ b/conan/internal/api/detect/detect_api.py @@ -292,7 +292,7 @@ def default_msvc_runtime(compiler): def detect_msvc_update(version): - from conans.client.conf.detect_vs import vs_detect_update + from conan.internal.api.detect.detect_vs import vs_detect_update return vs_detect_update(version) @@ -416,7 +416,7 @@ def default_msvc_ide_version(version): def _detect_vs_ide_version(): - from conans.client.conf.detect_vs import vs_installation_path + from conan.internal.api.detect.detect_vs import vs_installation_path msvc_versions = "17", "16", "15" for version in msvc_versions: vs_path = os.getenv('vs%s0comntools' % version) diff --git a/conans/client/conf/detect_vs.py b/conan/internal/api/detect/detect_vs.py similarity index 100% rename from conans/client/conf/detect_vs.py rename to conan/internal/api/detect/detect_vs.py diff --git a/conan/internal/api/profile/detect.py b/conan/internal/api/profile/detect.py index 9048a82be2f..7c2d2685d6e 100644 --- a/conan/internal/api/profile/detect.py +++ b/conan/internal/api/profile/detect.py @@ -1,5 +1,5 @@ from conan.api.output import ConanOutput -from conan.internal.api.detect_api import detect_os, detect_arch, default_msvc_runtime, \ +from conan.internal.api.detect.detect_api import detect_os, detect_arch, default_msvc_runtime, \ detect_libcxx, detect_cppstd, detect_default_compiler, default_compiler_version diff --git a/conan/internal/api/profile/profile_loader.py b/conan/internal/api/profile/profile_loader.py index 8b36ef61f64..e9047054a49 100644 --- a/conan/internal/api/profile/profile_loader.py +++ b/conan/internal/api/profile/profile_loader.py @@ -6,7 +6,7 @@ from conan import conan_version from conan.api.output import ConanOutput -from conan.internal.api import detect_api +from conan.internal.api.detect import detect_api from conan.internal.cache.home_paths import HomePaths from conan.tools.env.environment import ProfileEnvironment from conans.errors import ConanException diff --git a/conan/internal/api/uploader.py b/conan/internal/api/uploader.py index 6c56a69be43..2cdf1ff2ad7 100644 --- a/conan/internal/api/uploader.py +++ b/conan/internal/api/uploader.py @@ -1,3 +1,4 @@ +import fnmatch import os import shutil import time @@ -277,3 +278,37 @@ def _total_size(cache_files): stat = os.stat(file) total_size += stat.st_size return human_size(total_size) + + +def _metadata_files(folder, metadata): + result = {} + for root, _, files in os.walk(folder): + for f in files: + abs_path = os.path.join(root, f) + relpath = os.path.relpath(abs_path, folder) + if metadata: + if not any(fnmatch.fnmatch(relpath, m) for m in metadata): + continue + path = os.path.join("metadata", relpath).replace("\\", "/") + result[path] = abs_path + return result + + +def gather_metadata(package_list, cache, metadata): + for rref, recipe_bundle in package_list.refs().items(): + if metadata or recipe_bundle["upload"]: + metadata_folder = cache.recipe_layout(rref).metadata() + files = _metadata_files(metadata_folder, metadata) + if files: + ConanOutput(scope=str(rref)).info(f"Recipe metadata: {len(files)} files") + recipe_bundle.setdefault("files", {}).update(files) + recipe_bundle["upload"] = True + + for pref, pkg_bundle in package_list.prefs(rref, recipe_bundle).items(): + if metadata or pkg_bundle["upload"]: + metadata_folder = cache.pkg_layout(pref).metadata() + files = _metadata_files(metadata_folder, metadata) + if files: + ConanOutput(scope=str(pref)).info(f"Package metadata: {len(files)} files") + pkg_bundle.setdefault("files", {}).update(files) + pkg_bundle["upload"] = True diff --git a/conans/client/conf/__init__.py b/conan/internal/default_settings.py similarity index 99% rename from conans/client/conf/__init__.py rename to conan/internal/default_settings.py index 28f89d142b0..3987645642f 100644 --- a/conans/client/conf/__init__.py +++ b/conan/internal/default_settings.py @@ -150,10 +150,6 @@ """ -def get_default_settings_yml(): - return default_settings_yml - - def migrate_settings_file(cache_folder): from conans.client.migrations import update_file diff --git a/conan/internal/upload_metadata.py b/conan/internal/upload_metadata.py deleted file mode 100644 index 0dc8c2319cc..00000000000 --- a/conan/internal/upload_metadata.py +++ /dev/null @@ -1,38 +0,0 @@ -import fnmatch -import os - -from conan.api.output import ConanOutput - - -def _metadata_files(folder, metadata): - result = {} - for root, _, files in os.walk(folder): - for f in files: - abs_path = os.path.join(root, f) - relpath = os.path.relpath(abs_path, folder) - if metadata: - if not any(fnmatch.fnmatch(relpath, m) for m in metadata): - continue - path = os.path.join("metadata", relpath).replace("\\", "/") - result[path] = abs_path - return result - - -def gather_metadata(package_list, cache, metadata): - for rref, recipe_bundle in package_list.refs().items(): - if metadata or recipe_bundle["upload"]: - metadata_folder = cache.recipe_layout(rref).metadata() - files = _metadata_files(metadata_folder, metadata) - if files: - ConanOutput(scope=str(rref)).info(f"Recipe metadata: {len(files)} files") - recipe_bundle.setdefault("files", {}).update(files) - recipe_bundle["upload"] = True - - for pref, pkg_bundle in package_list.prefs(rref, recipe_bundle).items(): - if metadata or pkg_bundle["upload"]: - metadata_folder = cache.pkg_layout(pref).metadata() - files = _metadata_files(metadata_folder, metadata) - if files: - ConanOutput(scope=str(pref)).info(f"Package metadata: {len(files)} files") - pkg_bundle.setdefault("files", {}).update(files) - pkg_bundle["upload"] = True diff --git a/conan/tools/build/cppstd.py b/conan/tools/build/cppstd.py index bf66fc62435..c15bbaa714f 100644 --- a/conan/tools/build/cppstd.py +++ b/conan/tools/build/cppstd.py @@ -1,7 +1,7 @@ import operator from conan.errors import ConanInvalidConfiguration, ConanException -from conan.internal.api.detect_api import default_cppstd as default_cppstd_ +from conan.internal.api.detect.detect_api import default_cppstd as default_cppstd_ from conans.model.version import Version diff --git a/conan/tools/microsoft/visual.py b/conan/tools/microsoft/visual.py index 7aad2edf995..233f9c50eb5 100644 --- a/conan/tools/microsoft/visual.py +++ b/conan/tools/microsoft/visual.py @@ -2,7 +2,7 @@ import textwrap from conan.internal import check_duplicated_generator -from conans.client.conf.detect_vs import vs_installation_path +from conan.internal.api.detect.detect_vs import vs_installation_path from conan.errors import ConanException, ConanInvalidConfiguration from conan.tools.scm import Version from conan.tools.intel.intel_cc import IntelCC diff --git a/conans/client/conf/required_version.py b/conans/client/conf/required_version.py deleted file mode 100644 index 50c89935ca5..00000000000 --- a/conans/client/conf/required_version.py +++ /dev/null @@ -1,30 +0,0 @@ -from conans import __version__ as client_version -from conans.errors import ConanException -from conans.model.version import Version -from conans.model.version_range import VersionRange - - -def validate_conan_version(required_range): - clientver = Version(client_version) - version_range = VersionRange(required_range) - for conditions in version_range.condition_sets: - conditions.prerelease = True - if not version_range.contains(clientver, resolve_prerelease=None): - raise ConanException("Current Conan version ({}) does not satisfy " - "the defined one ({}).".format(clientver, required_range)) - - -def check_required_conan_version(global_conf): - """ Check if the required Conan version in config file matches to the current Conan version - - When required_conan_version is not configured, it's skipped - When required_conan_version is configured, Conan's version must matches the required - version - When it doesn't match, an ConanException is raised - - :param global_conf: the global configura - :return: None - """ - required_range_new = global_conf.get("core:required_conan_version") - if required_range_new: - validate_conan_version(required_range_new) diff --git a/conans/client/loader.py b/conans/client/loader.py index b355c015086..efaed1a6418 100644 --- a/conans/client/loader.py +++ b/conans/client/loader.py @@ -14,13 +14,13 @@ from conan.tools.cmake import cmake_layout from conan.tools.google import bazel_layout from conan.tools.microsoft import vs_layout -from conans.client.conf.required_version import validate_conan_version from conans.client.loader_txt import ConanFileTextLoader from conans.errors import ConanException, NotFoundException, conanfile_exception_formatter from conans.model.conan_file import ConanFile from conans.model.options import Options from conans.model.recipe_ref import RecipeReference from conan.internal.paths import DATA_YML +from conans.model.version_range import validate_conan_version from conans.util.files import load, chdir, load_user_encoded diff --git a/conans/client/migrations.py b/conans/client/migrations.py index ddde216ac69..82997ba4e9e 100644 --- a/conans/client/migrations.py +++ b/conans/client/migrations.py @@ -4,6 +4,7 @@ from conan.api.output import ConanOutput from conan.api.subapi.config import ConfigAPI +from conan.internal.default_settings import migrate_settings_file from conans.migrations import Migrator from conans.util.dates import timestamp_now from conans.util.files import load, save @@ -44,7 +45,6 @@ def _apply_migrations(self, old_version): # Migrate the settings if they were the default for that version # Time for migrations! # Update settings.yml - from conans.client.conf import migrate_settings_file migrate_settings_file(self.cache_folder) # Update compatibility.py, app_compat.py, and cppstd_compat.py. from conans.client.graph.compatibility import migrate_compatibility_files diff --git a/conans/model/version_range.py b/conans/model/version_range.py index 751683e3e73..ba59e84e6ba 100644 --- a/conans/model/version_range.py +++ b/conans/model/version_range.py @@ -3,6 +3,7 @@ from conans.errors import ConanException from conans.model.recipe_ref import Version +from conans import __version__ as client_version @total_ordering @@ -217,3 +218,13 @@ def _calculate_limits(operator, lhs, rhs): def version(self): return Version(f"[{self._expression}]") + + +def validate_conan_version(required_range): + clientver = Version(client_version) + version_range = VersionRange(required_range) + for conditions in version_range.condition_sets: + conditions.prerelease = True + if not version_range.contains(clientver, resolve_prerelease=None): + raise ConanException("Current Conan version ({}) does not satisfy " + "the defined one ({}).".format(clientver, required_range)) diff --git a/test/conftest.py b/test/conftest.py index bc148aabefd..3d169ce3540 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -6,7 +6,7 @@ import pytest -from conans.client.conf.detect_vs import vswhere +from conan.internal.api.detect.detect_vs import vswhere """ To override these locations with your own in your dev machine: diff --git a/test/functional/test_profile_detect_api.py b/test/functional/test_profile_detect_api.py index 1bac560e898..509df11297d 100644 --- a/test/functional/test_profile_detect_api.py +++ b/test/functional/test_profile_detect_api.py @@ -3,7 +3,7 @@ import pytest -from conan.internal.api import detect_api +from conan.internal.api.detect import detect_api from conan.test.utils.tools import TestClient diff --git a/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_custom_configs.py b/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_custom_configs.py index 4169b5f2779..3501ddbdcc1 100644 --- a/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_custom_configs.py +++ b/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_custom_configs.py @@ -5,7 +5,7 @@ import pytest -from conans.client.conf import get_default_settings_yml +from conan.internal.default_settings import default_settings_yml from conan.test.assets.genconanfile import GenConanfile from conan.test.assets.sources import gen_function_cpp from conan.test.utils.tools import TestClient @@ -145,7 +145,7 @@ def generate(self): def setUp(self): self.client = TestClient(path_with_spaces=False) - settings = get_default_settings_yml() + settings = default_settings_yml settings = settings.replace("build_type: [null, Debug, Release, ", "build_type: [null, Debug, MyRelease, ") save(self.client.cache.settings_path, settings) diff --git a/test/functional/toolchains/microsoft/test_msbuild.py b/test/functional/toolchains/microsoft/test_msbuild.py index 073eed151bd..890f17e771c 100644 --- a/test/functional/toolchains/microsoft/test_msbuild.py +++ b/test/functional/toolchains/microsoft/test_msbuild.py @@ -5,7 +5,7 @@ import pytest from conan.tools.microsoft.visual import vcvars_command -from conans.client.conf.detect_vs import vs_installation_path +from conan.internal.api.detect.detect_vs import vs_installation_path from conan.test.assets.sources import gen_function_cpp from test.functional.utils import check_vs_runtime, check_exe_run from conan.test.utils.tools import TestClient diff --git a/test/functional/util/tools_test.py b/test/functional/util/tools_test.py index 42c14d8fba4..b89fc1c583c 100644 --- a/test/functional/util/tools_test.py +++ b/test/functional/util/tools_test.py @@ -5,7 +5,7 @@ import pytest -from conans.client.conf.detect_vs import vswhere +from conan.internal.api.detect.detect_vs import vswhere from conans.errors import ConanException from conan.test.utils.env import environment_update diff --git a/test/integration/conanfile/required_conan_version_test.py b/test/integration/conanfile/required_conan_version_test.py index d4904a2a1f7..3bde82da837 100644 --- a/test/integration/conanfile/required_conan_version_test.py +++ b/test/integration/conanfile/required_conan_version_test.py @@ -22,10 +22,10 @@ class Lib(ConanFile): client.run("source . ", assert_error=True) assert f"Current Conan version ({__version__}) does not satisfy the defined one (>=100.0)" in client.out - with mock.patch("conans.client.conf.required_version.client_version", "101.0"): + with mock.patch("conans.model.version_range.client_version", "101.0"): client.run("export . --name=pkg --version=1.0") - with mock.patch("conans.client.conf.required_version.client_version", "101.0-dev"): + with mock.patch("conans.model.version_range.client_version", "101.0-dev"): client.run("export . --name=pkg --version=1.0") client.run("install --requires=pkg/1.0@", assert_error=True) diff --git a/test/integration/configuration/conf/test_conf.py b/test/integration/configuration/conf/test_conf.py index 66cc9ef2219..d8329e09e4d 100644 --- a/test/integration/configuration/conf/test_conf.py +++ b/test/integration/configuration/conf/test_conf.py @@ -6,7 +6,7 @@ from mock import patch from conan import conan_version -from conan.internal.api import detect_api +from conan.internal.api.detect import detect_api from conan.test.assets.genconanfile import GenConanfile from conan.test.utils.test_files import temp_folder from conans.util.files import save, load @@ -134,7 +134,7 @@ def test_new_config_file(client): assert "[conf] Either 'cache:read_only' does not exist in configuration list" in client.out -@patch("conans.client.conf.required_version.client_version", "1.26.0") +@patch("conans.model.version_range.client_version", "1.26.0") def test_new_config_file_required_version(): client = TestClient() conf = textwrap.dedent("""\ diff --git a/test/integration/configuration/required_version_test.py b/test/integration/configuration/required_version_test.py index d4a92fa1102..eb69db7cba1 100644 --- a/test/integration/configuration/required_version_test.py +++ b/test/integration/configuration/required_version_test.py @@ -11,7 +11,7 @@ class RequiredVersionTest(unittest.TestCase): - @mock.patch("conans.client.conf.required_version.client_version", "1.26.0") + @mock.patch("conans.model.version_range.client_version", "1.26.0") def test_wrong_version(self): required_version = "1.23.0" client = TestClient() @@ -20,21 +20,21 @@ def test_wrong_version(self): self.assertIn("Current Conan version (1.26.0) does not satisfy the defined " "one ({})".format(required_version), client.out) - @mock.patch("conans.client.conf.required_version.client_version", "1.22.0") + @mock.patch("conans.model.version_range.client_version", "1.22.0") def test_exact_version(self): required_version = "1.22.0" client = TestClient() client.save_home({"global.conf": f"core:required_conan_version={required_version}"}) client.run("--help") - @mock.patch("conans.client.conf.required_version.client_version", "2.1.0") + @mock.patch("conans.model.version_range.client_version", "2.1.0") def test_lesser_version(self): required_version = "<3.0" client = TestClient() client.save_home({"global.conf": f"core:required_conan_version={required_version}"}) client.run("--help") - @mock.patch("conans.client.conf.required_version.client_version", "1.0.0") + @mock.patch("conans.model.version_range.client_version", "1.0.0") def test_greater_version(self): required_version = ">0.1.0" client = TestClient() diff --git a/test/integration/graph/core/graph_manager_base.py b/test/integration/graph/core/graph_manager_base.py index 7f4ac1f73c3..7303cb6bc69 100644 --- a/test/integration/graph/core/graph_manager_base.py +++ b/test/integration/graph/core/graph_manager_base.py @@ -7,7 +7,7 @@ from conan.api.conan_api import ConanAPI from conan.internal.cache.cache import PkgCache from conan.internal.cache.home_paths import HomePaths -from conans.client.conf import default_settings_yml +from conan.internal.default_settings import default_settings_yml from conans.model.conf import ConfDefinition from conans.model.manifest import FileTreeManifest from conans.model.options import Options diff --git a/test/unittests/client/build/cpp_std_flags_test.py b/test/unittests/client/build/cpp_std_flags_test.py index c57948be77c..e4318082b1a 100644 --- a/test/unittests/client/build/cpp_std_flags_test.py +++ b/test/unittests/client/build/cpp_std_flags_test.py @@ -1,6 +1,6 @@ import unittest -from conan.internal.api.detect_api import default_cppstd +from conan.internal.api.detect.detect_api import default_cppstd from conan.tools.build import cppstd_flag from conans.model.version import Version from conan.test.utils.mocks import MockSettings, ConanFileMock diff --git a/test/unittests/client/conf/detect/test_gcc_compiler.py b/test/unittests/client/conf/detect/test_gcc_compiler.py index dd8cc5e80b4..b7059c600b9 100644 --- a/test/unittests/client/conf/detect/test_gcc_compiler.py +++ b/test/unittests/client/conf/detect/test_gcc_compiler.py @@ -4,7 +4,7 @@ from parameterized import parameterized -from conan.internal.api.detect_api import detect_gcc_compiler +from conan.internal.api.detect.detect_api import detect_gcc_compiler class GCCCompilerTestCase(unittest.TestCase): @@ -12,7 +12,7 @@ class GCCCompilerTestCase(unittest.TestCase): @parameterized.expand([("10",), ("4.2",), ('7', )]) def test_detect_gcc_10(self, version): with mock.patch("platform.system", return_value="Linux"): - with mock.patch("conan.internal.api.detect_api.detect_runner", return_value=(0, version)): + with mock.patch("conan.internal.api.detect.detect_api.detect_runner", return_value=(0, version)): compiler, installed_version, compiler_exe = detect_gcc_compiler() self.assertEqual(compiler, 'gcc') self.assertEqual(installed_version, version) diff --git a/test/unittests/client/profile_loader/compiler_cppstd_test.py b/test/unittests/client/profile_loader/compiler_cppstd_test.py index baaaa33e04b..af73239e1f5 100644 --- a/test/unittests/client/profile_loader/compiler_cppstd_test.py +++ b/test/unittests/client/profile_loader/compiler_cppstd_test.py @@ -7,8 +7,8 @@ from conan.internal.cache.cache import PkgCache from conan.internal.cache.home_paths import HomePaths -from conans.client.conf import default_settings_yml from conan.internal.api.profile.profile_loader import ProfileLoader +from conan.internal.default_settings import default_settings_yml from conans.errors import ConanException from conans.model.conf import ConfDefinition from conans.model.settings import Settings diff --git a/test/unittests/model/settings_test.py b/test/unittests/model/settings_test.py index da418033cb9..93c9adaf0b6 100644 --- a/test/unittests/model/settings_test.py +++ b/test/unittests/model/settings_test.py @@ -3,7 +3,7 @@ import pytest -from conans.client.conf import default_settings_yml +from conan.internal.default_settings import default_settings_yml from conans.errors import ConanException from conans.model.settings import Settings, bad_value_msg, undefined_field diff --git a/test/unittests/tools/build/test_cppstd.py b/test/unittests/tools/build/test_cppstd.py index 62c6176256a..943a64288c1 100644 --- a/test/unittests/tools/build/test_cppstd.py +++ b/test/unittests/tools/build/test_cppstd.py @@ -1,6 +1,6 @@ import pytest -from conan.internal.api.detect_api import detect_cppstd +from conan.internal.api.detect.detect_api import detect_cppstd from conan.tools.build import supported_cppstd, check_min_cppstd, valid_min_cppstd from conans.errors import ConanException, ConanInvalidConfiguration from conans.model.version import Version diff --git a/test/unittests/tools/cmake/test_cmake_install.py b/test/unittests/tools/cmake/test_cmake_install.py index 48308d6f295..8460406061d 100644 --- a/test/unittests/tools/cmake/test_cmake_install.py +++ b/test/unittests/tools/cmake/test_cmake_install.py @@ -1,6 +1,6 @@ +from conan.internal.default_settings import default_settings_yml from conan.tools.cmake import CMake from conan.tools.cmake.presets import write_cmake_presets -from conans.client.conf import get_default_settings_yml from conans.model.conf import Conf from conans.model.settings import Settings from conan.test.utils.mocks import ConanFileMock @@ -13,7 +13,7 @@ def test_run_install_component(): Issue related: https://github.com/conan-io/conan/issues/10359 """ # Load some generic windows settings - settings = Settings.loads(get_default_settings_yml()) + settings = Settings.loads(default_settings_yml) settings.os = "Windows" settings.arch = "x86" settings.build_type = "Release" @@ -42,7 +42,7 @@ def test_run_install_strip(): Issue related: https://github.com/conan-io/conan/issues/14166 """ - settings = Settings.loads(get_default_settings_yml()) + settings = Settings.loads(default_settings_yml) settings.os = "Linux" settings.arch = "x86_64" settings.build_type = "Release" @@ -71,7 +71,7 @@ def test_run_install_cli_args(): Issue related: https://github.com/conan-io/conan/issues/14235 """ - settings = Settings.loads(get_default_settings_yml()) + settings = Settings.loads(default_settings_yml) settings.os = "Linux" settings.arch = "x86_64" settings.build_type = "Release" @@ -99,7 +99,7 @@ def test_run_install_cli_args_strip(): Issue related: https://github.com/conan-io/conan/issues/14235 """ - settings = Settings.loads(get_default_settings_yml()) + settings = Settings.loads(default_settings_yml) settings.os = "Linux" settings.arch = "x86_64" settings.build_type = "Release" diff --git a/test/unittests/tools/cmake/test_cmake_test.py b/test/unittests/tools/cmake/test_cmake_test.py index aab3e284edc..901fb3f451b 100644 --- a/test/unittests/tools/cmake/test_cmake_test.py +++ b/test/unittests/tools/cmake/test_cmake_test.py @@ -1,8 +1,8 @@ import pytest +from conan.internal.default_settings import default_settings_yml from conan.tools.cmake import CMake from conan.tools.cmake.presets import write_cmake_presets -from conans.client.conf import get_default_settings_yml from conans.model.conf import Conf from conans.model.settings import Settings from conan.test.utils.mocks import ConanFileMock @@ -23,7 +23,7 @@ def test_run_tests(generator, target): multi-config ones. Issue related: https://github.com/conan-io/conan/issues/11405 """ - settings = Settings.loads(get_default_settings_yml()) + settings = Settings.loads(default_settings_yml) settings.os = "Windows" settings.arch = "x86" settings.build_type = "Release" @@ -46,7 +46,7 @@ def test_run_tests(generator, target): def test_cli_args_configure(): - settings = Settings.loads(get_default_settings_yml()) + settings = Settings.loads(default_settings_yml) conanfile = ConanFileMock() conanfile.conf = Conf() diff --git a/test/unittests/tools/cmake/test_cmaketoolchain.py b/test/unittests/tools/cmake/test_cmaketoolchain.py index 0420540f73a..25ffb110429 100644 --- a/test/unittests/tools/cmake/test_cmaketoolchain.py +++ b/test/unittests/tools/cmake/test_cmaketoolchain.py @@ -4,9 +4,9 @@ from mock import Mock from conan import ConanFile +from conan.internal.default_settings import default_settings_yml from conan.tools.cmake import CMakeToolchain from conan.tools.cmake.toolchain.blocks import Block -from conans.client.conf import get_default_settings_yml from conans.errors import ConanException from conans.model.conf import Conf from conans.model.options import Options @@ -533,7 +533,7 @@ def test_fpic_enabled(conanfile_linux_fpic): def test_libcxx_abi_flag(): c = ConanFile() c.settings = "os", "compiler", "build_type", "arch" - c.settings = Settings.loads(get_default_settings_yml()) + c.settings = Settings.loads(default_settings_yml) c.settings.build_type = "Release" c.settings.arch = "x86_64" c.settings.compiler = "gcc" @@ -581,7 +581,7 @@ def test_apple_cmake_osx_sysroot(os, os_sdk, arch, expected_sdk): """ c = ConanFile() c.settings = "os", "compiler", "build_type", "arch" - c.settings = Settings.loads(get_default_settings_yml()) + c.settings = Settings.loads(default_settings_yml) c.settings.os = os if os_sdk: c.settings.os.sdk = os_sdk @@ -615,7 +615,7 @@ def test_apple_cmake_osx_sysroot_sdk_mandatory(os, arch, expected_sdk): """ c = ConanFile() c.settings = "os", "compiler", "build_type", "arch" - c.settings = Settings.loads(get_default_settings_yml()) + c.settings = Settings.loads(default_settings_yml) c.settings.os = os c.settings.build_type = "Release" c.settings.arch = arch diff --git a/test/unittests/util/detect_libc_test.py b/test/unittests/util/detect_libc_test.py index c6106d4cc17..c0a8160a03a 100644 --- a/test/unittests/util/detect_libc_test.py +++ b/test/unittests/util/detect_libc_test.py @@ -1,6 +1,6 @@ from parameterized import parameterized -from conan.internal.api.detect_api import _parse_gnu_libc, _parse_musl_libc +from conan.internal.api.detect.detect_api import _parse_gnu_libc, _parse_musl_libc class TestDetectLibc: diff --git a/test/unittests/util/detect_test.py b/test/unittests/util/detect_test.py index 0309715e813..654a27c75e2 100644 --- a/test/unittests/util/detect_test.py +++ b/test/unittests/util/detect_test.py @@ -5,7 +5,7 @@ import pytest from parameterized import parameterized -from conan.internal.api.detect_api import _cc_compiler +from conan.internal.api.detect.detect_api import _cc_compiler from conan.internal.api.profile.detect import detect_defaults_settings from conans.model.version import Version from conan.test.utils.mocks import RedirectedTestOutput @@ -29,7 +29,7 @@ def test_detect_aix(self, processor, bitness, version, expected_arch): with mock.patch("platform.machine", mock.MagicMock(return_value='XXXXXXXXXXXX')), \ mock.patch("platform.processor", mock.MagicMock(return_value=processor)), \ mock.patch("platform.system", mock.MagicMock(return_value='AIX')), \ - mock.patch("conan.internal.api.detect_api._get_aix_conf", mock.MagicMock(return_value=bitness)), \ + mock.patch("conan.internal.api.detect.detect_api._get_aix_conf", mock.MagicMock(return_value=bitness)), \ mock.patch('subprocess.check_output', mock.MagicMock(return_value=version)): result = detect_defaults_settings() result = dict(result) @@ -51,7 +51,7 @@ def test_detect_arch(self, machine, expected_arch): result = dict(result) self.assertEqual(expected_arch, result['arch']) - @mock.patch("conan.internal.api.detect_api.detect_clang_compiler", + @mock.patch("conan.internal.api.detect.detect_api.detect_clang_compiler", return_value=("clang", Version("9"), "clang")) def test_detect_clang_gcc_toolchain(self, _): output = RedirectedTestOutput() @@ -69,7 +69,7 @@ def test_detect_clang_gcc_toolchain(self, _): ["clang version 18 (https://github.com/llvm/llvm-project.git 461274b81d8641eab64d494accddc81d7db8a09e)", "18"], ["cc.exe (Rev3, Built by MSYS2 project) 14", "14"], ]) -@patch("conan.internal.api.detect_api.detect_runner") +@patch("conan.internal.api.detect.detect_api.detect_runner") def test_detect_cc_versionings(detect_runner_mock, version_return, expected_version): detect_runner_mock.return_value = 0, version_return compiler, installed_version, compiler_exe = _cc_compiler() diff --git a/test/unittests/util/detected_architecture_test.py b/test/unittests/util/detected_architecture_test.py index 99bed7e39b6..5db15b92824 100644 --- a/test/unittests/util/detected_architecture_test.py +++ b/test/unittests/util/detected_architecture_test.py @@ -3,7 +3,7 @@ from parameterized import parameterized -from conan.internal.api.detect_api import detect_arch +from conan.internal.api.detect.detect_api import detect_arch class DetectedArchitectureTest(unittest.TestCase): @@ -41,14 +41,14 @@ def test_aix(self): with mock.patch("platform.machine", mock.MagicMock(return_value='00FB91F44C00')),\ mock.patch("platform.processor", mock.MagicMock(return_value='powerpc')),\ mock.patch("platform.system", mock.MagicMock(return_value='AIX')),\ - mock.patch("conan.internal.api.detect_api._get_aix_conf", mock.MagicMock(return_value='32')),\ + mock.patch("conan.internal.api.detect.detect_api._get_aix_conf", mock.MagicMock(return_value='32')),\ mock.patch('subprocess.check_output', mock.MagicMock(return_value='7.1.0.0')): self.assertEqual('ppc32', detect_arch()) with mock.patch("platform.machine", mock.MagicMock(return_value='00FB91F44C00')),\ mock.patch("platform.processor", mock.MagicMock(return_value='powerpc')),\ mock.patch("platform.system", mock.MagicMock(return_value='AIX')),\ - mock.patch("conan.internal.api.detect_api._get_aix_conf", mock.MagicMock(return_value='64')),\ + mock.patch("conan.internal.api.detect.detect_api._get_aix_conf", mock.MagicMock(return_value='64')),\ mock.patch('subprocess.check_output', mock.MagicMock(return_value='7.1.0.0')): self.assertEqual('ppc64', detect_arch()) From d54f555d8be9d74c1e0cd2fd99fc1e07c4112972 Mon Sep 17 00:00:00 2001 From: James Date: Mon, 16 Sep 2024 07:59:03 +0200 Subject: [PATCH 09/12] Fix/bash path slash (#16997) * fix bash_path slashes * test * fix test --- conans/client/subsystems.py | 1 + test/conftest.py | 2 +- test/functional/toolchains/gnu/autotools/test_win_bash.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/conans/client/subsystems.py b/conans/client/subsystems.py index ac7ca25c79d..39654b14719 100644 --- a/conans/client/subsystems.py +++ b/conans/client/subsystems.py @@ -72,6 +72,7 @@ def _windows_bash_wrapper(conanfile, command, env, envfiles_folder): if not shell_path: raise ConanException("The config 'tools.microsoft.bash:path' is " "needed to run commands in a Windows subsystem") + shell_path = shell_path.replace("\\", "/") # Should work in all terminals env = env or [] if subsystem == MSYS2: # Configure MSYS2 to inherith the PATH diff --git a/test/conftest.py b/test/conftest.py index 3d169ce3540..b9bc9ff5887 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -132,7 +132,7 @@ "platform": "Windows", "default": "system", "exe": "make", - "system": {"path": {'Windows': "C:/msys64/usr/bin"}}, + "system": {"path": {'Windows': r"C:\msys64\usr\bin"}}, }, 'msys2_clang64': { "disabled": True, diff --git a/test/functional/toolchains/gnu/autotools/test_win_bash.py b/test/functional/toolchains/gnu/autotools/test_win_bash.py index ddfc375aba7..d26647fced2 100644 --- a/test/functional/toolchains/gnu/autotools/test_win_bash.py +++ b/test/functional/toolchains/gnu/autotools/test_win_bash.py @@ -121,7 +121,7 @@ class Recipe(ConanFile): def package_info(self): self.conf_info.define("tools.microsoft.bash:subsystem", "msys2") - self.conf_info.define("tools.microsoft.bash:path", "{}") + self.conf_info.define("tools.microsoft.bash:path", r"{}") """.format(bash_path)) client.save({"conanfile.py": conanfile}) client.run("create .") From bd7dcc85e8d80773a007d63270e6e3d5be7b5839 Mon Sep 17 00:00:00 2001 From: James Date: Mon, 16 Sep 2024 16:05:12 +0200 Subject: [PATCH 10/12] Feature/config list pattern (#17000) * config list * config list --- conan/cli/commands/config.py | 10 ++++++++-- test/integration/command/config_test.py | 7 +++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/conan/cli/commands/config.py b/conan/cli/commands/config.py index 3df9b16466d..51b18fbb951 100644 --- a/conan/cli/commands/config.py +++ b/conan/cli/commands/config.py @@ -104,8 +104,14 @@ def config_list(conan_api, parser, subparser, *args): """ Show all the Conan available configurations: core and tools. """ - parser.parse_args(*args) - return conan_api.config.builtin_confs + subparser.add_argument('pattern', nargs="?", + help="Filter configuration items that matches this pattern") + args = parser.parse_args(*args) + confs = conan_api.config.builtin_confs + if args.pattern: + p = args.pattern.lower() + confs = {k: v for k, v in confs.items() if p in k.lower() or p in v.lower()} + return confs @conan_subcommand(formatters={"text": list_text_formatter, "json": default_json_formatter}) diff --git a/test/integration/command/config_test.py b/test/integration/command/config_test.py index 6ad53289379..04b749a4728 100644 --- a/test/integration/command/config_test.py +++ b/test/integration/command/config_test.py @@ -48,8 +48,10 @@ def test_config_list(): client.run("config list --format=json") assert f"{json.dumps(BUILT_IN_CONFS, indent=4)}\n" == client.stdout - client.run("config list unexpectedarg", assert_error=True) - assert "unrecognized arguments: unexpectedarg" in client.out + client.run("config list cmake") + assert "tools.cmake:cmake_program: Path to CMake executable" in client.out + assert "core.download:parallel" not in client.out + assert "tools.build:verbosity" not in client.out def test_config_install(): @@ -85,6 +87,7 @@ def test_config_install_conanignore(): 'config_folder/tests/tester': '', 'config_folder/other_tests/tester2': '' }) + def _assert_config_exists(path): assert os.path.exists(os.path.join(tc.cache_folder, path)) From ab7fdf7c3d402238ceae2e691e987904f91fcce4 Mon Sep 17 00:00:00 2001 From: Olzhas Zhumabek Date: Mon, 16 Sep 2024 21:37:18 +0200 Subject: [PATCH 11/12] model.py: Fix typo --- conan/api/model.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conan/api/model.py b/conan/api/model.py index 1c3a93598ea..abc5ebc84e0 100644 --- a/conan/api/model.py +++ b/conan/api/model.py @@ -56,7 +56,7 @@ def __getitem__(self, name): try: return self.lists[name] except KeyError: - raise ConanException(f"'{name}' doesn't exist is package list") + raise ConanException(f"'{name}' doesn't exist in package list") def add(self, name, pkg_list): self.lists[name] = pkg_list From 71795621a800c25021f27ab1fe73c5eefadad04e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abril=20Rinc=C3=B3n=20Blanco?= Date: Wed, 18 Sep 2024 11:11:04 +0200 Subject: [PATCH 12/12] Add missing Apple OS releases (#17012) * Add missing Apple OS releases * CMake support for newer Apple OS versions --- conan/internal/default_settings.py | 25 +++++++++++++++---------- conan/tools/cmake/toolchain/blocks.py | 11 ++++++----- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/conan/internal/default_settings.py b/conan/internal/default_settings.py index 3987645642f..99bc04c3008 100644 --- a/conan/internal/default_settings.py +++ b/conan/internal/default_settings.py @@ -19,43 +19,48 @@ "13.0", "13.1", "13.2", "13.3", "13.4", "13.5", "13.6", "13.7", "14.0", "14.1", "14.2", "14.3", "14.4", "14.5", "14.6", "14.7", "14.8", "15.0", "15.1", "15.2", "15.3", "15.4", "15.5", "15.6", "16.0", "16.1", - "16.2", "16.3", "16.4", "16.5", "16.6", "17.0", "17.1", "17.2", "17.3", "17.4", "17.5"] + "16.2", "16.3", "16.4", "16.5", "16.6", "17.0", "17.1", "17.2", "17.3", "17.4", "17.5", + "18.0", "18.1"] sdk: ["iphoneos", "iphonesimulator"] sdk_version: [null, "11.3", "11.4", "12.0", "12.1", "12.2", "12.4", "13.0", "13.1", "13.2", "13.4", "13.5", "13.6", "13.7", "14.0", "14.1", "14.2", "14.3", "14.4", "14.5", "15.0", "15.2", "15.4", - "15.5", "16.0", "16.1", "16.2", "16.4", "17.0", "17.1", "17.2", "17.4", "17.5"] + "15.5", "16.0", "16.1", "16.2", "16.4", "17.0", "17.1", "17.2", "17.4", "17.5", + "18.0", "18.1"] watchOS: version: ["4.0", "4.1", "4.2", "4.3", "5.0", "5.1", "5.2", "5.3", "6.0", "6.1", "6.2", "7.0", "7.1", "7.2", "7.3", "7.4", "7.5", "7.6", "8.0", "8.1", "8.3", "8.4", "8.5", "8.6", "8.7", "9.0", "9.1", "9.2", "9.3", "9.4", "9.5", "9.6", - "10.0", "10.1", "10.2", "10.3", "10.4", "10.5"] + "10.0", "10.1", "10.2", "10.3", "10.4", "10.5", "11.0", "11.1"] sdk: ["watchos", "watchsimulator"] sdk_version: [null, "4.3", "5.0", "5.1", "5.2", "5.3", "6.0", "6.1", "6.2", "7.0", "7.1", "7.2", "7.4", "8.0", "8.0.1", "8.3", "8.5", "9.0", "9.1", - "9.4", "10.0", "10.1", "10.2", "10.4", "10.5"] + "9.4", "10.0", "10.1", "10.2", "10.4", "10.5", "11.0", "11.1"] tvOS: version: ["11.0", "11.1", "11.2", "11.3", "11.4", "12.0", "12.1", "12.2", "12.3", "12.4", "13.0", "13.2", "13.3", "13.4", "14.0", "14.2", "14.3", "14.4", "14.5", "14.6", "14.7", "15.0", "15.1", "15.2", "15.3", "15.4", "15.5", "15.6", "16.0", "16.1", "16.2", "16.3", "16.4", "16.5", "16.6", "17.0", "17.1", "17.2", "17.3", "17.4", - "17.5"] + "17.5", "18.0", "18.1"] sdk: ["appletvos", "appletvsimulator"] sdk_version: [null, "11.3", "11.4", "12.0", "12.1", "12.2", "12.4", "13.0", "13.1", "13.2", "13.4", "14.0", "14.2", "14.3", "14.5", "15.0", - "15.2", "15.4", "16.0", "16.1", "16.4", "17.0", "17.1", "17.2", "17.4", "17.5"] + "15.2", "15.4", "16.0", "16.1", "16.4", "17.0", "17.1", "17.2", "17.4", "17.5", + "18.0", "18.1"] visionOS: - version: ["1.0", "1.1", "1.2"] + version: ["1.0", "1.1", "1.2", "2.0", "2.1"] sdk: ["xros", "xrsimulator"] - sdk_version: [null, "1.0", "1.1", "1.2"] + sdk_version: [null, "1.0", "1.1", "1.2", "2.0", "2.1"] Macos: version: [null, "10.6", "10.7", "10.8", "10.9", "10.10", "10.11", "10.12", "10.13", "10.14", "10.15", "11.0", "11.1", "11.2", "11.3", "11.4", "11.5", "11.6", "11.7", "12.0", "12.1", "12.2", "12.3", "12.4", "12.5", "12.6", "12.7", "13.0", "13.1", "13.2", "13.3", "13.4", "13.5", "13.6", - "14.0", "14.1", "14.2", "14.3", "14.4", "14.5"] + "14.0", "14.1", "14.2", "14.3", "14.4", "14.5", "14.6", + "15.0", "15.1"] sdk_version: [null, "10.13", "10.14", "10.15", "11.0", "11.1", "11.3", "12.0", "12.1", - "12.3", "13.0", "13.1", "13.3", "14.0", "14.2", "14.4", "14.5"] + "12.3", "13.0", "13.1", "13.3", "14.0", "14.2", "14.4", "14.5", + "15.0", "15.1"] subsystem: null: catalyst: diff --git a/conan/tools/cmake/toolchain/blocks.py b/conan/tools/cmake/toolchain/blocks.py index cc24c45c44b..a493f8c443c 100644 --- a/conan/tools/cmake/toolchain/blocks.py +++ b/conan/tools/cmake/toolchain/blocks.py @@ -1014,26 +1014,27 @@ def _is_apple_cross_building(self): @staticmethod def _get_darwin_version(os_name, os_version): # version mapping from https://en.wikipedia.org/wiki/Darwin_(operating_system) + # but a more detailed version can be found in https://theapplewiki.com/wiki/Kernel version_mapping = { "Macos": { "10.6": "10", "10.7": "11", "10.8": "12", "10.9": "13", "10.10": "14", "10.11": "15", "10.12": "16", "10.13": "17", "10.14": "18", "10.15": "19", "11": "20", "12": "21", - "13": "22", "14": "23", + "13": "22", "14": "23", "15": "24" }, "iOS": { "7": "14", "8": "14", "9": "15", "10": "16", "11": "17", "12": "18", "13": "19", - "14": "20", "15": "21", "16": "22", "17": "23" + "14": "20", "15": "21", "16": "22", "17": "23", "18": "24" }, "watchOS": { "4": "17", "5": "18", "6": "19", "7": "20", - "8": "21", "9": "22", "10": "23" + "8": "21", "9": "22", "10": "23", "11": "24" }, "tvOS": { "11": "17", "12": "18", "13": "19", "14": "20", - "15": "21", "16": "22", "17": "23" + "15": "21", "16": "22", "17": "23", "18": "24" }, "visionOS": { - "1": "23" + "1": "23", "2": "24" } } os_version = Version(os_version).major if os_name != "Macos" or (os_name == "Macos" and Version(