Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/PyWhlConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ function(add_pywhl_package targetName)
set(args_LICENSE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
endif()

if(NOT EXISTS "${args_LICENSE_FILE}")
if(NOT EXISTS "${args_LICENSE_FILE}" AND NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${args_LICENSE_FILE}")
message(FATAL_ERROR "License file not found: ${args_LICENSE_FILE}")
endif()

Expand Down Expand Up @@ -194,7 +194,7 @@ function(add_pywhl_package targetName)
list(GET info 0 pkgname2)
list(GET info 1 tgts)
if("${modname}" STREQUAL "${pkgname2}")
set(modtargets "${tgts}")
list(APPEND modtargets ${tgts})
endif()
endforeach()
if("${modmanifest}" STREQUAL "NOTFOUND")
Expand Down Expand Up @@ -258,7 +258,7 @@ function(add_pywhl_package targetName)
"${build_dir}" --package "${whl_file}"
OUTPUT "${whl_file}"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
DEPENDS "${PYWHL_SCRIPT_FILE_PATH}" "${manifest_file}"
DEPENDS "${PYWHL_SCRIPT_FILE_PATH}" "${manifest_file}" ${targets}
DEPFILE "${package_depfile}")

add_custom_command(
Expand All @@ -277,6 +277,7 @@ function(add_pywhl_package targetName)
"${manifest_file}" --dep-file "${editable_depfile}" --work-dir
"${build_dir}" --package "${editable_whl_file}" --editable
OUTPUT "${editable_whl_file}" "${editable_depfile}"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
DEPENDS "${PYWHL_SCRIPT_FILE_PATH}" "${manifest_file}"
DEPFILE "${editable_depfile}")

Expand All @@ -289,7 +290,7 @@ function(add_pywhl_package targetName)
DEPENDS "${editable_depfile}" "${PYWHL_SCRIPT_FILE_PATH}"
"${manifest_file}")

add_custom_target(${targetName} DEPENDS "${whl_file}" "${package_depfile}")
add_custom_target(${targetName} DEPENDS "${whl_file}" "${package_depfile}" ${targets})

set_target_properties(${args_DEV_TARGET} PROPERTIES WHL_FILE "${whl_file}")
set_target_properties(${args_DEV_TARGET} PROPERTIES EDITABLE_WHL_FILE
Expand Down
12 changes: 8 additions & 4 deletions src/pywhl.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def instance(cls) -> "CMakeBuildWheel":

def __init__(self, args: Args):
CMakeBuildWheel._instance = self
self.args: Args = args
self.work_dir: Path = args.work_dir
tagpyversion = f"cp{sys.version_info.major}{sys.version_info.minor}"
self.tag: str = f"{tagpyversion}-{tagpyversion}-{sys.platform}_{platform.machine()}"
Expand Down Expand Up @@ -422,11 +423,14 @@ def build_wheel(
_config_settings: dict[str, object] | None = None,
_metadata_directory: str | None = None,
) -> Path:
whl_file = Path(out_dir) / (
self.whl_file_name or f"{self.build_info.name}-{self.build_info.version}-{self.tag}.whl"
)
if self.args.editable:
whl_file = Path(out_dir) / f"{self.build_info.name}-{self.build_info.version}-0.editable-py3-none-any.whl"
else:
whl_file = Path(out_dir) / (
self.whl_file_name or f"{self.build_info.name}-{self.build_info.version}-{self.tag}.whl"
)
with zipfile.ZipFile(whl_file, "w", compression=zipfile.ZIP_DEFLATED, compresslevel=0) as archive:
for fpath, src_file, contents in self._generate_wheel_content():
for fpath, src_file, contents in self._generate_wheel_content(self.args.editable):
if src_file is not None:
archive.write(src_file, fpath)
elif contents is not None:
Expand Down
4 changes: 2 additions & 2 deletions tests/nanobind_example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ add_pywhl_module(nanobind_example
${CMAKE_CURRENT_SOURCE_DIR}/scripts/__init__.py@scripts
DATA
# Folders
${CMAKE_CURRENT_SOURCE_DIR}/config
config
${CMAKE_CURRENT_SOURCE_DIR}/pyext_config@pyext
# Files
${CMAKE_CURRENT_BINARY_DIR}/version_info.txt
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt@scripts
CMakeLists.txt@scripts
)

add_pywhl_package(nanobind_example
Expand Down
Loading