From c4c738b0e3090f49f5a4944ec7d910bb2c125c82 Mon Sep 17 00:00:00 2001 From: Kris Thielemans Date: Sat, 12 Jul 2025 22:57:58 +0100 Subject: [PATCH 1/2] update to PETSIRD 0.7.2 and remove python --- .devcontainer/Dockerfile | 2 +- PETSIRD | 2 +- README.md | 40 ++++++++++++++++++++++------------------ cpp/CMakeLists.txt | 25 ++++++++++++++++++++++--- cpp/README.md | 2 +- environment.yml | 12 ++++-------- justfile | 19 +++++++++++++++++++ python/README.md | 9 --------- python/start.py | 4 ---- 9 files changed, 70 insertions(+), 45 deletions(-) create mode 100644 justfile delete mode 100644 python/README.md delete mode 100644 python/start.py diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 8677bde..fe9b550 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -87,7 +87,7 @@ RUN mkdir -p /home/vscode/.local/share/CMakeTools \ && chown vscode:conda /home/vscode/.local/share/CMakeTools/cmake-tools-kits.json # Install the yardl tool -ARG YARDL_VERSION=0.6.2 +ARG YARDL_VERSION=0.6.3 RUN wget --quiet "https://github.com/microsoft/yardl/releases/download/v${YARDL_VERSION}/yardl_${YARDL_VERSION}_linux_x86_64.tar.gz" \ && tar -xzf "yardl_${YARDL_VERSION}_linux_x86_64.tar.gz" \ && mv yardl "/opt/conda/envs/${CONDA_ENVIRONMENT_NAME}/bin/" \ diff --git a/PETSIRD b/PETSIRD index ae3a048..96c1dc0 160000 --- a/PETSIRD +++ b/PETSIRD @@ -1 +1 @@ -Subproject commit ae3a0484a128f805a2143cc0d010d01557cf902f +Subproject commit 96c1dc0120fea2900b504fad1ab241aa2b1bd7d9 diff --git a/README.md b/README.md index 449e684..701ae6e 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,7 @@ -# PETSIRD template for use cases +# PETSIRD template for C++ use cases The purpose of this repo is to provide a starting point for developing software that uses PETSIRD. -It is currently mostly needed/useful for C++ development, but is also useful for Python developers -who want to experiment with development of PETSIRD itself. +It is currently mostly needed/useful for C++ development. ## Background The [Emission Tomography Standardization Initiative (ETSI)](https://etsinitiative.org/) @@ -18,7 +17,14 @@ These instructions will use `YourRepoName` for the name of your new repository. Easiest is to start from GitHub: 1. Navigate to the URL of this repo: https://github.com/ETSInitiative/PETSIRDUseCaseTemplate 2. Click on the `Use this template` button and create your own repo -3. Pull it to your own local machine and modify + +### Using your repo + +1. Open ***your*** repo in [GitHub Codespaces](https://code.visualstudio.com/docs/remote/codespaces) or +in a [VS Code devcontainer](https://code.visualstudio.com/docs/devcontainers/containers). +This codespace/container will contain all necessary tools, including `yardl` itself, as well as your repository.
+(Alternatively, clone to your local computer with `git clone --recurse-submodules `, download `yardl`, install dependencies etc.) +2. Start with basic house-keeping 1. Search-and-replace all occurences of `PETSIRDUseCaseTemplate` with `YourRepoName` 2. Update the README.md to remove references to this template and write something about what your repo is going to do 3. Update the `environment.yml`to include what you need. For instance, if you need ROOT, add something like `- root=6.28.0` @@ -27,19 +33,17 @@ Easiest is to start from GitHub: git commit -a -m "Updated template to YourRepoName" git push ``` - -### Using your repo - -1. Open ***your*** repo in [GitHub Codespaces](https://code.visualstudio.com/docs/remote/codespaces) or -in a [VS Code devcontainer](https://code.visualstudio.com/docs/devcontainers/containers). -This codespace/container will contain all necessary tools, including `yardl` itself, as well as your repository. -2. Use `yardl` to generate C++ and Python code for the model: - ```sh - cd YourRepoName - cd PETSIRD/model - yardl generate - cd ../.. - ``` -3. Start working in either the [`cpp`](cpp/README.md) and/or [`python`](python/README.md) directories. +3. Start working in the [`cpp`](cpp/README.md) directory. +4. Edit the [`justfile`](justfile), e.g. to add a `@run` target +5. type `just build` (or `just run`) + +Note: if you don't want to use `just`, you will have to use `yardl` to generate C++ and Python +code for the model: +```sh +cd YourRepoName +cd PETSIRD/model +yardl generate +cd ../.. +``` diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 748450a..74cc7fb 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -1,17 +1,36 @@ cmake_minimum_required(VERSION 3.12.0) # older would work, but could give warnings on policy CMP0074 -project(PETSIRDUseCaseTemplate VERSION 0.2.0) +project(PETSIRDUseCaseTemplate VERSION 0.7.2) set(CMAKE_CXX_STANDARD 17) +#Set the build type to Release if not specified +if (NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Release CACHE STRING + "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." + FORCE) +endif () + if(WIN32) add_compile_options(/W3 /WX) else() add_compile_options(-Wall -Wextra -pedantic) endif() +set(PETSIRD_dir ../PETSIRD/cpp/generated) +add_subdirectory(${PETSIRD_dir} PETSIRD_generated) + +# Add any packages, below is an example for ROOT (unlikely you'll need that one though!) +# find_package(ROOT REQUIRED COMPONENTS Tree) + # Example lines for a new executable # add_executable(my_prog my_prog.cpp) +# target_include_directories(my_prog PUBLIC ${PETSIRD_dir}) +# needed for helpers +# target_include_directories(my_prog PUBLIC ${PETSIRD_dir}/..) +# target_include_directories(my_prog PUBLIC ${PETSIRD_dir}/../helpers/include) # target_link_libraries(my_prog PUBLIC petsird_generated) -# install(TARGETS my_prog DESTINATION bin) -add_subdirectory(../PETSIRD/cpp/generated PETSIRD_generated) +# add any dependencies on packages here +# target_link_libraries(my_prog PUBLIC ROOT::Tree) + +# install(TARGETS my_prog DESTINATION bin) diff --git a/cpp/README.md b/cpp/README.md index af2056c..88f40e2 100644 --- a/cpp/README.md +++ b/cpp/README.md @@ -2,7 +2,7 @@ This directory provides a skeleton for C++ example code to read/write PETSIRD data. You need to `yardl generate` in the `model` directory first. -Check the example in the PRDdefinition repo first. +Check the example in the PETSIRD repo first. 1. Compile the code: ```sh diff --git a/environment.yml b/environment.yml index 9e85d4b..8e54cb4 100644 --- a/environment.yml +++ b/environment.yml @@ -6,16 +6,12 @@ dependencies: - bash-completion>=2.11 - cmake>=3.21.3 - fmt>=8.1.1 - - compilers - - h5py>=3.7.0 + - cxx-compiler - hdf5>=1.12.1 - howardhinnant_date>=3.0.1 - - ipykernel>=6.19.2 + - just=1.36.0 - ninja>=1.11.0 - nlohmann_json>=3.11.2 - - numpy>=1.24.3 - - python>=3.11.3 - - matplotlib - shellcheck>=0.8.0 - - xtensor-fftw>=0.2.5 - - xtensor>=0.24.2 + - xtensor>=0.24.2, <0.26.0 + - xtensor-blas diff --git a/justfile b/justfile new file mode 100644 index 0000000..c62a5c4 --- /dev/null +++ b/justfile @@ -0,0 +1,19 @@ +set shell := ['bash', '-ceuo', 'pipefail'] + +default: run + +@ensure-build-dir: + mkdir -p cpp/build + +@generate: + cd PETSIRD/model; \ + yardl generate + +@configure: generate ensure-build-dir + cd cpp/build; \ + cmake -GNinja .. + +@build: generate configure + cd cpp/build; \ + ninja + diff --git a/python/README.md b/python/README.md deleted file mode 100644 index b5d6ff5..0000000 --- a/python/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# PETSIRD basic Python example - -As you can now install the `petsird` package from PyPI, you likely no longer -need this repository and can just use `pip install petsird`. -You can of course use the Python package generated from the local PETSIRD -clone (`cd python; pip install .`). See -https://github.com/ETSInitiative/PETSIRD/tree/main/python#readme -for more information. - diff --git a/python/start.py b/python/start.py deleted file mode 100644 index 1e22e08..0000000 --- a/python/start.py +++ /dev/null @@ -1,4 +0,0 @@ -import sys -import petsird -help(petsird.BinaryPETSIRDReader) - From 43f6fbf53af2bb49edf881ecec047071cec7175d Mon Sep 17 00:00:00 2001 From: Kris Thielemans Date: Sat, 12 Jul 2025 23:25:52 +0100 Subject: [PATCH 2/2] fix CI --- .github/workflows/ci.yml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0784801..fc3853b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,12 +32,13 @@ jobs: with: activate-environment: yardl environment-file: temp-ci-environment.yml + miniforge-version: latest - name: Install yardl run: | rm temp-ci-environment.yml YARDL_DIR=${{github.workspace}}/yardl mkdir ${YARDL_DIR} - YARDL_VERSION=0.6.2 + YARDL_VERSION=0.6.3 wget --quiet "https://github.com/microsoft/yardl/releases/download/v${YARDL_VERSION}/yardl_${YARDL_VERSION}_linux_x86_64.tar.gz" tar -xzf "yardl_${YARDL_VERSION}_linux_x86_64.tar.gz" -C "${YARDL_DIR}" rm "yardl_${YARDL_VERSION}_linux_x86_64.tar.gz" @@ -48,12 +49,6 @@ jobs: cd PETSIRD/model yardl generate - - name: Python - run: | - pip install ./PETSIRD/python - cd python - python start.py - - name: Cpp run: | cd cpp && mkdir -p build && cd build