highdicom icon indicating copy to clipboard operation
highdicom copied to clipboard

Add Python 3.12 CI tests

Open DimitriPapadopoulos opened this issue 10 months ago • 12 comments

DimitriPapadopoulos avatar Oct 11 '23 20:10 DimitriPapadopoulos

I understand this depends on pillow-jpls, doesn't it?

I have opened issue https://github.com/planetmarshall/pillow-jpls/issues/20.

DimitriPapadopoulos avatar Oct 13 '23 14:10 DimitriPapadopoulos

I understand this depends on pillow-jpls, doesn't it?

I have opened issue https://github.com/planetmarshall/pillow-jpls/issues/20.

Yes that's right, thanks for notifying upstream

CPBridge avatar Oct 13 '23 15:10 CPBridge

Is there a reason for pillow-jpls not being an extra like pylibjpeg et al?

erikogabrielsson avatar Nov 16 '23 14:11 erikogabrielsson

I think this is because some kind of JPEG library is needed. From the Installation guide:

The library relies on the underlying pydicom package for decoding of pixel data, which internally delegates the task to either the pillow or the pylibjpeg packages. Since pillow is a dependency of highdicom and will automatically be installed, some transfer syntax can thus be readily decoded and encoded (baseline JPEG, JPEG-2000, JPEG-LS). Support for additional transfer syntaxes (e.g., lossless JPEG) requires installation of the pylibjpeg package as well as the pylibjpeg-libjpeg and pylibjpeg-openjpeg packages. Since pylibjpeg-libjpeg is licensed under a copyleft GPL v3 license, it is not installed by default when you install highdicom.

DimitriPapadopoulos avatar Nov 16 '23 14:11 DimitriPapadopoulos

Sure, but if a user need to read Jpeg-LS it would be easy to install the extra. Pillow typically supports Jpeg and Jpeg 2000 without any extra packages.

erikogabrielsson avatar Nov 16 '23 15:11 erikogabrielsson

That's correct. The main reason that pylibjpeg is optional is licence considerations. Since there are no such issues with pillow-jpls, we didn't make it optional. However if things like this holdup with 3.12 occur, it may make sense to make it optional too.

Generally we have been a bit wary of this approach of having a confusing mess of optional dependencies

CPBridge avatar Nov 16 '23 15:11 CPBridge

Thanks for the clarification @CPBridge. I agree that optional dependencies can be messy and that you should consider making it optional if it looks like its no longer maintained.

erikogabrielsson avatar Nov 16 '23 15:11 erikogabrielsson

So the idea would be to add a try: before import pillow_jpls and emit an error message suggesting to install the module if except ImportError? https://github.com/ImagingDataCommons/highdicom/blob/0f43f8e805bfc9be5256976f8eb984c7e45c3c5e/src/highdicom/frame.py#L260-L261

DimitriPapadopoulos avatar Nov 16 '23 15:11 DimitriPapadopoulos

I (too) made a PR to pillow-jpls for Python 3.12 and Pillow 10 support.

Regarding reading mpressed transfer syntaxes other than standard jpeg and jpeg 2000, wsidicom uses imagecodecs for decoding and encoding jpeg 12 bit, jpeg lossless, and jpeg ls.

erikogabrielsson avatar Dec 10 '23 07:12 erikogabrielsson

Thanks @erikogabrielsson . I had sort of hoped that pillow-jpls would come back to life and save us from having to work around this, but that is looking increasingly less likely. I will look into whether imagecodecs could be a good alternative.

CPBridge avatar Dec 10 '23 15:12 CPBridge

From what I understand, highdicom only uses pillow-jpls to enable encoding? Decoding can only be done if having the libjpeg extra with pylibjpeg-libjpeg. I did a quick test with:

return jpegls_encode(array)

in the jpeg ls statement in frame.py and it passed the tests.

erikogabrielsson avatar Dec 10 '23 21:12 erikogabrielsson

Thanks @erikogabrielsson . I had sort of hoped that pillow-jpls would come back to life and save us from having to work around this, but that is looking increasingly less likely. I will look into whether imagecodecs could be a good alternative.

Looks like the issue is now addressed. Hopefulle we will se a build for 3.12 soon.

erikogabrielsson avatar Dec 17 '23 08:12 erikogabrielsson