Repository: scikit-build/scikit-build-core
Pull request #729 (2024-04-29 05:08:56)

fix: don't generate entrypoints.txt if none set
Not needed unless entrypoints is non-empty.


codecov[bot]: ## [Codecov](https://app.codecov.io/gh/scikit-build/scikit-build-core/pull/729?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scikit-build) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 81.88%. Comparing base [(`293d8a7`)](https://app.codecov.io/gh/scikit-build/scikit-build-core/commit/293d8a7aab8bbee4891576bcf939cbf11fe6f438?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scikit-build) to head [(`27e6cd8`)](https://app.codecov.io/gh/scikit-build/scikit-build-core/pull/729?dropdown=coverage&src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scikit-build).


<details><summary>Additional details and impacted files</summary>


```diff
@@           Coverage Diff           @@
##             main     #729   +/-   ##
=======================================
  Coverage   81.87%   81.88%           
=======================================
  Files          68       68           
  Lines        3884     3886    +2     
=======================================
+ Hits         3180     3182    +2     
  Misses        704      704           
```



</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/scikit-build/scikit-build-core/pull/729?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scikit-build).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scikit-build).


Patch:
diff --git a/src/scikit_build_core/build/_wheelfile.py b/src/scikit_build_core/build/_wheelfile.py
index 7672554..3b3740b 100644
--- a/src/scikit_build_core/build/_wheelfile.py
+++ b/src/scikit_build_core/build/_wheelfile.py
@@ -135,10 +135,15 @@ class WheelWriter:
             msg = "Cannot have METADATA, WHEEL, RECORD, or entry_points.txt in metadata_dir"
             raise ValueError(msg)
 
+        entry_points_txt = entry_points.getvalue().encode("utf-8")
+        entry_points_dict = (
+            {"entry_points.txt": entry_points_txt} if entry_points_txt else {}
+        )
+
         return {
             "METADATA": bytes(rfc822),
             "WHEEL": self.wheel_metadata.as_bytes(),
-            "entry_points.txt": entry_points.getvalue().encode("utf-8"),
+            **entry_points_dict,
             **extra_metadata,
         }
 


Test patch:
diff --git a/tests/test_prepare_metadata.py b/tests/test_prepare_metadata.py
index f2edae2..daf68e3 100644
--- a/tests/test_prepare_metadata.py
+++ b/tests/test_prepare_metadata.py
@@ -42,7 +42,7 @@ def test_prepare_metadata_for_build(fp, editable):
         == metadata.strip()
     )
 
-    assert len(list(Path("simple/simplest-0.0.1.dist-info").iterdir())) == 3
+    assert len(list(Path("simple/simplest-0.0.1.dist-info").iterdir())) == 2
     assert len(list(Path("simple").iterdir())) == 1
 
 
diff --git a/tests/test_simplest_c.py b/tests/test_simplest_c.py
index 4fbb9c7..8e55093 100644
--- a/tests/test_simplest_c.py
+++ b/tests/test_simplest_c.py
@@ -147,7 +147,6 @@ def test_pep517_wheel_incexl(tmp_path, monkeypatch, virtualenv):
         "RECORD",
         "METADATA",
         "WHEEL",
-        "entry_points.txt",
     } == metadata_items
 
     filtered_pkg = {x for x in simplest_pkg if not x.startswith("_module")}
diff --git a/tests/test_wheelfile_utils.py b/tests/test_wheelfile_utils.py
index cde150a..9e92ac5 100644
--- a/tests/test_wheelfile_utils.py
+++ b/tests/test_wheelfile_utils.py
@@ -48,7 +48,6 @@ def test_wheel_writer_simple(tmp_path, monkeypatch):
     assert dist_info == {
         "METADATA": b"Metadata-Version: 2.1\nName: something\nVersion: 1.2.3\n",
         "WHEEL": b"Wheel-Version: 1.0\nGenerator: scikit-build-core 1.2.3\nRoot-Is-Purelib: false\nTag: py3-none-any\n\n",
-        "entry_points.txt": b"",
     }
 
     platlib = tmp_path / "platlib"
@@ -62,16 +61,11 @@ def test_wheel_writer_simple(tmp_path, monkeypatch):
         assert zf.namelist() == [
             "something-1.2.3.dist-info/METADATA",
             "something-1.2.3.dist-info/WHEEL",
-            "something-1.2.3.dist-info/entry_points.txt",
             "something-1.2.3.dist-info/RECORD",
         ]
 
         assert zf.read("something-1.2.3.dist-info/METADATA") == dist_info["METADATA"]
         assert zf.read("something-1.2.3.dist-info/WHEEL") == dist_info["WHEEL"]
-        assert (
-            zf.read("something-1.2.3.dist-info/entry_points.txt")
-            == dist_info["entry_points.txt"]
-        )
 
         for info in zf.infolist():
             assert info.external_attr == (0o664 | stat.S_IFREG) << 16