Skip to content

updates to TomoPhantom plugin to use v3.0#2287

Merged
gfardell merged 16 commits intoTomographicImaging:masterfrom
paskino:update_tomophantom_plugin
Apr 17, 2026
Merged

updates to TomoPhantom plugin to use v3.0#2287
gfardell merged 16 commits intoTomographicImaging:masterfrom
paskino:update_tomophantom_plugin

Conversation

@paskino
Copy link
Copy Markdown
Contributor

@paskino paskino commented Feb 10, 2026

Description

Update to use TomoPhantom v3.0 from httomo channel.
Update: binaries for Tomophantom 3.0.3 provided by anaconda ccpi, and the tomo share.

We now have the python wrappers no-arch as:
https://anaconda.org/channels/ccpi/packages/tomophantom/files

And the c layer build for windows and linux:
https://anaconda.org/channels/ccpi/packages/libtomophantom/overview

This is now not linked to any specific version of Python and NumPy as it uses ctypes instead of Cython.

Depends on:

A followup will be to move to the httomo channel when

  • a suitable version of TomoPhantom on httomo, probably v3.0.3

Example Usage

No change in the user interface.

Contribution Notes

  • The content of this Pull Request (the Contribution) is intentionally submitted for inclusion in CIL (the Work) under the terms and conditions of the Apache-2.0 License
  • I confirm that the contribution does not violate any intellectual property rights of third parties

Changes

Testing you performed

Please add any demo scripts to https://github.com/TomographicImaging/CIL-Demos/tree/main/misc

Unittests on local Linux installation. Tested the following and it works as expected and as in the CIL-Demos.

Unittests on local Windows installation.

from cil.plugins import TomoPhantom as cilTomoPhantom
from cil.framework import ImageGeometry

n = 256
ig = ImageGeometry(voxel_num_x=n, 
                   voxel_num_y=n, 
                   voxel_size_x=2/n, 
                   voxel_size_y=2/n)
print(ig)
#%%
phantom2D = cilTomoPhantom.get_ImageData(num_model=1, geometry=ig)


#%%
from cil.utilities.display import show2D

show2D(phantom2D)

Related issues/links

Checklist

  • I have performed a self-review of my code
  • I have added docstrings in line with the guidance in the developer guide
  • I have updated the relevant documentation
  • I have implemented unit tests that cover any new or modified functionality
  • CHANGELOG.md has been updated with any functionality change
  • Request review from all relevant developers

@paskino paskino force-pushed the update_tomophantom_plugin branch from a63847a to 2b2dab8 Compare February 10, 2026 16:32
@paskino paskino added this to CIL work Feb 10, 2026
@github-project-automation github-project-automation bot moved this to Todo in CIL work Feb 10, 2026
@paskino paskino moved this from Todo to In Progress in CIL work Feb 10, 2026
@paskino paskino force-pushed the update_tomophantom_plugin branch from 15a82ff to a090253 Compare February 10, 2026 16:52
@paskino
Copy link
Copy Markdown
Contributor Author

paskino commented Feb 20, 2026

Currently v3.0.2 of TomoPhantom has been released however, it seems to depend on Python 3.14 only.

@paskino
Copy link
Copy Markdown
Contributor Author

paskino commented Feb 25, 2026

@paskino paskino marked this pull request as ready for review February 25, 2026 13:16
@paskino paskino requested a review from a team as a code owner February 25, 2026 13:16
@paskino paskino moved this from In Progress to Blocked in CIL work Feb 25, 2026
@paskino paskino mentioned this pull request Feb 25, 2026
10 tasks
@gfardell gfardell modified the milestone: v26.0 Apr 1, 2026
Signed-off-by: Laura Murgatroyd <60604372+lauramurgatroyd@users.noreply.github.com>
@lauramurgatroyd
Copy link
Copy Markdown
Member

lauramurgatroyd commented Apr 15, 2026

We're working on uploading a release of tomophantom v3.0.3 to the ccpi channel. We will use this or the one from httomo, whatever is ready fastest. Then we can merge in before the numpy 2 PR

https://anaconda.org/channels/ccpi/packages/tomophantom/files
https://anaconda.org/channels/ccpi/packages/libtomophantom/overview

@gfardell
Copy link
Copy Markdown
Member

gfardell commented Apr 15, 2026

I have built the binaries for windows and linux (currently available on ccpi/label/dev), to make this not pinned to a python version I removed this line:
https://github.com/dkazanc/TomoPhantom/blob/e5dede43cef35d4856ba36aee65174ad48524231/conda-recipe_library/meta.yaml#L19

For linux the binaries seem to work:

(tomo_test) tpc56154@reconvm3:~/GitHub/CIL$ conda list tomophantom
# packages in environment at /home/tpc56154/miniforge3/envs/tomo_test:
#
# Name                    Version                   Build  Channel
libtomophantom            3.0.3                         0    ccpi/label/dev
tomophantom               3.0.3              pyh2b07374_0    ccpi/label/dev
(tomo_test) tpc56154@reconvm3:~/GitHub/CIL$ python
Python 3.12.13 | packaged by conda-forge | (main, Mar  5 2026, 16:50:00) [GCC 14.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from cil.plugins import TomoPhantom
>>>

but on windows the library isn't found, it might be as simple as making sure ctypes is looking in the right place, but I think requires a code change, not just a new build of 3.0.3.

(tomo_test) C:\Users\gemst>conda list tomophantom
# packages in environment at C:\Users\gemst\miniforge3\envs\tomo_test:
#
# Name                    Version                   Build  Channel
libtomophantom            3.0.3                         0    ccpi/label/dev
tomophantom               3.0.3              pyh2b07374_0    ccpi/label/dev

(tomo_test) C:\Users\gemst>python
Python 3.10.20 | packaged by conda-forge | (main, Mar  5 2026, 16:36:49) [MSC v.1944 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from cil.plugins import TomoPhantom
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\gemst\miniforge3\envs\tomo_test\lib\site-packages\cil\plugins\TomoPhantom.py", line 21, in <module>
    import tomophantom
  File "C:\Users\gemst\miniforge3\envs\tomo_test\lib\site-packages\tomophantom\__init__.py", line 3, in <module>
    from tomophantom.TomoP2D import *
  File "C:\Users\gemst\miniforge3\envs\tomo_test\lib\site-packages\tomophantom\TomoP2D.py", line 22, in <module>
    import tomophantom.ctypes.external as external
  File "C:\Users\gemst\miniforge3\envs\tomo_test\lib\site-packages\tomophantom\ctypes\external.py", line 36, in <module>
    LIB_TOMOPHANTOM = c_shared_lib("tomophantom")
  File "C:\Users\gemst\miniforge3\envs\tomo_test\lib\site-packages\tomophantom\ctypes\__init__.py", line 44, in c_shared_lib
    raise ModuleNotFoundError(
ModuleNotFoundError: TomoPhantom links to compiled components which are installed separately and loaded using ctypes.util.find_library(). A required library, tomophantom, was not found.
>>>

EDIT: I'd built the dll as 32bit, making sure it's built as 64bit fixed it.

@casperdcl
Copy link
Copy Markdown
Member

casperdcl commented Apr 15, 2026

note that dkazanc/TomoPhantom#124 could be split into 2 PRs:

  • scikit-build-core (easy, quick)
  • migrate ctypes to nanobind/pybind11 etc (hard, not required)

the former would allow a simple cross-platform approach like we use in Wrappers/Python/cil/framework/cilacc.py

@gfardell
Copy link
Copy Markdown
Member

This is now passing tests on windows locally. So I think we can promote the binaries ccpi/label/dev -> main and merge this PR.

@gfardell gfardell self-requested a review April 16, 2026 13:54
@gfardell
Copy link
Copy Markdown
Member

I'm not sure if the changes to build.yml are needed. @casperdcl do you know? I suspect that was just as @paskino was testing.

@gfardell gfardell removed their request for review April 16, 2026 14:01
@gfardell gfardell self-assigned this Apr 16, 2026
@gfardell gfardell moved this from Blocked to In Progress in CIL work Apr 16, 2026
@gfardell gfardell force-pushed the update_tomophantom_plugin branch from 8bbe58f to 330752d Compare April 16, 2026 14:07
@gfardell gfardell moved this from In Progress to Priority review in CIL work Apr 16, 2026
Copy link
Copy Markdown
Member

@lauramurgatroyd lauramurgatroyd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please open an issue about windows support when you merge

Comment thread scripts/requirements-test.yml
Comment thread README.md Outdated
Comment thread CHANGELOG.md
Comment thread scripts/requirements-test-windows.yml
Comment thread .github/workflows/build.yml Outdated
Comment thread recipe/meta.yaml Outdated
Comment thread README.md Outdated
Co-authored-by: Casper da Costa-Luis <casper.dcl@physics.org>
Signed-off-by: Casper da Costa-Luis <casper.dcl@physics.org>
@gfardell
Copy link
Copy Markdown
Member

Tests all pass on the duplicate local branch.

https://github.com/TomographicImaging/CIL/actions/runs/24558373845/workflow

@gfardell gfardell merged commit 38b8726 into TomographicImaging:master Apr 17, 2026
11 checks passed
@github-project-automation github-project-automation bot moved this from Priority review to Done in CIL work Apr 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

CIL channel tomophantom - updating to latest version.

4 participants