From 4760de0f827c812ee9a0984c51e557b024642f11 Mon Sep 17 00:00:00 2001 From: czoido Date: Mon, 6 Sep 2021 10:57:15 +0200 Subject: [PATCH 1/6] update 1.41.0 dev version --- conans/__init__.py | 2 +- conans/client/migrations_settings.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/conans/__init__.py b/conans/__init__.py index e3b5488172e..c88647a598e 100644 --- a/conans/__init__.py +++ b/conans/__init__.py @@ -20,4 +20,4 @@ SERVER_CAPABILITIES = [COMPLEX_SEARCH_CAPABILITY, REVISIONS] # Server is always with revisions DEFAULT_REVISION_V1 = "0" -__version__ = '1.40.0-dev' +__version__ = '1.41.0-dev' diff --git a/conans/client/migrations_settings.py b/conans/client/migrations_settings.py index e7f0584e5d6..cd67439c960 100644 --- a/conans/client/migrations_settings.py +++ b/conans/client/migrations_settings.py @@ -2430,3 +2430,5 @@ cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17, 20, gnu20, 23, gnu23] # Deprecated, use compiler.cppstd """ + +settings_1_41_0 = settings_1_40_0 From 089e56b5bfd316ea0cb43395bb5b72c50808744e Mon Sep 17 00:00:00 2001 From: Luis Martinez de Bartolome Izquierdo Date: Tue, 7 Sep 2021 13:52:36 +0200 Subject: [PATCH 2/6] Export to base src and test with git clone (#9536) * Export to base src and test with git clone * Windows test * use init git repo --- conans/client/source.py | 5 +-- .../test/functional/layout/test_in_cache.py | 34 +++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/conans/client/source.py b/conans/client/source.py index 77b42264a0a..b1bd03204f3 100644 --- a/conans/client/source.py +++ b/conans/client/source.py @@ -105,7 +105,7 @@ def get_sources_from_exports(): # First of all get the exported scm sources (if auto) or clone (if fixed) _run_cache_scm(conanfile, scm_sources_folder, output) # so self exported files have precedence over python_requires ones - merge_directories(export_folder, conanfile.source_folder) + merge_directories(export_folder, conanfile.folders.base_source) # Now move the export-sources to the right location merge_directories(export_source_folder, conanfile.folders.base_source) @@ -139,7 +139,8 @@ def _run_source(conanfile, conanfile_path, hook_manager, reference, cache, get_sources_from_exports() if cache: - _clean_source_folder(src_folder) # TODO: Why is it needed in cache? + # Clear the conanfile.py to avoid errors cloning git repositories. + _clean_source_folder(src_folder) with conanfile_exception_formatter(conanfile.display_name, "source"): with conan_v2_property(conanfile, 'settings', diff --git a/conans/test/functional/layout/test_in_cache.py b/conans/test/functional/layout/test_in_cache.py index f731d8f40c7..646626bc9f8 100644 --- a/conans/test/functional/layout/test_in_cache.py +++ b/conans/test/functional/layout/test_in_cache.py @@ -7,6 +7,7 @@ from conans import load from conans.model.ref import ConanFileReference, PackageReference from conans.test.assets.genconanfile import GenConanfile +from conans.test.utils.test_files import temp_folder from conans.test.utils.tools import TestClient @@ -270,3 +271,36 @@ def generate(self): assert 'set(hello_INCLUDE_DIRS_RELEASE "${hello_PACKAGE_FOLDER_RELEASE}/foo/include")' in cmake assert 'set(hello_LIB_DIRS_RELEASE "${hello_PACKAGE_FOLDER_RELEASE}/foo/libs")' in cmake assert 'set(hello_LIBS_RELEASE foo)' in cmake + + +def test_git_clone_with_source_layout(): + client = TestClient() + repo = temp_folder() + conanfile = textwrap.dedent(""" + import os + from conans import ConanFile + class Pkg(ConanFile): + exports = "*.txt" + + def layout(self): + self.folders.source = "src" + + def source(self): + self.run('git clone "{}" src') + """).format(repo.replace("\\", "/")) + + client.save({"conanfile.py": conanfile, + "myfile.txt": "My file is copied"}) + with client.chdir(repo): + client.save({"cloned.txt": "foo"}, repo) + client.init_git_repo() + + client.run("create . hello/1.0@") + sf = client.cache.package_layout(ConanFileReference.loads("hello/1.0@")).source() + assert os.path.exists(os.path.join(sf, "myfile.txt")) + # The conanfile is cleared from the root before cloning + assert not os.path.exists(os.path.join(sf, "conanfile.py")) + assert not os.path.exists(os.path.join(sf, "cloned.txt")) + + assert os.path.exists(os.path.join(sf, "src", "cloned.txt")) + assert not os.path.exists(os.path.join(sf, "src", "myfile.txt")) From b93f661d2c968a54f5c55b17e4bd3b8e104d6b5b Mon Sep 17 00:00:00 2001 From: James Date: Thu, 9 Sep 2021 09:32:12 +0200 Subject: [PATCH 3/6] generate deactivate scripts by default in Env (#9539) --- conan/tools/env/environment.py | 6 +++--- conans/test/unittests/tools/env/test_env.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/conan/tools/env/environment.py b/conan/tools/env/environment.py index 9a07bc7156a..48bc157257d 100644 --- a/conan/tools/env/environment.py +++ b/conan/tools/env/environment.py @@ -194,7 +194,7 @@ def prepend_path(self, name, value): def remove(self, name, value): self._values[name].remove(value) - def save_bat(self, filename, generate_deactivate=False, pathsep=os.pathsep): + def save_bat(self, filename, generate_deactivate=True, pathsep=os.pathsep): deactivate = textwrap.dedent("""\ echo Capturing current environment in deactivate_{filename} setlocal @@ -228,7 +228,7 @@ def save_bat(self, filename, generate_deactivate=False, pathsep=os.pathsep): content = "\n".join(result) save(filename, content) - def save_ps1(self, filename, generate_deactivate=False, pathsep=os.pathsep): + def save_ps1(self, filename, generate_deactivate=True, pathsep=os.pathsep): # FIXME: This is broken and doesnt work deactivate = "" capture = textwrap.dedent("""\ @@ -242,7 +242,7 @@ def save_ps1(self, filename, generate_deactivate=False, pathsep=os.pathsep): content = "\n".join(result) save(filename, content) - def save_sh(self, filename, generate_deactivate=False, pathsep=os.pathsep): + def save_sh(self, filename, generate_deactivate=True, pathsep=os.pathsep): deactivate = textwrap.dedent("""\ echo Capturing current environment in deactivate_{filename} echo echo Restoring variables >> deactivate_{filename} diff --git a/conans/test/unittests/tools/env/test_env.py b/conans/test/unittests/tools/env/test_env.py index 8758892c10b..a33b3d5a23e 100644 --- a/conans/test/unittests/tools/env/test_env.py +++ b/conans/test/unittests/tools/env/test_env.py @@ -257,7 +257,7 @@ def check(cmd_): with chdir(folder): if platform.system() == "Windows": - env.save_bat("test.bat", pathsep=":", generate_deactivate=True) + env.save_bat("test.bat", pathsep=":") save("display.bat", display_bat) cmd = "test.bat && display.bat && deactivate_test.bat && display.bat" @@ -270,7 +270,7 @@ def check(cmd_): # stdout, stderr = decode_text(stdout), decode_text(stderr) # check(cmd) else: - env.save_sh("test.sh", pathsep=":", generate_deactivate=True) + env.save_sh("test.sh", pathsep=":") save("display.sh", display_sh) os.chmod("display.sh", 0o777) cmd = '. ./test.sh && ./display.sh && . ./deactivate_test.sh && ./display.sh' @@ -294,7 +294,7 @@ def test_windows_case_insensitive(): """) with chdir(folder): - env.save_bat("test.bat", generate_deactivate=True) + env.save_bat("test.bat") save("display.bat", display_bat) cmd = "test.bat && display.bat && deactivate_test.bat && display.bat" out, _ = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, From c426910bb51998415277c6cca2786ab08ee9a702 Mon Sep 17 00:00:00 2001 From: el-g-1 <85537082+el-g-1@users.noreply.github.com> Date: Thu, 9 Sep 2021 00:55:02 -0700 Subject: [PATCH 4/6] Support other types of remote archives (#9530) * Support other types of remote archives * Use tgz_with_contents() for test --- conans/client/conf/config_installer.py | 2 +- .../functional/command/config_install_test.py | 29 ++++++++++++++++++- conans/test/utils/test_files.py | 4 +-- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/conans/client/conf/config_installer.py b/conans/client/conf/config_installer.py index a2aae34fdb4..3c4a96e7ee4 100644 --- a/conans/client/conf/config_installer.py +++ b/conans/client/conf/config_installer.py @@ -137,7 +137,7 @@ def _process_folder(config, folder, cache, output): def _process_download(config, cache, output, requester): with tmp_config_install_folder(cache) as tmp_folder: output.info("Trying to download %s" % _hide_password(config.uri)) - zippath = os.path.join(tmp_folder, "config.zip") + zippath = os.path.join(tmp_folder, os.path.basename(config.uri)) try: tools.download(config.uri, zippath, out=output, verify=config.verify_ssl, requester=requester) diff --git a/conans/test/functional/command/config_install_test.py b/conans/test/functional/command/config_install_test.py index 3c751065259..4dc5315b8e3 100644 --- a/conans/test/functional/command/config_install_test.py +++ b/conans/test/functional/command/config_install_test.py @@ -1,6 +1,7 @@ import json import os import shutil +import tarfile import textwrap import time import unittest @@ -16,7 +17,7 @@ from conans.client.downloaders.file_downloader import FileDownloader from conans.errors import ConanException from conans.test.assets.genconanfile import GenConanfile -from conans.test.utils.test_files import temp_folder +from conans.test.utils.test_files import scan_folder, temp_folder, tgz_with_contents from conans.test.utils.tools import TestClient, StoppableThreadBottle, zipdir from conans.util.files import load, mkdir, save, save_files, make_file_read_only @@ -144,6 +145,21 @@ def _create_zip(self, zippath=None): zipdir(folder, zippath) return zippath + @staticmethod + def _get_files(folder): + relpaths = scan_folder(folder) + files = {} + for path in relpaths: + with open(os.path.join(folder, path), "r") as file_handle: + files[path] = file_handle.read() + return files + + def _create_tgz(self, tgz_path=None): + folder = self._create_profile_folder() + tgz_path = tgz_path or os.path.join(folder, "myconfig.tar.gz") + files = self._get_files(folder) + return tgz_with_contents(files, tgz_path) + def _check(self, params): typ, uri, verify, args = [p.strip() for p in params.split(",")] configs = json.loads(load(self.client.cache.config_install_file)) @@ -362,6 +378,17 @@ def my_download(obj, url, file_path, **kwargs): # @UnusedVariable self.client.run("config install http://myfakeurl.com/myconf.zip --verify-ssl=False") self._check("url, http://myfakeurl.com/myconf.zip, False, None") + def test_install_url_tgz(self): + """ should install from a URL to tar.gz + """ + + def my_download(obj, url, file_path, **kwargs): # @UnusedVariable + self._create_tgz(file_path) + + with patch.object(FileDownloader, 'download', new=my_download): + self.client.run("config install http://myfakeurl.com/myconf.tar.gz") + self._check("url, http://myfakeurl.com/myconf.tar.gz, True, None") + def test_failed_install_repo(self): """ should install from a git repo """ diff --git a/conans/test/utils/test_files.py b/conans/test/utils/test_files.py index cbba03f903a..c25aebc2628 100644 --- a/conans/test/utils/test_files.py +++ b/conans/test/utils/test_files.py @@ -73,9 +73,9 @@ def scan_folder(folder): return sorted(scanned_files) -def tgz_with_contents(files): +def tgz_with_contents(files, output_path=None): folder = temp_folder() - file_path = os.path.join(folder, "myfile.tar.gz") + file_path = output_path or os.path.join(folder, "myfile.tar.gz") with open(file_path, "wb") as tgz_handle: tgz = gzopen_without_timestamps("myfile.tar.gz", mode="w", fileobj=tgz_handle) From ff7b8e6703e8407773968517d68424b9ec59aa30 Mon Sep 17 00:00:00 2001 From: James Date: Thu, 9 Sep 2021 11:05:17 +0200 Subject: [PATCH 5/6] testing that cmake_paths functionality is covered by CMakeToolchain (#9538) * testing that cmake_paths functionality is covered by CMakeToolchain * add real helloConfig.cmake test * checking CMakeDeps has priority --- .../test_cmakedeps_custom_configs.py | 0 .../test_cmakedeps_find_module_and_config.py | 9 +- .../{ => cmake}/test_cmake_toolchain.py | 0 .../cmake/test_cmaketoolchain_paths.py | 131 ++++++++++++++++++ 4 files changed, 137 insertions(+), 3 deletions(-) rename conans/test/functional/toolchains/cmake/{ => cmakedeps}/test_cmakedeps_custom_configs.py (100%) rename conans/test/functional/toolchains/{ => cmake}/test_cmake_toolchain.py (100%) create mode 100644 conans/test/functional/toolchains/cmake/test_cmaketoolchain_paths.py diff --git a/conans/test/functional/toolchains/cmake/test_cmakedeps_custom_configs.py b/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_custom_configs.py similarity index 100% rename from conans/test/functional/toolchains/cmake/test_cmakedeps_custom_configs.py rename to conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_custom_configs.py diff --git a/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_find_module_and_config.py b/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_find_module_and_config.py index 6afdf5b3d22..f2e71ec6ba5 100644 --- a/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_find_module_and_config.py +++ b/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_find_module_and_config.py @@ -48,11 +48,14 @@ def package_info(self): self.cpp_info.set_property("cmake_module_file_name", "mi_dependencia") self.cpp_info.set_property("cmake_module_target_name", "mi_dependencia_target") - self.cpp_info.set_property("cmake_module_target_namespace", "mi_dependencia_namespace") + self.cpp_info.set_property("cmake_module_target_namespace", + "mi_dependencia_namespace") self.cpp_info.components["crispin"].libs = ["mydep"] - self.cpp_info.components["crispin"].set_property("cmake_target_name", "MyCrispinTarget") - self.cpp_info.components["crispin"].set_property("cmake_module_target_name", "mi_crispin_target") + self.cpp_info.components["crispin"].set_property("cmake_target_name", + "MyCrispinTarget") + self.cpp_info.components["crispin"].set_property("cmake_module_target_name", + "mi_crispin_target") """) t.save({"conanfile.py": conanfile, diff --git a/conans/test/functional/toolchains/test_cmake_toolchain.py b/conans/test/functional/toolchains/cmake/test_cmake_toolchain.py similarity index 100% rename from conans/test/functional/toolchains/test_cmake_toolchain.py rename to conans/test/functional/toolchains/cmake/test_cmake_toolchain.py diff --git a/conans/test/functional/toolchains/cmake/test_cmaketoolchain_paths.py b/conans/test/functional/toolchains/cmake/test_cmaketoolchain_paths.py new file mode 100644 index 00000000000..c8f6522e20d --- /dev/null +++ b/conans/test/functional/toolchains/cmake/test_cmaketoolchain_paths.py @@ -0,0 +1,131 @@ +import textwrap + +import pytest + +from conans.test.utils.tools import TestClient + + +@pytest.mark.tool_cmake +@pytest.mark.parametrize("package", ["hello", "ZLIB"]) +@pytest.mark.parametrize("find_package", ["module", "config"]) +def test_cmaketoolchain_path_find(package, find_package): + """Test with user "Hello" and also ZLIB one, to check that package ZLIB + has priority over the CMake system one + + Also, that user cmake files in the root are accessible via CMake include() + """ + client = TestClient() + conanfile = textwrap.dedent(""" + from conans import ConanFile + class TestConan(ConanFile): + exports = "*" + def layout(self): + pass + def package(self): + self.copy(pattern="*", keep_path=False) + """) + find = textwrap.dedent(""" + SET({package}_FOUND 1) + MESSAGE("HELLO FROM THE {package} FIND PACKAGE!") + """).format(package=package) + myowncmake = textwrap.dedent(""" + MESSAGE("MYOWNCMAKE FROM {package}!") + """).format(package=package) + + filename = "{}Config.cmake" if find_package == "config" else "Find{}.cmake" + filename = filename.format(package) + client.save({"conanfile.py": conanfile, + "{}".format(filename): find, + "myowncmake.cmake": myowncmake}) + client.run("create . {}/0.1@".format(package)) + + consumer = textwrap.dedent(""" + set(CMAKE_CXX_COMPILER_WORKS 1) + set(CMAKE_CXX_ABI_COMPILED 1) + project(MyHello CXX) + cmake_minimum_required(VERSION 3.15) + + find_package({package} REQUIRED) + include(myowncmake) + """).format(package=package) + + client.save({"CMakeLists.txt": consumer}, clean_first=True) + client.run("install {}/0.1@ -g CMakeToolchain".format(package)) + with client.chdir("build"): + client.run_command("cmake .. -DCMAKE_TOOLCHAIN_FILE=../conan_toolchain.cmake") + assert "Conan: Target declared" not in client.out + assert "HELLO FROM THE {package} FIND PACKAGE!".format(package=package) in client.out + assert "MYOWNCMAKE FROM {package}!".format(package=package) in client.out + + # If using the CMakeDeps generator, the in-package .cmake will be ignored + # But it is still possible to include(owncmake) + client.run("install {}/0.1@ -g CMakeToolchain -g CMakeDeps".format(package)) + with client.chdir("build2"): # A clean folder, not the previous one, CMake cache doesnt affect + client.run_command("cmake .. -DCMAKE_TOOLCHAIN_FILE=../conan_toolchain.cmake") + assert "Conan: Target declared '{package}::{package}'".format(package=package) in client.out + assert "HELLO FROM THE {package} FIND PACKAGE!".format(package=package) not in client.out + assert "MYOWNCMAKE FROM {package}!".format(package=package) in client.out + + +@pytest.mark.tool_cmake +def test_cmaketoolchain_path_find_real_config(): + client = TestClient() + conanfile = textwrap.dedent(""" + from conans import ConanFile + from conan.tools.cmake import CMake + class TestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + exports = "*" + generators = "CMakeToolchain" + + def layout(self): + pass + + def build(self): + cmake = CMake(self) + cmake.configure() + + def package(self): + cmake = CMake(self) + cmake.install() + """) + cmake = textwrap.dedent(""" + cmake_minimum_required(VERSION 3.15) + project(MyHello NONE) + + add_library(hello INTERFACE) + install(TARGETS hello EXPORT helloConfig) + export(TARGETS hello + NAMESPACE hello:: + FILE "${CMAKE_CURRENT_BINARY_DIR}/helloConfig.cmake" + ) + install(EXPORT helloConfig + DESTINATION "${CMAKE_INSTALL_PREFIX}/hello/cmake" + NAMESPACE hello:: + ) + """) + client.save({"conanfile.py": conanfile, + "CMakeLists.txt": cmake}) + client.run("create . hello/0.1@") + + consumer = textwrap.dedent(""" + project(MyHello NONE) + cmake_minimum_required(VERSION 3.15) + + find_package(hello REQUIRED) + """) + + client.save({"CMakeLists.txt": consumer}, clean_first=True) + client.run("install hello/0.1@ -g CMakeToolchain") + with client.chdir("build"): + client.run_command("cmake .. -DCMAKE_TOOLCHAIN_FILE=../conan_toolchain.cmake") + # If it didn't fail, it found the helloConfig.cmake + assert "Conan: Target declared" not in client.out + + # If using the CMakeDeps generator, the in-package .cmake will be ignored + # But it is still possible to include(owncmake) + client.run("install hello/0.1@ -g CMakeToolchain -g CMakeDeps") + with client.chdir("build2"): # A clean folder, not the previous one, CMake cache doesnt affect + client.run_command("cmake .. -DCMAKE_TOOLCHAIN_FILE=../conan_toolchain.cmake") + assert "Conan: Target declared 'hello::hello'" in client.out + From acfaf917a14f078c47202e3d823664ea72f57de6 Mon Sep 17 00:00:00 2001 From: James Date: Fri, 10 Sep 2021 13:35:52 +0200 Subject: [PATCH 6/6] removing unused __future__ lib (#9563) --- conans/requirements.txt | 1 - pyinstaller.py | 2 -- 2 files changed, 3 deletions(-) diff --git a/conans/requirements.txt b/conans/requirements.txt index 3a9618d72b4..458ca1f8e03 100644 --- a/conans/requirements.txt +++ b/conans/requirements.txt @@ -8,7 +8,6 @@ fasteners>=0.14.1 six>=1.10.0,<=1.16.0 node-semver==0.6.1 distro>=1.0.2, <=1.6.0 -future>=0.16.0, <0.19.0 pygments>=2.0, <3.0 tqdm>=4.28.1, <5 Jinja2>=2.9, <3 diff --git a/pyinstaller.py b/pyinstaller.py index 32d49525c9b..d0d469a0e94 100644 --- a/pyinstaller.py +++ b/pyinstaller.py @@ -1,5 +1,3 @@ -from __future__ import print_function - import os import platform import shutil