diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index c306a55..3188800 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -32,8 +32,6 @@ jobs: steps: - uses: actions/checkout@v4 - with: - submodules: recursive - name: Log in to the GitHub Container registry uses: docker/login-action@v3 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 81b6dfd..cfe20bd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -39,8 +39,6 @@ jobs: steps: - uses: actions/checkout@v4 - with: - submodules: recursive - name: Get conda uses: conda-incubator/setup-miniconda@v3 diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index c4cb4cb..0000000 --- a/.gitmodules +++ /dev/null @@ -1,6 +0,0 @@ -[submodule "external/pybind11"] - path = external/pybind11 - url = https://github.com/pybind/pybind11.git -[submodule "external/awkward"] - path = external/awkward - url = https://github.com/scikit-hep/awkward.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e65615..dd39668 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,9 @@ set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) +set(AWKWARD_VERSION "v2.5.0") +set(PYBIND11_VERSION "v2.11.1") + find_package( Python COMPONENTS Interpreter Development.Module @@ -25,8 +28,30 @@ find_package(Geant4 REQUIRED CONFIG COMPONENTS gdml) message(STATUS "Using Geant4 ${Geant4_VERSION} from ${Geant4_DIR}") message(STATUS "Using Python ${Python_VERSION} from ${Python_EXECUTABLE}") -add_subdirectory(external/awkward/header-only) -add_subdirectory(external/pybind11) +include(FetchContent) + +FetchContent_Declare( + awkward-headers + URL https://github.com/scikit-hep/awkward/releases/download/${AWKWARD_VERSION}/header-only.zip +) +FetchContent_GetProperties(awkward-headers) +if (NOT awkward-headers_POPULATED) + FetchContent_Populate(awkward-headers) + add_subdirectory(${awkward-headers_SOURCE_DIR} + ${awkward-headers_BINARY_DIR} EXCLUDE_FROM_ALL) +endif () + +FetchContent_Declare( + pybind11 + GIT_REPOSITORY https://github.com/pybind/pybind11.git + GIT_TAG ${PYBIND11_VERSION} + DOWNLOAD_EXTRACT_TIMESTAMP 1) +FetchContent_GetProperties(pybind11) +if (NOT pybind11_POPULATED) + FetchContent_Populate(pybind11) + add_subdirectory(${pybind11_SOURCE_DIR} ${pybind11_BINARY_DIR} + EXCLUDE_FROM_ALL) +endif () file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS "${PROJECT_SOURCE_DIR}/src/geant4_application/src/*.cpp") @@ -37,13 +62,15 @@ file(GLOB_RECURSE PYTHON_SOURCES CONFIGURE_DEPENDS pybind11_add_module(${PYTHON_MODULE_NAME} MODULE ${SOURCES} ${PYTHON_SOURCES}) target_compile_definitions( - ${PYTHON_MODULE_NAME} PRIVATE VERSION_INFO=${PROJECT_VERSION} - GEANT4_VERSION=${Geant4_VERSION} - ) + ${PYTHON_MODULE_NAME} + PRIVATE VERSION_INFO=${PROJECT_VERSION} GEANT4_VERSION=${Geant4_VERSION} + AWKWARD_VERSION=${AWKWARD_VERSION} + PYBIND11_VERSION=${PYBIND11_VERSION}) target_include_directories( - ${PYTHON_MODULE_NAME} PRIVATE ${PROJECT_SOURCE_DIR}/src/geant4_application/include - ${Geant4_INCLUDE_DIRS}) + ${PYTHON_MODULE_NAME} + PRIVATE ${PROJECT_SOURCE_DIR}/src/geant4_application/include + ${Geant4_INCLUDE_DIRS}) target_link_libraries( ${PYTHON_MODULE_NAME} PRIVATE ${Geant4_LIBRARIES} awkward::layout-builder diff --git a/external/awkward b/external/awkward deleted file mode 160000 index ffc1533..0000000 --- a/external/awkward +++ /dev/null @@ -1 +0,0 @@ -Subproject commit ffc1533d1cef189ae9aa38903b0101570e8f7e64 diff --git a/external/pybind11 b/external/pybind11 deleted file mode 160000 index 8a099e4..0000000 --- a/external/pybind11 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 8a099e44b3d5f85b20f05828d919d2332a8de841 diff --git a/src/geant4_python_application/__init__.py b/src/geant4_python_application/__init__.py index b10bb18..48ecde2 100644 --- a/src/geant4_python_application/__init__.py +++ b/src/geant4_python_application/__init__.py @@ -1,10 +1,10 @@ from __future__ import annotations -import os -import sys import ctypes -import subprocess +import os import shutil +import subprocess +import sys import warnings geant4_config = shutil.which("geant4-config") @@ -55,9 +55,7 @@ def datasets() -> list[(str, str, str)]: datasets = subprocess.check_output( [geant4_config, "--datasets"], encoding="utf-8" ).strip() - return [ - tuple(line.split()) for line in datasets.split("\n") if line.strip() != "" - ] + return [tuple(line.split()) for line in datasets.split("\n") if line.strip() != ""] def check_datasets() -> bool: