nebius/SWE-bench-extra huggingface dataset:
Repository: pypa/setuptools_scm

Issue:
7.0.0+ Regression: Calling GitWorkdir.git_branch inserts a newline
We use a version scheme for development that adds a branch name when the package is built on a git branch.

Recently we found 7.0.0+ changed the behavior of git_branch with the trailing `--` (apparently to add Hg support?)... Now, the "branch" variable consistently adds a newline and a trailing `--`, which breaks compatibility with PEP and causes other surprising failures downstream.

The code traces to this line here which changed in the 7.0.0 merge: https://github.com/pypa/setuptools_scm/blob/main/src/setuptools_scm/git.py#L85

Running raw git command with Ubuntu 20.04, on a branch called "test-branch" results in:

```
$ git --version
git version 2.25.1
$ git rev-parse --abbrev-ref HEAD --
test-branch
--
$
```

And then inside a python environment:

```
>>> from setuptools_scm import git
>>> git.parse(".")
<ScmVersion 7.0.2 dist=None node=gf1f35bd dirty=False branch=test-branch
-->
>>> 
```


Comments:

Patch:
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 997d10b..4c9bd24 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -1,5 +1,10 @@
+v7.0.3
+=======
+* fix mercurial usage when pip primes a isolated environment
+* fix regression for branch names on git + add a test
+
 v7.0.2
-======
+=======
 
 * fix #723 and #722: remove bootstrap dependencies
 * bugfix: ensure we read the distribution name from setup.cfg
diff --git a/src/setuptools_scm/git.py b/src/setuptools_scm/git.py
index 1f8984b..47e2a9e 100644
--- a/src/setuptools_scm/git.py
+++ b/src/setuptools_scm/git.py
@@ -82,10 +82,10 @@ class GitWorkdir(Workdir):
         return bool(out)
 
     def get_branch(self) -> str | None:
-        branch, err, ret = self.do_ex_git(["rev-parse", "--abbrev-ref", "HEAD", "--"])
+        branch, err, ret = self.do_ex_git(["rev-parse", "--abbrev-ref", "HEAD"])
         if ret:
             trace("branch err", branch, err, ret)
-            branch, err, ret = self.do_ex_git(["symbolic-ref", "--short", "HEAD", "--"])
+            branch, err, ret = self.do_ex_git(["symbolic-ref", "--short", "HEAD"])
             if ret:
                 trace("branch err (symbolic-ref)", branch, err, ret)
                 return None


Test patch:
diff --git a/testing/test_git.py b/testing/test_git.py
index 661a5ee..cb54f61 100644
--- a/testing/test_git.py
+++ b/testing/test_git.py
@@ -378,6 +378,14 @@ def test_git_archive_run_from_subdirectory(
     assert integration.find_files(".") == [opj(".", "test1.txt")]
 
 
+@pytest.mark.issue("https://github.com/pypa/setuptools_scm/issues/728")
+def test_git_branch_names_correct(wd: WorkDir) -> None:
+    wd.commit_testfile()
+    wd("git checkout -b test/fun")
+    wd_git = git.GitWorkdir(os.fspath(wd.cwd))
+    assert wd_git.get_branch() == "test/fun"
+
+
 def test_git_feature_branch_increments_major(wd: WorkDir) -> None:
     wd.commit_testfile()
     wd("git tag 1.0.0")
Repository: pypa/wheel

Issue:
Incorrect summary in produced wheels starting from 0.38.1
See https://pypi.org/search/?q=%3D%3Futf-8%3Fq%3F
All wheels produced after 2022/11/04 (0.38.1 release date) have incorrect summaries.

Comments:

Patch:
diff --git a/src/wheel/bdist_wheel.py b/src/wheel/bdist_wheel.py
index 4754fd1..7fcf4a3 100644
--- a/src/wheel/bdist_wheel.py
+++ b/src/wheel/bdist_wheel.py
@@ -15,6 +15,7 @@ import sysconfig
 import warnings
 from collections import OrderedDict
 from email.generator import BytesGenerator, Generator
+from email.policy import EmailPolicy
 from glob import iglob
 from io import BytesIO
 from shutil import rmtree
@@ -534,8 +535,13 @@ class bdist_wheel(Command):
                 adios(dependency_links_path)
 
         pkg_info_path = os.path.join(distinfo_path, "METADATA")
+        serialization_policy = EmailPolicy(
+            utf8=True,
+            mangle_from_=False,
+            max_line_length=0,
+        )
         with open(pkg_info_path, "w", encoding="utf-8") as out:
-            Generator(out, mangle_from_=False, maxheaderlen=0).flatten(pkg_info)
+            Generator(out, policy=serialization_policy).flatten(pkg_info)
 
         for license_path in self.license_paths:
             filename = os.path.basename(license_path)


Test patch:
diff --git a/tests/test_bdist_wheel.py b/tests/test_bdist_wheel.py
index 531d9e6..5a6db16 100644
--- a/tests/test_bdist_wheel.py
+++ b/tests/test_bdist_wheel.py
@@ -72,6 +72,45 @@ def test_unicode_record(wheel_paths):
     assert "åäö_日本語.py".encode() in record
 
 
+UTF8_PKG_INFO = """\
+Metadata-Version: 2.1
+Name: helloworld
+Version: 42
+Author-email: "John X. Ãørçeč" <john@utf8.org>, Γαμα קּ 東 <gama@utf8.org>
+
+
+UTF-8 描述 説明
+"""
+
+
+def test_preserve_unicode_metadata(monkeypatch, tmp_path):
+    monkeypatch.chdir(tmp_path)
+    egginfo = tmp_path / "dummy_dist.egg-info"
+    distinfo = tmp_path / "dummy_dist.dist-info"
+
+    egginfo.mkdir()
+    (egginfo / "PKG-INFO").write_text(UTF8_PKG_INFO, encoding="utf-8")
+    (egginfo / "dependency_links.txt").touch()
+
+    class simpler_bdist_wheel(bdist_wheel):
+        """Avoid messing with setuptools/distutils internals"""
+
+        def __init__(self):
+            pass
+
+        @property
+        def license_paths(self):
+            return []
+
+    cmd_obj = simpler_bdist_wheel()
+    cmd_obj.egg2dist(egginfo, distinfo)
+
+    metadata = (distinfo / "METADATA").read_text(encoding="utf-8")
+    assert 'Author-email: "John X. Ãørçeč"' in metadata
+    assert "Γαμα קּ 東 " in metadata
+    assert "UTF-8 描述 説明" in metadata
+
+
 def test_licenses_default(dummy_dist, monkeypatch, tmpdir):
     monkeypatch.chdir(dummy_dist)
     subprocess.check_call(
Repository: pypa/wheel

Issue:
wheel unpack doesn't preserve permissions
I expected `wheel unpack` + `wheel pack` to result in similarly functioning wheels. However, `wheel unpack` doesn't seem to preserve permissions. That is, there's nothing in `wheel` that does this kind of thing: https://github.com/pypa/pip/blob/852deddb9c14afdb780e77ea28c2fa6d29f8c2e1/src/pip/_internal/utils/unpacking.py#L143 

Is this intentional?

Comments:

Patch:
diff --git a/docs/news.rst b/docs/news.rst
index 4961729..2fbe136 100644
--- a/docs/news.rst
+++ b/docs/news.rst
@@ -4,6 +4,7 @@ Release Notes
 **UNRELEASED**
 
 - Updated vendored ``packaging`` to 23.0
+- ``wheel unpack`` now preserves the executable attribute of extracted files
 - Fixed spaces in platform names not being converted to underscores (PR by David Tucker)
 - Fixed ``RECORD`` files in generated wheels missing the regular file attribute
 - Fixed ``DeprecationWarning`` about the use of the deprecated ``pkg_resources`` API
diff --git a/src/wheel/cli/unpack.py b/src/wheel/cli/unpack.py
index c6409d4..d48840e 100644
--- a/src/wheel/cli/unpack.py
+++ b/src/wheel/cli/unpack.py
@@ -18,6 +18,13 @@ def unpack(path: str, dest: str = ".") -> None:
         namever = wf.parsed_filename.group("namever")
         destination = Path(dest) / namever
         print(f"Unpacking to: {destination}...", end="", flush=True)
-        wf.extractall(destination)
+        for zinfo in wf.filelist:
+            wf.extract(zinfo, destination)
+
+            # Set permissions to the same values as they were set in the archive
+            # We have to do this manually due to
+            # https://github.com/python/cpython/issues/59999
+            permissions = zinfo.external_attr >> 16 & 0o777
+            destination.joinpath(zinfo.filename).chmod(permissions)
 
     print("OK")


Test patch:
diff --git a/tests/cli/test_unpack.py b/tests/cli/test_unpack.py
index e6a38bb..ae584af 100644
--- a/tests/cli/test_unpack.py
+++ b/tests/cli/test_unpack.py
@@ -1,6 +1,12 @@
 from __future__ import annotations
 
+import platform
+import stat
+
+import pytest
+
 from wheel.cli.unpack import unpack
+from wheel.wheelfile import WheelFile
 
 
 def test_unpack(wheel_paths, tmp_path):
@@ -10,3 +16,21 @@ def test_unpack(wheel_paths, tmp_path):
     """
     for wheel_path in wheel_paths:
         unpack(wheel_path, str(tmp_path))
+
+
+@pytest.mark.skipif(
+    platform.system() == "Windows", reason="Windows does not support the executable bit"
+)
+def test_unpack_executable_bit(tmp_path):
+    wheel_path = tmp_path / "test-1.0-py3-none-any.whl"
+    script_path = tmp_path / "script"
+    script_path.write_bytes(b"test script")
+    script_path.chmod(0o755)
+    with WheelFile(wheel_path, "w") as wf:
+        wf.write(str(script_path), "nested/script")
+
+    script_path.unlink()
+    script_path = tmp_path / "test-1.0" / "nested" / "script"
+    unpack(str(wheel_path), str(tmp_path))
+    assert not script_path.is_dir()
+    assert stat.S_IMODE(script_path.stat().st_mode) == 0o755
Repository: pypa/wheel

Issue:
Parens in metadata version specifiers
The [packaging spec](https://packaging.python.org/en/latest/specifications/core-metadata/#requires-dist-multiple-use) says that Requires-Dist specifiers should not have parens, but wheel add the parens [here](https://github.com/pypa/wheel/blob/main/src/wheel/metadata.py#L95).

I ran into this problem because of a super edge case installing a wheel that has exact identity (===) dependencies. Pip allows any character after an the identity specifier, which means that it also captures the closing paren and so a requirement like `requests (===1.2.3)` won't match. The identity specifiers are used for prereleases and some other special-case version specifiers.

Comments:

Patch:
diff --git a/docs/news.rst b/docs/news.rst
index a76eb6c..df991f2 100644
--- a/docs/news.rst
+++ b/docs/news.rst
@@ -5,6 +5,7 @@ Release Notes
 
 - Fixed naming of the ``data_dir`` directory in the presence of local version segment
   given via ``egg_info.tag_build`` (PR by Anderson Bravalheri)
+- Fixed version specifiers in ``Requires-Dist`` being wrapped in parentheses
 
 **0.41.0 (2023-07-22)**
 
diff --git a/src/wheel/metadata.py b/src/wheel/metadata.py
index b391c96..ddcb90e 100644
--- a/src/wheel/metadata.py
+++ b/src/wheel/metadata.py
@@ -92,7 +92,7 @@ def requires_to_requires_dist(requirement: Requirement) -> str:
         requires_dist.append(spec.operator + spec.version)
 
     if requires_dist:
-        return " (" + ",".join(sorted(requires_dist)) + ")"
+        return " " + ",".join(sorted(requires_dist))
     else:
         return ""
 


Test patch:
diff --git a/tests/test_metadata.py b/tests/test_metadata.py
index e267f02..8480732 100644
--- a/tests/test_metadata.py
+++ b/tests/test_metadata.py
@@ -22,11 +22,11 @@ def test_pkginfo_to_metadata(tmp_path):
         ("Provides-Extra", "faster-signatures"),
         ("Requires-Dist", "ed25519ll ; extra == 'faster-signatures'"),
         ("Provides-Extra", "rest"),
-        ("Requires-Dist", "docutils (>=0.8) ; extra == 'rest'"),
+        ("Requires-Dist", "docutils >=0.8 ; extra == 'rest'"),
         ("Requires-Dist", "keyring ; extra == 'signatures'"),
         ("Requires-Dist", "keyrings.alt ; extra == 'signatures'"),
         ("Provides-Extra", "test"),
-        ("Requires-Dist", "pytest (>=3.0.0) ; extra == 'test'"),
+        ("Requires-Dist", "pytest >=3.0.0 ; extra == 'test'"),
         ("Requires-Dist", "pytest-cov ; extra == 'test'"),
     ]