Repository: scikit-build/scikit-build-core
Pull request #325 (2023-05-19 14:31:05)

fix: LICENSE files were placed in the wrong place
Yanked 0.4.0. Will release 0.4.1 once this goes in.



Patch:
diff --git a/docs/changelog.md b/docs/changelog.md
index 8f57647..7b38743 100644
--- a/docs/changelog.md
+++ b/docs/changelog.md
@@ -1,5 +1,14 @@
 # Changelog
 
+## Version 0.4.1
+
+A fix for LICENCE files being placed in the wrong place in the wheel. Now we
+follow hatchling's structure of placing them in `*.dist-info/licenses`.
+
+Fixes:
+
+- LICENCE files were placed in the wrong place by @henryiii in #325
+
 ## Version 0.4.0
 
 An important fix/feature: LICENSE files were not being included in the wheel's
diff --git a/src/scikit_build_core/build/wheel.py b/src/scikit_build_core/build/wheel.py
index f6993ec..6eb18fa 100644
--- a/src/scikit_build_core/build/wheel.py
+++ b/src/scikit_build_core/build/wheel.py
@@ -228,7 +228,9 @@ def _build_wheel_impl(
         with WheelWriter(metadata, Path(wheel_directory), tags.as_tags_set()) as wheel:
             wheel.build(wheel_dirs)
             for license_file in license_files:
-                wheel.write(str(license_file), license_file.name)
+                wheel.write(
+                    str(license_file), f"{wheel.dist_info}/licenses/{license_file.name}"
+                )
 
             if editable:
                 modules = {


Test patch:
diff --git a/tests/test_pyproject_pep517.py b/tests/test_pyproject_pep517.py
index 5d869e3..4eb50f4 100644
--- a/tests/test_pyproject_pep517.py
+++ b/tests/test_pyproject_pep517.py
@@ -160,11 +160,11 @@ def test_pep517_wheel(virtualenv):
             entry_points = p.joinpath(
                 "cmake_example-0.0.1.dist-info/entry_points.txt"
             ).read_text()
+            assert p.joinpath("cmake_example-0.0.1.dist-info/licenses/LICENSE").exists()
 
-        assert len(file_names) == 3
+        assert len(file_names) == 2
         assert "cmake_example-0.0.1.dist-info" in file_names
         file_names.remove("cmake_example-0.0.1.dist-info")
-        file_names.remove("LICENSE")
         (so_file,) = file_names
 
         assert so_file.startswith("cmake_example")
@@ -208,11 +208,11 @@ def test_pep517_wheel_source_dir(virtualenv):
             entry_points = p.joinpath(
                 "cmake_example-0.0.1.dist-info/entry_points.txt"
             ).read_text()
+            assert p.joinpath("cmake_example-0.0.1.dist-info/licenses/LICENSE").exists()
 
-        assert len(file_names) == 3
+        assert len(file_names) == 2
         assert "cmake_example-0.0.1.dist-info" in file_names
         file_names.remove("cmake_example-0.0.1.dist-info")
-        file_names.remove("LICENSE")
         (so_file,) = file_names
 
         assert so_file.startswith("cmake_example")
diff --git a/tests/test_pyproject_pep518.py b/tests/test_pyproject_pep518.py
index 6905192..a3a4a53 100644
--- a/tests/test_pyproject_pep518.py
+++ b/tests/test_pyproject_pep518.py
@@ -70,11 +70,11 @@ def test_pep518_wheel(isolated, build_args):
         with wheel.open("rb") as f:
             p = zipfile.Path(f)
             file_names = [p.name for p in p.iterdir()]
+            assert p.joinpath("cmake_example-0.0.1.dist-info/licenses/LICENSE").exists()
 
-        assert len(file_names) == 3
+        assert len(file_names) == 2
         assert "cmake_example-0.0.1.dist-info" in file_names
         file_names.remove("cmake_example-0.0.1.dist-info")
-        file_names.remove("LICENSE")
         (so_file,) = file_names
 
         assert so_file.startswith("cmake_example")
@@ -119,11 +119,11 @@ def test_pep518_rebuild_build_dir(isolated, tmp_path, build_args):
         with wheel.open("rb") as f:
             p = zipfile.Path(f)
             file_names = [p.name for p in p.iterdir()]
+            assert p.joinpath("cmake_example-0.0.1.dist-info/licenses/LICENSE").exists()
 
-        assert len(file_names) == 3
+        assert len(file_names) == 2
         assert "cmake_example-0.0.1.dist-info" in file_names
         file_names.remove("cmake_example-0.0.1.dist-info")
-        file_names.remove("LICENSE")
         (so_file,) = file_names
 
         assert so_file.startswith("cmake_example")