nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: StingraySoftware/stingray
Pull request #363 (2018-09-20 21:34:33)

Added `tstart` keyword to `simulator`
All light curves created by the `Simulator` class start at zero by default. I just simulated a bunch of time lags, and it was kind of annoying that they were all shifted compared to my actual data, so I added a `tstart` keyword. Thoughts?


Patch:
diff --git a/stingray/simulator/simulator.py b/stingray/simulator/simulator.py
index b1e70f4f..0cb5746a 100644
--- a/stingray/simulator/simulator.py
+++ b/stingray/simulator/simulator.py
@@ -33,14 +33,15 @@ class Simulator(object):
     """
 
     def __init__(self, dt=1, N=1024, mean=0, rms=1, red_noise=1,
-                 random_state=None):
+                 random_state=None, tstart=0.0):
 
         self.dt = dt
         self.N = N
         self.mean = mean
         self.rms = rms
         self.red_noise = red_noise
-        self.time = dt*np.arange(N)
+        self.tstart = tstart
+        self.time = dt*np.arange(N) + self.tstart
 
         # Initialize a tuple of energy ranges with corresponding light curves
         self.channels = []
@@ -483,10 +484,11 @@ class Simulator(object):
 
         if mode == 'same':
             lc = lc[:-(len(h) - 1)]
+
         elif mode == 'filtered':
             lc = lc[(len(h) - 1):-(len(h) - 1)]
 
-        time = self.dt * np.arange(len(lc))
+        time = self.dt * np.arange(len(lc)) + self.tstart
         return Lightcurve(time, lc, err_dist='gauss', dt=self.dt)
 
     def _find_inverse(self, real, imaginary):


Test patch:
diff --git a/stingray/simulator/tests/test_simulator.py b/stingray/simulator/tests/test_simulator.py
index 7bed5536..9aa72e02 100644
--- a/stingray/simulator/tests/test_simulator.py
+++ b/stingray/simulator/tests/test_simulator.py
@@ -44,6 +44,15 @@ class TestSimulator(object):
         self.simulator = simulator.Simulator(N=1024, random_state=12)
         assert len(self.simulator.simulate(2).counts), 1024
 
+    def test_simulate_with_tstart(self):
+        """
+        Simulate with a random seed value.
+        """
+        tstart = 10.0
+        self.simulator = simulator.Simulator(N=1024, tstart=tstart)
+        assert self.simulator.time[0] == tstart
+
+
     def test_simulate_with_random_state(self):
         self.simulator = simulator.Simulator(N=1024, random_state=np.random.RandomState(12))
Repository: conan-io/conan
Pull request #15378 (2024-01-03 11:11:15)

Raise error if `check_type=int` and conf value is set to `bool`
Changelog: Fix: Raise if `check_type=int` and conf value is set to `bool`.
Docs: https://github.com/conan-io/docs/pull/XXXX

I just realized reviewing this https://github.com/conan-io/conan/pull/15360 that as `bool` is instance of `int` we allow these cases but I think that for these cases it may be more correct to fail (not in the opposite that you may use 0 or 1 to set a bool value)


Patch:
diff --git a/conans/model/conf.py b/conans/model/conf.py
index dce8fa6d8..b8677a0d5 100644
--- a/conans/model/conf.py
+++ b/conans/model/conf.py
@@ -313,7 +313,8 @@ class Conf:
                 return str(v)
             elif v is None:  # value was unset
                 return default
-            elif check_type is not None and not isinstance(v, check_type):
+            elif (check_type is not None and not isinstance(v, check_type) or
+                  check_type is int and isinstance(v, bool)):
                 raise ConanException(f"[conf] {conf_name} must be a "
                                      f"{check_type.__name__}-like object. The value '{v}' "
                                      f"introduced is a {type(v).__name__} object")


Test patch:
diff --git a/conans/test/unittests/model/test_conf.py b/conans/test/unittests/model/test_conf.py
index 186e05139..8353185b8 100644
--- a/conans/test/unittests/model/test_conf.py
+++ b/conans/test/unittests/model/test_conf.py
@@ -220,6 +220,7 @@ def test_conf_get_check_type_and_default():
         zlib:user.company.check:shared_str="False"
         zlib:user.company.check:static_str=off
         user.company.list:newnames+=myname
+        core.download:parallel=True
     """)
     c = ConfDefinition()
     c.loads(text)
@@ -238,6 +239,10 @@ def test_conf_get_check_type_and_default():
     assert c.get("zlib:user.company.check:static_str") == "off"
     assert c.get("zlib:user.company.check:static_str", check_type=bool) is False  # smart conversion
     assert c.get("user.company.list:newnames") == ["myname"]  # Placeholder is removed
+    with pytest.raises(ConanException) as exc_info:
+        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)
 
 
 def test_conf_pop():
Repository: conan-io/conan
Pull request #15410 (2024-01-08 07:49:52)

[BazelDeps][bugfix] Avoid getting binaries in `_get_libs`
Changelog: Bugfix: `BazelDeps._get_libs()` was gathering binary names.
Docs: omit
Closes: https://github.com/conan-io/conan/issues/15390



Patch:
diff --git a/conan/tools/google/bazeldeps.py b/conan/tools/google/bazeldeps.py
index 233b4bb32..7b3438e77 100644
--- a/conan/tools/google/bazeldeps.py
+++ b/conan/tools/google/bazeldeps.py
@@ -118,15 +118,16 @@ def _get_libs(dep, cpp_info=None) -> list:
             full_path = os.path.join(libdir, f)
             if not os.path.isfile(full_path):  # Make sure that directories are excluded
                 continue
+            name, ext = os.path.splitext(f)
             # Users may not name their libraries in a conventional way. For example, directly
-            # use the basename of the lib file as lib name.
-            if f in libs:
+            # use the basename of the lib file as lib name, e.g., cpp_info.libs = ["liblib1.a"]
+            # Issue related: https://github.com/conan-io/conan/issues/11331
+            if ext and f in libs:  # let's ensure that it has any extension
                 _save_lib_path(f, full_path)
                 continue
-            name, ext = os.path.splitext(f)
             if name not in libs and name.startswith("lib"):
                 name = name[3:]  # libpkg -> pkg
-             # FIXME: Should it read a conf variable to know unexpected extensions?
+            # FIXME: Should it read a conf variable to know unexpected extensions?
             if (is_shared and ext in (".so", ".dylib", ".lib", ".dll")) or \
                (not is_shared and ext in (".a", ".lib")):
                 if name in libs:


Test patch:
diff --git a/conans/test/unittests/tools/google/test_bazel.py b/conans/test/unittests/tools/google/test_bazel.py
index 64172d413..1dc015cf6 100644
--- a/conans/test/unittests/tools/google/test_bazel.py
+++ b/conans/test/unittests/tools/google/test_bazel.py
@@ -20,6 +20,7 @@ def cpp_info():
     save(ConanFileMock(), os.path.join(bindirs, "mylibwin2.dll"), "")
     save(ConanFileMock(), os.path.join(bindirs, "myliblin.so"), "")
     save(ConanFileMock(), os.path.join(bindirs, "mylibmac.dylib"), "")
+    save(ConanFileMock(), os.path.join(bindirs, "protoc"), "")  # binary
     save(ConanFileMock(), os.path.join(libdirs, "myliblin.a"), "")
     save(ConanFileMock(), os.path.join(libdirs, "mylibmac.a"), "")
     save(ConanFileMock(), os.path.join(libdirs, "mylibwin.lib"), "")
@@ -101,6 +102,10 @@ def test_bazeldeps_relativize_path(path, pattern, expected):
     (["noexist"], False, []),
     # no lib matching + Win + static
     (["noexist", "mylibwin"], False, [('mylibwin', False, '{base_folder}/lib/mylibwin.lib', None)]),
+    # protobuf (Issue related https://github.com/conan-io/conan/issues/15390)
+    (["protoc"], True, []),
+    # non-conventional library name (Issue related https://github.com/conan-io/conan/pull/11343)
+    (["libmylib.so"], True, [('libmylib.so', True, '{base_folder}/lib/libmylib.so', None)]),
 ])
 def test_bazeldeps_get_libs(cpp_info, libs, is_shared, expected):
     cpp_info.libs = libs
Repository: conan-io/conan
Pull request #15948 (2024-03-26 08:40:08)

[AutotoolsToolchain] Backported bugfix from #13230
Changelog: Fix flags passed by AutotoolsToolchain when cross compiling from macOS to a non-Apple OS. Backported from Conan 2.x #13230.
Docs: omit
Closes: https://github.com/conan-io/conan/issues/15429



Patch:
diff --git a/conan/tools/gnu/autotoolstoolchain.py b/conan/tools/gnu/autotoolstoolchain.py
index b870bd5b0..cf4af9063 100644
--- a/conan/tools/gnu/autotoolstoolchain.py
+++ b/conan/tools/gnu/autotoolstoolchain.py
@@ -1,6 +1,7 @@
 from conan.tools._check_build_profile import check_using_build_profile
 from conan.tools._compilers import architecture_flag, build_type_flags, cppstd_flag, \
     build_type_link_flags, libcxx_flags
+from conan.tools.apple import is_apple_os
 from conan.tools.apple.apple import apple_min_version_flag, to_apple_arch, \
     apple_sdk_path
 from conan.tools.build.cross_building import cross_building, get_cross_building_settings
@@ -59,7 +60,7 @@ class AutotoolsToolchain:
             # Build triplet
             self._build = _get_gnu_triplet(os_build, arch_build, compiler=compiler)
             # Apple Stuff
-            if os_build == "Macos":
+            if os_build == "Macos" and is_apple_os(self._conanfile):
                 sdk_path = apple_sdk_path(conanfile)
                 apple_arch = to_apple_arch(self._conanfile)
                 # https://man.archlinux.org/man/clang.1.en#Target_Selection_Options


Test patch:
diff --git a/conans/test/unittests/client/toolchain/autotools/autotools_toolchain_test.py b/conans/test/unittests/client/toolchain/autotools/autotools_toolchain_test.py
index aedd2fdf9..cd64d20fe 100644
--- a/conans/test/unittests/client/toolchain/autotools/autotools_toolchain_test.py
+++ b/conans/test/unittests/client/toolchain/autotools/autotools_toolchain_test.py
@@ -315,6 +315,19 @@ def test_apple_min_os_flag():
     assert expected in env["LDFLAGS"]
 
 
+def test_crossbuild_from_macos_to_non_apple_os():
+    """Check we are not adding Apple-specific flags
+        when the os_build is Macos, but we are targetting
+        a non-Apple OS (e.g. Linux, Android, QNX)"""
+    conanfile = ConanFileMock()
+    conanfile.settings = MockSettings({"os": "Android", "arch": "armv8"})
+    conanfile.settings_build = MockSettings({"os": "Macos", "arch": "armv8"})
+    be = AutotoolsToolchain(conanfile)
+    assert be.apple_min_version_flag == ''
+    assert be.apple_arch_flag is None
+    assert be.apple_isysroot_flag is None
+
+
 def test_apple_isysrootflag():
     """Even when no cross building it is adjusted because it could target a Mac version"""
     conanfile = ConanFileMock()
Repository: conan-io/conan
Pull request #16069 (2024-04-11 15:12:07)

Improve error messages for invalid version ranges operators
Changelog: Fix: Improve the definition of version ranges UX with better error message for invalid ``==, ~=, ^=`` operators.
Docs: Omit

Close https://github.com/conan-io/conan/issues/16066


Patch:
diff --git a/conans/model/version_range.py b/conans/model/version_range.py
index 97778f68c..751683e3e 100644
--- a/conans/model/version_range.py
+++ b/conans/model/version_range.py
@@ -88,6 +88,8 @@ class _ConditionSet:
             if expression[1] == "=":
                 operator += "="
                 index = 2
+        elif expression[1] == "=":
+            raise ConanException(f"Invalid version range operator '{operator}=' in {expression}, you should probably use {operator} instead.")
         version = expression[index:]
         if version == "":
             raise ConanException(f'Error parsing version range "{expression}"')
@@ -111,7 +113,7 @@ class _ConditionSet:
         else:
             return [_Condition(operator, Version(version))]
 
-    def _valid(self, version, conf_resolve_prepreleases):
+    def valid(self, version, conf_resolve_prepreleases):
         if version.pre:
             # Follow the expression desires only if core.version_ranges:resolve_prereleases is None,
             # else force to the conf's value
@@ -180,7 +182,7 @@ class VersionRange:
         """
         assert isinstance(version, Version), type(version)
         for condition_set in self.condition_sets:
-            if condition_set._valid(version, resolve_prerelease):
+            if condition_set.valid(version, resolve_prerelease):
                 return True
         return False
 


Test patch:
diff --git a/conans/test/unittests/model/version/test_version_range.py b/conans/test/unittests/model/version/test_version_range.py
index 263caf65f..256d4420e 100644
--- a/conans/test/unittests/model/version/test_version_range.py
+++ b/conans/test/unittests/model/version/test_version_range.py
@@ -5,6 +5,7 @@ from conans.model.version import Version
 from conans.model.version_range import VersionRange
 
 values = [
+    ['=1.0.0',  [[['=', '1.0.0']]],                   ["1.0.0"],          ["0.1"]],
     ['>1.0.0',  [[['>', '1.0.0']]],                   ["1.0.1"],          ["0.1"]],
     ['<2.0',    [[['<', '2.0-']]],                     ["1.0.1"],          ["2.1"]],
     ['>1 <2.0', [[['>', '1'], ['<', '2.0-']]],         ["1.5.1"],          ["0.1", "2.1"]],
@@ -109,7 +110,8 @@ def test_range_prereleases_conf(version_range, resolve_prereleases, versions_in,
 
 @pytest.mark.parametrize("version_range", [
     ">= 1.0",  # https://github.com/conan-io/conan/issues/12692
-    ">=0.0.1 < 1.0"  # https://github.com/conan-io/conan/issues/14612
+    ">=0.0.1 < 1.0",  # https://github.com/conan-io/conan/issues/14612
+    "==1.0",  "~=1.0",  "^=1.0", "v=1.0"  # https://github.com/conan-io/conan/issues/16066
 ])
 def test_wrong_range_syntax(version_range):
     with pytest.raises(ConanException):
Repository: conan-io/conan
Pull request #16087 (2024-04-16 13:57:03)

Add comments to .conanignore
Changelog: Feature: Add comment support for .conanignore file
Docs: Omit




Patch:
diff --git a/conans/client/conf/config_installer.py b/conans/client/conf/config_installer.py
index fc4284fd9..82f39daa0 100644
--- a/conans/client/conf/config_installer.py
+++ b/conans/client/conf/config_installer.py
@@ -19,8 +19,8 @@ class _ConanIgnoreMatcher:
         if os.path.exists(conanignore_path):
             with open(conanignore_path, 'r') as conanignore:
                 for line in conanignore:
-                    line_content = line.strip()
-                    if line_content != "":
+                    line_content = line.split("#", maxsplit=1)[0].strip()
+                    if line_content:
                         self._ignored_entries.add(line_content)
         if ignore:
             self._ignored_entries.update(ignore)


Test patch:
diff --git a/conans/test/integration/command/config_test.py b/conans/test/integration/command/config_test.py
index 2e27d36b7..f35d1ea1d 100644
--- a/conans/test/integration/command/config_test.py
+++ b/conans/test/integration/command/config_test.py
@@ -65,10 +65,12 @@ def test_config_install():
 def test_config_install_conanignore():
     tc = TestClient()
     conanignore = textwrap.dedent("""
-    a/*
+    a/*  # This is a tests
     b/c/*
     d/*
     tests/*
+    # Next line is commented out, so it should be ignored
+    # other_tests/*
     """)
     tc.save({
         'config_folder/.conanignore': conanignore,
Repository: conan-io/conan
Pull request #16113 (2024-04-19 10:25:28)

fix restore not exist file
Changelog: Fix: Clean error message for ``conan cache restore <non-existing-file>``
Docs: Omit

Close https://github.com/conan-io/conan/issues/16112



Patch:
diff --git a/conan/api/subapi/cache.py b/conan/api/subapi/cache.py
index 0875f6fb2..1fcb49219 100644
--- a/conan/api/subapi/cache.py
+++ b/conan/api/subapi/cache.py
@@ -155,6 +155,8 @@ class CacheAPI:
             tgz.close()
 
     def restore(self, path):
+        if not os.path.isfile(path):
+            raise ConanException(f"Restore archive doesn't exist in {path}")
         with open(path, mode='rb') as file_handler:
             the_tar = tarfile.open(fileobj=file_handler)
             fileobj = the_tar.extractfile("pkglist.json")


Test patch:
diff --git a/conans/test/integration/command_v2/test_cache_save_restore.py b/conans/test/integration/command_v2/test_cache_save_restore.py
index 046e0fb0e..2d5301b60 100644
--- a/conans/test/integration/command_v2/test_cache_save_restore.py
+++ b/conans/test/integration/command_v2/test_cache_save_restore.py
@@ -211,3 +211,9 @@ def test_cache_save_subfolder():
     c.run("export .")
     c.run("cache save * --file=subfolder/cache.tgz")
     assert os.path.exists(os.path.join(c.current_folder, "subfolder", "cache.tgz"))
+
+
+def test_error_restore_not_existing():
+    c = TestClient()
+    c.run("cache restore potato.tgz", assert_error=True)
+    assert "ERROR: Restore archive doesn't exist in " in c.out
Repository: conan-io/conan
Pull request #16170 (2024-04-29 08:22:36)

fix remove editables deleted
Changelog: Fix: Allowing ``conan editable remove <path>`` even when the path has been already deleted.
Docs: Omit

Close https://github.com/conan-io/conan/issues/16164



Patch:
diff --git a/conan/api/subapi/local.py b/conan/api/subapi/local.py
index eaaa3a170..88ae8a8fe 100644
--- a/conan/api/subapi/local.py
+++ b/conan/api/subapi/local.py
@@ -1,5 +1,6 @@
 import os
 
+from conan.api.output import ConanOutput
 from conan.cli import make_abs_path
 from conan.internal.conan_app import ConanApp
 from conans.client.cache.editable import EditablePackages
@@ -60,7 +61,8 @@ class LocalAPI:
 
     def editable_remove(self, path=None, requires=None, cwd=None):
         if path:
-            path = self._conan_api.local.get_conanfile_path(path, cwd, py=True)
+            path = make_abs_path(path, cwd)
+            path = os.path.join(path, "conanfile.py")
         return self.editable_packages.remove(path, requires)
 
     def editable_list(self):


Test patch:
diff --git a/conans/test/integration/editable/editable_remove_test.py b/conans/test/integration/editable/editable_remove_test.py
index e28164f68..837e17601 100644
--- a/conans/test/integration/editable/editable_remove_test.py
+++ b/conans/test/integration/editable/editable_remove_test.py
@@ -48,8 +48,9 @@ class TestRemoveEditablePackageTest:
         c.save({'pkg/conanfile.py': GenConanfile()})
         c.run('editable add pkg --name=lib --version=version')
         shutil.rmtree(os.path.join(c.current_folder, "pkg"))
-        c.run("editable remove pkg", assert_error=True)
-        c.run("editable remove --refs=lib/version")
+        # https://github.com/conan-io/conan/issues/16164
+        # Making it possible, repeated issue
+        c.run("editable remove pkg")
         assert "Removed editable 'lib/version'" in c.out
         c.run("editable list")
         assert "lib" not in c.out
Repository: conan-io/conan
Pull request #16213 (2024-05-07 09:14:49)

fix CommandAPI usage without commands
Changelog: Fix: CommandAPI usage when not used by Conan custom commands
Docs: https://github.com/conan-io/docs/pull/XXXX

Close https://github.com/conan-io/conan/issues/16209


Patch:
diff --git a/conan/cli/cli.py b/conan/cli/cli.py
index a9a420c58..a99a055ac 100644
--- a/conan/cli/cli.py
+++ b/conan/cli/cli.py
@@ -38,7 +38,7 @@ class Cli:
         self._groups = defaultdict(list)
         self._commands = {}
 
-    def _add_commands(self):
+    def add_commands(self):
         if Cli._builtin_commands is None:
             conan_cmd_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "commands")
             for module in pkgutil.iter_modules([conan_cmd_path]):
@@ -167,7 +167,7 @@ class Cli:
         methods
         """
         output = ConanOutput()
-        self._add_commands()
+        self.add_commands()
         try:
             command_argument = args[0][0]
         except IndexError:  # No parameters


Test patch:
diff --git a/conans/test/integration/conan_api/test_cli.py b/conans/test/integration/conan_api/test_cli.py
index 64d94e1c6..10804ba0d 100644
--- a/conans/test/integration/conan_api/test_cli.py
+++ b/conans/test/integration/conan_api/test_cli.py
@@ -21,3 +21,18 @@ def test_cli():
         cli.run(["list", "*"])
         cli2.run(["list", "*"])
         cli.run(["list", "*"])
+
+
+def test_basic_api():
+    api = ConanAPI(cache_folder=temp_folder())
+    result = api.remotes.list()
+    assert result[0].name == "conancenter"
+
+
+def test_api_command():
+    # The ``CommandAPI`` requires a bit more of setup
+    api = ConanAPI()
+    cli = Cli(api)
+    cli.add_commands()
+    result = api.command.run(["remote", "list"])
+    assert result[0].name == "conancenter"
Repository: conan-io/conan
Pull request #16252 (2024-05-14 16:19:22)

Hotfix update check in compatibility processing
Changelog: Bugfix: Make compatibility checks understand update flag patterns
Docs: Omit



RubenRBS: The modified test without the fix lists bth libraries as being checked in the servers, and with the fix only pkg is


Patch:
diff --git a/conans/client/graph/graph_binaries.py b/conans/client/graph/graph_binaries.py
index 6663bca70..46ef40517 100644
--- a/conans/client/graph/graph_binaries.py
+++ b/conans/client/graph/graph_binaries.py
@@ -150,7 +150,7 @@ class GraphBinariesAnalyzer(object):
             if node.binary in (BINARY_CACHE, BINARY_UPDATE, BINARY_DOWNLOAD):
                 _compatible_found(package_id, compatible_package)
                 return
-        if not update:
+        if not should_update_reference(conanfile.ref, update):
             conanfile.output.info(f"Compatible configurations not found in cache, checking servers")
             for package_id, compatible_package in compatibles.items():
                 conanfile.output.info(f"'{package_id}': "


Test patch:
diff --git a/conans/test/integration/package_id/compatible_test.py b/conans/test/integration/package_id/compatible_test.py
index 782fe7ca2..8e4e0a999 100644
--- a/conans/test/integration/package_id/compatible_test.py
+++ b/conans/test/integration/package_id/compatible_test.py
@@ -71,14 +71,17 @@ class CompatibleIDsTest(unittest.TestCase):
         client.run("export . --name=pkg --version=0.1 --user=user --channel=stable")
         self.assertIn("pkg/0.1@user/stable: Exported: "
                       "pkg/0.1@user/stable#d165eb4bcdd1c894a97d2a212956f5fe", client.out)
+        client.run("export . --name=lib --version=0.1 --user=user --channel=stable")
 
         # package can be used with a profile gcc 4.9 falling back to 4.8 binary
-        client.save({"conanfile.py": GenConanfile().with_require("pkg/0.1@user/stable")})
+        client.save({"conanfile.py": GenConanfile().with_requires("pkg/0.1@user/stable", "lib/0.1@user/stable")})
         # No fallback
-        client.run("install . -pr=myprofile --build=missing")
+        client.run("install . -pr=myprofile --build=missing -u=lib")
         self.assertIn("pkg/0.1@user/stable: PackageInfo!: Gcc version: 4.9!", client.out)
         client.assert_listed_binary({"pkg/0.1@user/stable":
                                      ("1ded27c9546219fbd04d4440e05b2298f8230047", "Build")})
+        assert "lib/0.1@user/stable: Compatible configurations not found in cache, checking servers" not in client.out
+        assert "pkg/0.1@user/stable: Compatible configurations not found in cache, checking servers" in client.out
 
     def test_compatible_setting_no_user_channel(self):
         client = TestClient()