Skip to content

Commit d941a08

Browse files
committed
Add wheel repair test
Signed-off-by: Cristian Le <git@lecris.dev>
1 parent 79614d3 commit d941a08

File tree

17 files changed

+196
-0
lines changed

17 files changed

+196
-0
lines changed

tests/conftest.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import dataclasses
55
import importlib.util
66
import os
7+
import platform
78
import shutil
89
import subprocess
910
import sys
@@ -53,6 +54,12 @@ def pep518_wheelhouse(tmp_path_factory: pytest.TempPathFactory) -> Path:
5354
"virtualenv",
5455
"wheel",
5556
]
57+
if platform.system() == "Linux":
58+
packages.append("pyelftools")
59+
if platform.system() == "Darwin":
60+
packages.append("macholib")
61+
if platform.system() == "Windows":
62+
packages.append("pefile")
5663

5764
if importlib.util.find_spec("cmake") is not None:
5865
packages.append("cmake")
@@ -341,6 +348,15 @@ def package_pep639_pure(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Pack
341348
return package
342349

343350

351+
@pytest.fixture
352+
def repair_wheel(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> PackageInfo:
353+
package = PackageInfo(
354+
"repair_wheel",
355+
)
356+
process_package(package, tmp_path, monkeypatch)
357+
return package
358+
359+
344360
def which_mock(name: str) -> str | None:
345361
if name in {"ninja", "ninja-build", "cmake3", "samu", "gmake", "make"}:
346362
return None
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
cmake_minimum_required(VERSION 3.15...3.26)
2+
3+
project(${SKBUILD_PROJECT_NAME} LANGUAGES CXX)
4+
5+
include(GNUInstallDirs)
6+
include(CMakePackageConfigHelpers)
7+
8+
find_package(Base CONFIG REQUIRED)
9+
find_package(Python COMPONENTS Interpreter Development.Module)
10+
11+
add_executable(main src/main.cpp)
12+
add_library(other SHARED src/other.cpp)
13+
python_add_library(_module MODULE src/module.cpp WITH_SOABI)
14+
15+
target_link_libraries(other PRIVATE base::base)
16+
target_link_libraries(main PRIVATE other)
17+
target_link_libraries(_module PRIVATE base::base)
18+
19+
install(TARGETS main other)
20+
install(TARGETS _module DESTINATION ".")
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@PACKAGE_INIT@
2+
3+
include(${CMAKE_CURRENT_LIST_DIR}/BaseTargets.cmake)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
cmake_minimum_required(VERSION 3.15...3.26)
2+
3+
project(Base LANGUAGES CXX)
4+
5+
include(GNUInstallDirs)
6+
include(CMakePackageConfigHelpers)
7+
8+
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
9+
10+
add_library(base SHARED)
11+
12+
target_sources(base PRIVATE base.cpp)
13+
set_property(
14+
TARGET base
15+
APPEND
16+
PROPERTY PUBLIC_HEADER base.h)
17+
target_include_directories(
18+
base PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
19+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
20+
21+
install(TARGETS base EXPORT BaseTargets)
22+
install(
23+
EXPORT BaseTargets
24+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/base
25+
NAMESPACE base::)
26+
configure_package_config_file(
27+
BaseConfig.cmake.in BaseConfig.cmake
28+
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Base)
29+
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/BaseConfig.cmake
30+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/base)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include <iostream>
2+
3+
#include "base.h"
4+
5+
void base::hello() {
6+
std::cout << "Hello, World!" << std::endl;
7+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#pragma once
2+
3+
namespace base {
4+
void hello();
5+
}

tests/packages/repair_wheel/extern/base_project/__init__.py

Whitespace-only changes.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[build-system]
2+
requires = ["scikit-build-core"]
3+
build-backend = "scikit_build_core.build"
4+
5+
[project]
6+
name = "base_project"
7+
version = "0.1.0"
8+
9+
[project.entry-points."cmake.root"]
10+
Base = "base_project"
11+
12+
[tool.scikit-build]
13+
wheel.install-dir = "base_project"
14+
wheel.repair = true
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[build-system]
2+
requires = ["scikit-build-core"]
3+
build-backend = "scikit_build_core.build"
4+
5+
[project]
6+
name = "repair_wheel"
7+
version = "0.1.0"
8+
9+
[tool.scikit-build]
10+
build.requires = ["base_project @ {root:uri}/extern"]
11+
wheel.install-dir = "repair_wheel"
12+
wheel.repair = true
13+
14+
[project.scripts]
15+
main = "repair_wheel.__main__:run"

tests/packages/repair_wheel/python/repair_wheel/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)