nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: pypa/setuptools
Pull request #532 (2016-04-06 04:52:07)

Reinstate the or guard in WorkingSet._markers_pass
Thanks to @jaraco refactoring the marker evaluation in WorkingSet.resolve(), we can test it directly to show that the [''] guard is required.


Patch:
diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py
index 086777198..c3e3e96ca 100644
--- a/pkg_resources/__init__.py
+++ b/pkg_resources/__init__.py
@@ -861,7 +861,7 @@ class WorkingSet(object):
 
         result = []
         if req in extra_req_mapping:
-            for extra in extra_req_mapping[req]:
+            for extra in extra_req_mapping[req] or ['']:
                 result.append(req.marker.evaluate({'extra': extra}))
         else:
             result.append(req.marker.evaluate())


Test patch:
diff --git a/pkg_resources/tests/test_resources.py b/pkg_resources/tests/test_resources.py
index 7f86c7978..7907224ee 100644
--- a/pkg_resources/tests/test_resources.py
+++ b/pkg_resources/tests/test_resources.py
@@ -186,6 +186,12 @@ class TestDistro:
         res = ws.resolve(parse_requirements("Foo;python_version>='2'"), ad)
         assert list(res) == [Foo]
 
+    def test_environment_marker_evaluation_called(self):
+        ws = WorkingSet([])
+        req, = parse_requirements("bar;python_version<'4'")
+        extra_req_mapping = {req: ()}
+        assert ws._markers_pass(req, extra_req_mapping) == True
+
     def test_marker_evaluation_with_extras(self):
         """Extras are also evaluated as markers at resolution time."""
         ad = pkg_resources.Environment([])
Repository: pypa/setuptools
Pull request #736 (2016-08-16 06:13:24)

Fix issue #459
Patched sys.argv[0] before loading entry point

#459 


Patch:
diff --git a/CHANGES.rst b/CHANGES.rst
index cd2039520..cc027f411 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -5,6 +5,9 @@ CHANGES
 v25.4.0
 -------
 
+* #459 via #736: On Windows systems, sys.argv[0] now correctly becomes the
+  name of entry point.
+
 * Add Extension(py_limited_api=True). When set to a truthy value,
   that extension gets a filename apropriate for code using Py_LIMITED_API.
   When used correctly this allows a single compiled extension to work on
diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py
index ae9079d80..5065661fa 100755
--- a/setuptools/command/easy_install.py
+++ b/setuptools/command/easy_install.py
@@ -2018,10 +2018,12 @@ class ScriptWriter(object):
     template = textwrap.dedent("""
         # EASY-INSTALL-ENTRY-SCRIPT: %(spec)r,%(group)r,%(name)r
         __requires__ = %(spec)r
+        import re
         import sys
         from pkg_resources import load_entry_point
 
         if __name__ == '__main__':
+            sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
             sys.exit(
                 load_entry_point(%(spec)r, %(group)r, %(name)r)()
             )


Test patch:
diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py
index da0a355c4..82e1d7e8b 100644
--- a/setuptools/tests/test_easy_install.py
+++ b/setuptools/tests/test_easy_install.py
@@ -74,10 +74,12 @@ class TestEasyInstallTest:
         expected = header + DALS("""
             # EASY-INSTALL-ENTRY-SCRIPT: 'spec','console_scripts','name'
             __requires__ = 'spec'
+            import re
             import sys
             from pkg_resources import load_entry_point
 
             if __name__ == '__main__':
+                sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
                 sys.exit(
                     load_entry_point('spec', 'console_scripts', 'name')()
                 )