From 6307fb9f0ce05db39c7ed974092f7b05a1038b5c Mon Sep 17 00:00:00 2001 From: Kris Thielemans Date: Fri, 1 Nov 2024 19:09:57 +0000 Subject: [PATCH 1/6] add some instructions to use pip install --- .gitignore | 2 ++ python/README.md | 29 ++++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 7b8c4c5..5483edf 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,8 @@ /cpp/build/ /python/petsird/ __pycache__/ +build/ +petsird.egg-info/ # Common editor backups /.vscode/ diff --git a/python/README.md b/python/README.md index 4dc83c6..4f682e3 100644 --- a/python/README.md +++ b/python/README.md @@ -1,6 +1,33 @@ # PETSIRD basic Python example -This directory contains some Python example code to read/write PETSIRD data. You need to `yardl generate` in the `model` directory first. +This directory contains some Python example code to read/write PETSIRD data. + +## Pre-installation + +You will need the Python files generated by yardl. You have a few options. + +### Use PyPI + +```sh +python3 -m venv ~/petsirdenv +source ~/petsirdenv/bin/activate +pip install petsird +``` + +### Use the model files from your local clone + +(This option needs the `yardl` binary, either download it, or use our devcontainer or GitHub CodeSpace.) + +You need to `yardl generate` in the `model` directory first. This will create the Python package files in a `petsird` +subfolder. Optionally install those into your venv +```sh +python3 -m venv ~/petsirdenv +source ~/petsirdenv/bin/activate +cd python +pip install . +``` + +## Usage The Python code shows piping the compact binary format to standard out and reading it from standard in. This can be used as follows: From c30ccfc0d59816457846118c5315ec035c3fa5ab Mon Sep 17 00:00:00 2001 From: Kris Thielemans Date: Fri, 1 Nov 2024 19:20:53 +0000 Subject: [PATCH 2/6] Update README for PyPI package --- python/README.pypi.md | 9 +++++++++ python/pyproject.toml | 6 ++++-- 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 python/README.pypi.md diff --git a/python/README.pypi.md b/python/README.pypi.md new file mode 100644 index 0000000..12f0621 --- /dev/null +++ b/python/README.pypi.md @@ -0,0 +1,9 @@ +# PETSIRD Python SDK + +The [Emission Tomography Standardization Initiative (ETSI)](https://etsinitiative.org/) +is working towards establishing a standard for PET Raw Data, called PETSIRD ("PET ETSI Raw Data"). + +This python package contains the python SDK to read/write PETSIRD data. + +Examples for how to use this package are available at +https://github.com/ETSInitiative/PETSIRD/tree/main/python diff --git a/python/pyproject.toml b/python/pyproject.toml index b15f89a..8c292b9 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta" name = "petsird" dynamic = ["version"] description = "Library and tools for working with PET Emission Tomography Standardization Initiative Raw Data (PETSIRD) data" -readme = "README.md" +readme = "README.pypi.md" authors = [ # TODO {name = "Kris Thielemans", email = "k.thielemans@ucl.ac.uk"}, @@ -28,7 +28,9 @@ classifiers = [ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", - "Programming Language :: Python :: 3 :: Only"] + "Programming Language :: Python :: 3 :: Only", + "Intended Audience :: Science/Research", + "Topic :: Scientific/Engineering :: Medical Science Apps."] [tool.setuptools.packages.find] include = ["petsird", "petsird.*"] From 810f7cc644d0b5a9066ec15fc0b0228cd75612fc Mon Sep 17 00:00:00 2001 From: Kris Thielemans Date: Fri, 1 Nov 2024 19:28:39 +0000 Subject: [PATCH 3/6] update main README to refer to PyPI --- README.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6db6314..7806c18 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # PETSIRD draft data model and examples -The purpose of this repo is to have a simple working example of a data model for PET imaging (list mode data). This is **not complete**, and aspects do not follow the actual proposal of PETSIRD yet. +The purpose of this repo is to have a working example of a data model for PET imaging (list mode data). This is **not complete**, and aspects do not follow the actual proposal of PETSIRD yet. ## Background @@ -9,9 +9,13 @@ is working towards establishing a standard for PET Raw Data, called PETSIRD ("PE The specification uses the [yardl](https://aka.ms/yardl) tool to define the model. `yardl` can be used to read the specification (in the `model` directory) and -generate an SDK for both C++ and API to read/write PETSIRD data. +generate an SDK for both C++ and Python to read/write PETSIRD data. -## To get started quickly: +## To get started as a Python user: + +If you don't want to modify the yardl model, clone this repository and follow instructions in the [`python/README.md`](python/README.md). + +## To get started quickly as a developer: 1. Open this repo in [GitHub Codespaces](https://code.visualstudio.com/docs/remote/codespaces) or in a [VS Code devcontainer](https://code.visualstudio.com/docs/devcontainers/containers). @@ -26,3 +30,5 @@ This codespace/container will contain all necessary tools, including `yardl` its 4. Have a look at (and try!) the examples in the [`cpp`](cpp/README.md) and/or [`python`](python/README.md) directories. + + From a60beca899f82e7001f85f4d0cc5a41754514384 Mon Sep 17 00:00:00 2001 From: Kris Thielemans Date: Fri, 1 Nov 2024 19:45:14 +0000 Subject: [PATCH 4/6] change CI description --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fb07fc1..276fe72 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: cppVersion: [17] environment: pypi permissions: {id-token: write} - name: Validate Python and C++${{ matrix.cppVersion }} + name: Validate Python and C++${{ matrix.cppVersion }} and deploy to PyPI runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 From 64e4d1c65276058712eb0c96d9f3a6bd2021b137 Mon Sep 17 00:00:00 2001 From: Kris Thielemans Date: Fri, 1 Nov 2024 22:20:43 +0000 Subject: [PATCH 5/6] Apply suggestions from code review Co-authored-by: Casper da Costa-Luis --- .gitignore | 4 ++-- python/README.md | 16 +++++++--------- python/README.pypi.md | 9 +++++---- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 5483edf..ee6a3b1 100644 --- a/.gitignore +++ b/.gitignore @@ -2,8 +2,8 @@ /cpp/build/ /python/petsird/ __pycache__/ -build/ -petsird.egg-info/ +/python/build/ +/python/petsird.egg* # Common editor backups /.vscode/ diff --git a/python/README.md b/python/README.md index 4f682e3..e65d1bd 100644 --- a/python/README.md +++ b/python/README.md @@ -2,11 +2,9 @@ This directory contains some Python example code to read/write PETSIRD data. -## Pre-installation +## Install -You will need the Python files generated by yardl. You have a few options. - -### Use PyPI +Some python code is generated by `yardl` and included in the PyPI distribution. ```sh python3 -m venv ~/petsirdenv @@ -19,12 +17,12 @@ pip install petsird (This option needs the `yardl` binary, either download it, or use our devcontainer or GitHub CodeSpace.) You need to `yardl generate` in the `model` directory first. This will create the Python package files in a `petsird` -subfolder. Optionally install those into your venv +subfolder. + ```sh -python3 -m venv ~/petsirdenv -source ~/petsirdenv/bin/activate -cd python -pip install . +cd ../model +yardl generate +pip install --editable ../python ``` ## Usage diff --git a/python/README.pypi.md b/python/README.pypi.md index 12f0621..6cd14cb 100644 --- a/python/README.pypi.md +++ b/python/README.pypi.md @@ -1,9 +1,10 @@ # PETSIRD Python SDK The [Emission Tomography Standardization Initiative (ETSI)](https://etsinitiative.org/) -is working towards establishing a standard for PET Raw Data, called PETSIRD ("PET ETSI Raw Data"). +is working towards establishing a standard for PET Raw Data, called PETSIRD ("Positron Emission Tomography Standardization Initiative Raw Data"). -This python package contains the python SDK to read/write PETSIRD data. +Read & write PETSIRD data in Python. -Examples for how to use this package are available at -https://github.com/ETSInitiative/PETSIRD/tree/main/python +## Examples + +See [ETSInitiative/PETSIRD:python](https://github.com/ETSInitiative/PETSIRD/tree/main/python). From b8adf4ab75036162dec676527e08e98d868254b4 Mon Sep 17 00:00:00 2001 From: Kris Thielemans Date: Fri, 1 Nov 2024 22:21:13 +0000 Subject: [PATCH 6/6] one more code review Co-authored-by: Casper da Costa-Luis --- python/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/README.md b/python/README.md index e65d1bd..e4eba3f 100644 --- a/python/README.md +++ b/python/README.md @@ -12,7 +12,7 @@ source ~/petsirdenv/bin/activate pip install petsird ``` -### Use the model files from your local clone +## Local Development (This option needs the `yardl` binary, either download it, or use our devcontainer or GitHub CodeSpace.)