nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: conan-io/conan
Pull request #16434 (2024-06-07 14:09:08)

Hotfix/cmaketoolchain fulldeploy
Changelog: Bugfix: Fixed regression in ``CMakeToolchain`` with ``--deployer=full_deploy`` creating wrong escaping.
Docs: Omit

Close https://github.com/conan-io/conan/issues/16432


Patch:
diff --git a/conan/tools/cmake/toolchain/blocks.py b/conan/tools/cmake/toolchain/blocks.py
index 34021ece8..6d15ac0b1 100644
--- a/conan/tools/cmake/toolchain/blocks.py
+++ b/conan/tools/cmake/toolchain/blocks.py
@@ -564,8 +564,8 @@ class FindFiles(Block):
         return host_runtime_dirs
 
     def _join_paths(self, paths):
-        paths = [relativize_path(p, self._conanfile, "${CMAKE_CURRENT_LIST_DIR}") for p in paths]
         paths = [p.replace('\\', '/').replace('$', '\\$').replace('"', '\\"') for p in paths]
+        paths = [relativize_path(p, self._conanfile, "${CMAKE_CURRENT_LIST_DIR}") for p in paths]
         return " ".join([f'"{p}"' for p in paths])
 
     def context(self):
diff --git a/setup.py b/setup.py
index 45d16b892..3c14b1b87 100644
--- a/setup.py
+++ b/setup.py
@@ -14,7 +14,7 @@ from os import path
 
 # The tests utils are used by conan-package-tools
 here = path.abspath(path.dirname(__file__))
-excluded_test_packages = ["test"]
+excluded_test_packages = ["test*"]
 
 
 def get_requires(filename):


Test patch:
diff --git a/test/integration/toolchains/cmake/test_cmaketoolchain.py b/test/integration/toolchains/cmake/test_cmaketoolchain.py
index c21b35ffc..457f6a2b3 100644
--- a/test/integration/toolchains/cmake/test_cmaketoolchain.py
+++ b/test/integration/toolchains/cmake/test_cmaketoolchain.py
@@ -1501,6 +1501,7 @@ def test_toolchain_keep_absolute_paths():
     presets = json.loads(c.load(user_presets["include"][0]))
     assert os.path.isabs(presets["configurePresets"][0]["toolchainFile"])
 
+
 def test_output_dirs_gnudirs_local_default():
     # https://github.com/conan-io/conan/issues/14733
     c = TestClient()
@@ -1630,3 +1631,18 @@ def test_toolchain_extra_variables():
     toolchain = client.load("conan_toolchain.cmake")
     assert 'set(CACHE_VAR_DEFAULT_DOC "hello world" CACHE PATH "CACHE_VAR_DEFAULT_DOC")' in toolchain
 
+
+def test_variables_wrong_scaping():
+    # https://github.com/conan-io/conan/issues/16432
+    c = TestClient()
+    c.save({"tool/conanfile.py": GenConanfile("tool", "0.1"),
+            "pkg/conanfile.txt": "[tool_requires]\ntool/0.1\n[generators]\nCMakeToolchain"})
+    c.run("create tool")
+    c.run("install pkg")
+    toolchain = c.load("pkg/conan_toolchain.cmake")
+    cache_folder = c.cache_folder.replace("\\", "/")
+    assert f'list(PREPEND CMAKE_PROGRAM_PATH "{cache_folder}' in toolchain
+
+    c.run("install pkg --deployer=full_deploy")
+    toolchain = c.load("pkg/conan_toolchain.cmake")
+    assert 'list(PREPEND CMAKE_PROGRAM_PATH "${CMAKE_CURRENT_LIST_DIR}/full_deploy' in toolchain
Repository: conan-io/conan
Pull request #16573 (2024-06-30 21:21:52)

Ensure msvc fallback does not ignore 194 binaries
Changelog: Bugfix: Ensure msvc cppstd fallback does not ignore 194 binaries
Docs: Omit

This is one of the alternatives, another one might be to test each factor in isolation too?

Closes https://github.com/conan-io/conan/issues/16564

memsharded: > This is one of the alternatives, another one might be to test each factor in isolation too?

Yes, I think the combinatorics is not complete, and the empty element of each factor should also be used for the combinations.
RubenRBS: Good catch. I've changed the fix to address what I think the underlying issue is, can discuss it later :)

Patch:
diff --git a/conans/client/graph/compatibility.py b/conans/client/graph/compatibility.py
index a23669c88..7805878c2 100644
--- a/conans/client/graph/compatibility.py
+++ b/conans/client/graph/compatibility.py
@@ -65,10 +65,10 @@ def cppstd_compat(conanfile):
         new_combinations = []
         for comb in combinations:
             for f in factor:
-                comb = comb.copy()
-                comb.update(f)
-                new_combinations.append(comb)
-        combinations = new_combinations
+                new_comb = comb.copy()
+                new_comb.update(f)
+                new_combinations.append(new_comb)
+        combinations.extend(new_combinations)
 
     ret = []
     for comb in combinations:


Test patch:
diff --git a/test/integration/package_id/compatible_test.py b/test/integration/package_id/compatible_test.py
index dca4e3c06..a931701fc 100644
--- a/test/integration/package_id/compatible_test.py
+++ b/test/integration/package_id/compatible_test.py
@@ -400,3 +400,21 @@ class TestNewCompatibility:
 
         c.run("install --requires=pdfium/2020.9 -pr=myprofile -s build_type=Debug")
         assert "missing. Using compatible package" in c.out
+
+    def test_compatibility_msvc_and_cppstd(self):
+        """msvc 194 would not find compatible packages built with same version but different cppstd
+        due to an issue in the msvc fallback compatibility rule."""
+        tc = TestClient()
+        profile = textwrap.dedent("""
+                   [settings]
+                   compiler=msvc
+                   compiler.version=194
+                   compiler.runtime=dynamic
+                   """)
+        tc.save({"dep/conanfile.py": GenConanfile("dep", "1.0").with_setting("compiler"),
+                 "conanfile.py": GenConanfile("app", "1.0").with_require("dep/1.0").with_setting("compiler"),
+                 "profile": profile})
+
+        tc.run("create dep -pr=profile -s compiler.cppstd=20")
+        tc.run("create . -pr=profile -s compiler.cppstd=17")
+        tc.assert_listed_binary({"dep/1.0": ("b6d26a6bc439b25b434113982791edf9cab4d004", "Cache")})
Repository: conan-io/conan
Pull request #16936 (2024-09-05 09:27:41)

improve error messages for broken 'list --graph' arguments
Changelog: Fix: Better error messages when ``conan list --graph=<graph-json-file>`` file has issues
Docs: Omit

Close https://github.com/conan-io/conan/issues/16921



Patch:
diff --git a/conan/api/model.py b/conan/api/model.py
index 3c606b060..1c3a93598 100644
--- a/conan/api/model.py
+++ b/conan/api/model.py
@@ -99,8 +99,13 @@ class MultiPackagesList:
     def load_graph(graphfile, graph_recipes=None, graph_binaries=None):
         if not os.path.isfile(graphfile):
             raise ConanException(f"Graph file not found: {graphfile}")
-        graph = json.loads(load(graphfile))
-        return MultiPackagesList._define_graph(graph, graph_recipes, graph_binaries)
+        try:
+            graph = json.loads(load(graphfile))
+            return MultiPackagesList._define_graph(graph, graph_recipes, graph_binaries)
+        except JSONDecodeError as e:
+            raise ConanException(f"Graph file invalid JSON: {graphfile}\n{e}")
+        except Exception as e:
+            raise ConanException(f"Graph file broken: {graphfile}\n{e}")
 
     @staticmethod
     def _define_graph(graph, graph_recipes=None, graph_binaries=None):


Test patch:
diff --git a/test/integration/command_v2/list_test.py b/test/integration/command_v2/list_test.py
index f6daf9d7b..63b167b92 100644
--- a/test/integration/command_v2/list_test.py
+++ b/test/integration/command_v2/list_test.py
@@ -43,6 +43,20 @@ class TestParamErrors:
         c.run("list * -p os=Linux", assert_error=True)
         assert "--package-query and --filter-xxx can only be done for binaries" in c.out
 
+    def test_graph_file_error(self):
+        # This can happen when reusing the same file in input and output
+        c = TestClient(light=True)
+        c.run("list --graph=graph.json", assert_error=True)
+        assert "ERROR: Graph file not found" in c.out
+        c.save({"graph.json": ""})
+        c.run("list --graph=graph.json", assert_error=True)
+        assert "ERROR: Graph file invalid JSON:" in c.out
+        text = b'\x2b\x2f\x76\x38J\xe2nis\xa7'
+        with open(os.path.join(c.current_folder, "graph.json"), 'wb') as handle:
+            handle.write(text)
+        c.run("list --graph=graph.json", assert_error=True)
+        assert "ERROR: Graph file broken" in c.out
+
 
 @pytest.fixture(scope="module")
 def client():
Repository: conan-io/conan
Pull request #17020 (2024-09-18 14:19:03)

redirect PkgConfig stderr
Changelog: Fix: Redirect the ``PkgConfig`` ``stderr`` to the exception raised.
Docs: Omit

Close https://github.com/conan-io/conan/issues/17013



Patch:
diff --git a/conan/internal/default_settings.py b/conan/internal/default_settings.py
index 99bc04c30..a8f752e91 100644
--- a/conan/internal/default_settings.py
+++ b/conan/internal/default_settings.py
@@ -120,7 +120,7 @@ compiler:
     clang:
         version: ["3.3", "3.4", "3.5", "3.6", "3.7", "3.8", "3.9", "4.0",
                   "5.0", "6.0", "7.0", "7.1",
-                  "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18"]
+                  "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19"]
         libcxx: [null, libstdc++, libstdc++11, libc++, c++_shared, c++_static]
         cppstd: [null, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17, 20, gnu20, 23, gnu23]
         runtime: [null, static, dynamic]
diff --git a/conan/tools/gnu/pkgconfig.py b/conan/tools/gnu/pkgconfig.py
index 9d053819d..fb911ba93 100644
--- a/conan/tools/gnu/pkgconfig.py
+++ b/conan/tools/gnu/pkgconfig.py
@@ -1,3 +1,4 @@
+import textwrap
 from io import StringIO
 
 from conan.tools.build import cmd_args_to_string
@@ -30,8 +31,13 @@ class PkgConfig:
             env.prepend_path("PKG_CONFIG_PATH", self._pkg_config_path)
         with env.vars(self._conanfile).apply():
             # This way we get the environment from ConanFile, from profile (default buildenv)
-            output = StringIO()
-            self._conanfile.run(command, stdout=output, quiet=True)
+            output, err = StringIO(), StringIO()
+            ret = self._conanfile.run(command, stdout=output, stderr=err, quiet=True,
+                                      ignore_errors=True)
+            if ret != 0:
+                raise ConanException(f"PkgConfig failed. Command: {command}\n"
+                                     f"    stdout:\n{textwrap.indent(output.getvalue(), '    ')}\n"
+                                     f"    stderr:\n{textwrap.indent(err.getvalue(), '    ')}\n")
         value = output.getvalue().strip()
         return value
 


Test patch:
diff --git a/test/functional/toolchains/gnu/test_pkg_config.py b/test/functional/toolchains/gnu/test_pkg_config.py
index 5b9105f25..6d972f4a1 100644
--- a/test/functional/toolchains/gnu/test_pkg_config.py
+++ b/test/functional/toolchains/gnu/test_pkg_config.py
@@ -24,6 +24,8 @@ class TestPkgConfig:
                 """)
         c.save({"conanfile.py": conanfile})
         c.run("install .", assert_error=True)
+        assert "PkgConfig failed. Command: pkg-config --libs-only-l something_that_not_exist " \
+               "--print-errors" in c.out
         assert "Package something_that_not_exist was not found" in c.out
 
     def test_pc(self):
Repository: conan-io/conan
Pull request #17174 (2024-10-16 13:23:22)

fix for test_requires required components
Changelog: Bugfix: Avoid raising an error for required components for ``test_requires`` also required as transitive ``requires``
Docs: Omit

Close https://github.com/conan-io/conan/issues/17164



Patch:
diff --git a/conans/model/requires.py b/conans/model/requires.py
index 7b312b40e..60021fd4d 100644
--- a/conans/model/requires.py
+++ b/conans/model/requires.py
@@ -254,6 +254,7 @@ class Requirement:
         self.transitive_libs = self.transitive_libs or other.transitive_libs
         if not other.test:
             self.test = False  # it it was previously a test, but also required by non-test
+        self.is_test = self.is_test or other.is_test
         # package_id_mode is not being propagated downstream. So it is enough to check if the
         # current require already defined it or not
         if self.package_id_mode is None:
@@ -344,6 +345,7 @@ class Requirement:
 
         if self.test:
             downstream_require.test = True
+        downstream_require.is_test = require.is_test
 
         # If the current one is resolving conflicts, the downstream one will be too
         downstream_require.force = require.force


Test patch:
diff --git a/test/integration/graph/test_test_requires.py b/test/integration/graph/test_test_requires.py
index f85391d9d..5342bc3ad 100644
--- a/test/integration/graph/test_test_requires.py
+++ b/test/integration/graph/test_test_requires.py
@@ -198,6 +198,38 @@ def test_requires_transitive_diamond_components():
     assert "libc/0.1: Created package" in c.out
 
 
+def test_requires_transitive_diamond_components_order():
+    """
+    like the above, but in different order
+     libc  --(test-requires)---> liba
+       |-----> libb -----------/
+    https://github.com/conan-io/conan/issues/17164
+    """
+    c = TestClient(light=True)
+    libc = textwrap.dedent("""
+        from conan import ConanFile
+        class LibC(ConanFile):
+            name = "libc"
+            version = "0.1"
+
+            def requirements(self):
+                self.test_requires("liba/1.0")
+                self.requires("libb/1.0")
+
+            def package_info(self):
+                 self.cpp_info.components["comp"].libs = ["libc"]
+                 self.cpp_info.components["comp"].requires.append("libb::libb")
+        """)
+    c.save({"liba/conanfile.py": GenConanfile("liba", "1.0"),
+            "libb/conanfile.py": GenConanfile("libb", "1.0").with_requires("liba/1.0"),
+            "libc/conanfile.py": libc})
+    c.run("create liba")
+    c.run("create libb")
+    c.run("create libc")
+    # This used to crash due to component not defined to liba
+    assert "libc/0.1: Created package" in c.out
+
+
 def test_test_requires_options():
     """ the default_options = {} values also propagate to ``test_requires()`` """
     c = TestClient(light=True)
Repository: conan-io/conan
Pull request #17251 (2024-10-30 11:03:21)

[Environment] Fixed if scope=None
Changelog: Bugfix: `deduce_subsystem` failed if `scope=None`
Docs: omit
Closes: https://github.com/conan-io/conan/issues/17249


Pending an improvement in UX.


Patch:
diff --git a/conans/client/subsystems.py b/conans/client/subsystems.py
index e5fe65eaf..e2d892a09 100644
--- a/conans/client/subsystems.py
+++ b/conans/client/subsystems.py
@@ -128,6 +128,7 @@ def deduce_subsystem(conanfile, scope):
     - Aggregation of envfiles: to map each aggregated path to the subsystem
     - unix_path: util for recipes
     """
+    scope = "build" if scope is None else scope  # let's assume build context if scope=None
     if scope.startswith("build"):
         the_os = conanfile.settings_build.get_safe("os")
         if the_os is None:


Test patch:
diff --git a/test/integration/toolchains/env/test_environment.py b/test/integration/toolchains/env/test_environment.py
new file mode 100644
index 000000000..549895753
--- /dev/null
+++ b/test/integration/toolchains/env/test_environment.py
@@ -0,0 +1,38 @@
+import platform
+import textwrap
+
+from conan.test.utils.tools import TestClient
+
+
+# TODO: Change this test when we refactor EnvVars. The UX leaves much to be desired
+def test_env_and_scope_none():
+    """
+    Check scope=None does not append foo=var to conan{build|run}.{bat|sh|ps1}
+
+    Issue: https://github.com/conan-io/conan/issues/17249
+    """
+    client = TestClient()
+    conanfile = textwrap.dedent("""
+        from conan import ConanFile
+        from conan.tools.env import Environment
+        class Pkg(ConanFile):
+            name = "pkg"
+            version = "0.1"
+            settings = "os", "compiler", "build_type", "arch"
+            def generate(self):
+                env1 = Environment()
+                env1.define("foo", "var")
+                # Will not append "my_env_file" to "conanbuild.bat|sh|ps1"
+                envvars = env1.vars(self, scope=None)
+                envvars.save_script("my_env_file")
+                # Let's check the apply() function
+                with env1.vars(self, scope=None).apply():
+                    import os
+                    assert os.environ["foo"] == "var"
+            """)
+    client.save({"conanfile.py": conanfile})
+    client.run("install .")
+    ext = ".bat" if platform.system() == "Windows" else ".sh"
+    assert "my_env_file" not in client.load(f"conanbuild{ext}")
+    assert "my_env_file" not in client.load(f"conanrun{ext}")
+
Repository: conan-io/conan
Pull request #17292 (2024-11-07 23:33:33)

fix CMake max_cpu_count
Changelog: Bugfix: Solve bug in ``CMake`` not using the correct value from ``tools.microsoft.msbuild:max_cpu_count``
Docs: Omit

Close https://github.com/conan-io/conan/issues/17290


Patch:
diff --git a/conan/tools/cmake/cmake.py b/conan/tools/cmake/cmake.py
index 2efa8f37a..a94bae711 100644
--- a/conan/tools/cmake/cmake.py
+++ b/conan/tools/cmake/cmake.py
@@ -20,7 +20,7 @@ def _cmake_cmd_line_args(conanfile, generator):
 
     maxcpucount = conanfile.conf.get("tools.microsoft.msbuild:max_cpu_count", check_type=int)
     if maxcpucount and "Visual Studio" in generator:
-        args.append("/m:{}".format(njobs))
+        args.append("/m:{}".format(maxcpucount))
 
     # Arguments for verbosity
     if "Visual Studio" in generator:
diff --git a/conan/tools/files/patches.py b/conan/tools/files/patches.py
index f3274f83f..5c35641d7 100644
--- a/conan/tools/files/patches.py
+++ b/conan/tools/files/patches.py
@@ -142,5 +142,7 @@ def export_conandata_patches(conanfile):
         if patch_file:
             src = os.path.join(conanfile.recipe_folder, patch_file)
             dst = os.path.join(conanfile.export_sources_folder, patch_file)
+            if not os.path.exists(src):
+                raise ConanException(f"Patch file does not exist: '{src}'")
             mkdir(os.path.dirname(dst))
             shutil.copy2(src, dst)


Test patch:
diff --git a/test/functional/tools/test_files.py b/test/functional/tools/test_files.py
index 604654ae5..44b0c2748 100644
--- a/test/functional/tools/test_files.py
+++ b/test/functional/tools/test_files.py
@@ -407,7 +407,7 @@ def test_export_conandata_patches(mock_patch_ng):
     # No patch found
     client.save({"conandata.yml": conandata_yml})
     client.run("create .", assert_error=True)
-    assert "No such file or directory" in client.out
+    assert "Patch file does not exist: '" in client.out
 
     client.save({"patches/mypatch.patch": "mypatch!!!"})
     client.run("create .")
diff --git a/test/unittests/tools/cmake/test_cmake_cmd_line_args.py b/test/unittests/tools/cmake/test_cmake_cmd_line_args.py
index b1c7dd860..7aa8a2f20 100644
--- a/test/unittests/tools/cmake/test_cmake_cmd_line_args.py
+++ b/test/unittests/tools/cmake/test_cmake_cmd_line_args.py
@@ -12,6 +12,7 @@ def conanfile():
     c = ConfDefinition()
     c.loads(textwrap.dedent("""\
         tools.build:jobs=10
+        tools.microsoft.msbuild:max_cpu_count=23
     """))
 
     conanfile = ConanFileMock()
@@ -39,7 +40,7 @@ def test_ninja(conanfile):
 
 def test_visual_studio(conanfile):
     args = _cmake_cmd_line_args(conanfile, 'Visual Studio 16 2019')
-    assert [] == args
+    assert ["/m:23"] == args
 
     args = _cmake_cmd_line_args(conanfile, 'Ninja')
     assert args == ['-j10']
Repository: conan-io/conan
Pull request #17294 (2024-11-08 07:09:50)

Raise ConanException if source patch does not exist in export_conandata_patches
Changelog: Feature: Raise ConanException if source patch does not exist in `export_conandata_patches`. 
Docs: Omit

Trying to fix tests that fail in Python 3.13: https://github.com/conan-io/conan/pull/17205

I found that now the error thrown by shutil.copy2 [has changed in Windows](https://github.com/python/cpython/commit/cda1bd3c9d3b2cecdeeba0c498cd2df83fbdb535). So if the source patch does not exist now the error is different.

It was like this:

```
FileNotFoundError: [Errno 2] No such file or directory: '/private/var/folders/hr/t3_1lzj9145g383b4zyj67d40000gn/T/tmpjqj9cq99conans/path with spaces/patches/mypatch.patch'
```

now it's like this:

```
FileNotFoundError: [WinError 3] The system cannot find the path specified
```


So I think it would be better to throw that error ourselves si that we always output a meaningful message:

```
ConanException: Patch file does not exist: '/private/var/folders/hr/t3_1lzj9145g383b4zyj67d40000gn/T/tmpuewtmlhpconans/path with spaces/patches/mypatch.patch'
```




Patch:
diff --git a/conan/tools/files/patches.py b/conan/tools/files/patches.py
index f3274f83f..5c35641d7 100644
--- a/conan/tools/files/patches.py
+++ b/conan/tools/files/patches.py
@@ -142,5 +142,7 @@ def export_conandata_patches(conanfile):
         if patch_file:
             src = os.path.join(conanfile.recipe_folder, patch_file)
             dst = os.path.join(conanfile.export_sources_folder, patch_file)
+            if not os.path.exists(src):
+                raise ConanException(f"Patch file does not exist: '{src}'")
             mkdir(os.path.dirname(dst))
             shutil.copy2(src, dst)


Test patch:
diff --git a/test/functional/tools/test_files.py b/test/functional/tools/test_files.py
index 604654ae5..44b0c2748 100644
--- a/test/functional/tools/test_files.py
+++ b/test/functional/tools/test_files.py
@@ -407,7 +407,7 @@ def test_export_conandata_patches(mock_patch_ng):
     # No patch found
     client.save({"conandata.yml": conandata_yml})
     client.run("create .", assert_error=True)
-    assert "No such file or directory" in client.out
+    assert "Patch file does not exist: '" in client.out
 
     client.save({"patches/mypatch.patch": "mypatch!!!"})
     client.run("create .")