TomoPhantom icon indicating copy to clipboard operation
TomoPhantom copied to clipboard

Upload package to pypi

Open purepani opened this issue 9 months ago • 4 comments

I have been going through a few imaging packages to try and get them converted to a Python package rather than just available by source or through conda, to help make them easier to install, and also hopefully simplifying the code. For this package, the path to this I would go on is to convert the C code into a c extension using nanobind or something similar, and then using the build backend scikit-build-core to handle the compilation of the c-extension. This wouldn't be too difficult to do(I am doing a similar thing for CIL and successfully finished that step as part of a PR), and would eventually allow the code to be cleaned up quite a bit.

From there, it should be quite easy to make a wheel and upload to PyPI. It also seems to be possible to generate a conda recipe from the pypi package, though I haven't made this step yet for anything. I'm making this issue to ask if you'd want to go down this path

purepani avatar Mar 27 '25 19:03 purepani

thanks @purepani , I think it would be a great help. This package doesn't require lots of dependencies which would benefit from using conda and PyPi distribution will be totally sufficient. Additionally as the Matlab extension becomes a legacy we can minimise the effort in supporting various build modifications. Is this conversion assumes removing the CMake recipes or you still need them?

As the older build totally failed I had to re-do it with Ctypes, but I still dislike the fact that the library needs a separate build with a dedicated recipe. Although it became easier to work just on Python part without the need of re-building the library each time. Still, having a one joint build system seems preferable and less error prone. The build of C-extensions is pretty quick if conda recipe is not involved.

dkazanc avatar Mar 31 '25 16:03 dkazanc

By "CMake Recipes" do you mean the conda recipes to build the code? or do you mean the cmake files themselves? To switch from conda to a full pyproject, we would still need cmake, but the conda recipes aren't needed. If there are a sufficient number of non-python dependencies, maybe we could keep the conda recipes around for just those dependencies, but in principle I imagine the build diagram to be something like pyproject.toml -> scikit-build-core builds c-extension and wheel -> upload to pypi -> generate conda recipe if desired

You should still get caching when you're working with scikit-build-core, so you won't have a bunch of rebuilds of the c-extension

purepani avatar Mar 31 '25 16:03 purepani

I didn't mean to close the issue whoops. I don't seem to have permissions to reopen it, so could you do that haha

purepani avatar Mar 31 '25 16:03 purepani

No worries. I meant the C-make files, but you've answered my question.

I don't think there are any dependencies that require conda environment to be honest, may be it could be done purely through venv even. I'm sure that everything we need is also on PyPi. But I can be wrong. So yeah it will be interesting to try the scikit-build-core way. Cheers

dkazanc avatar Apr 01 '25 09:04 dkazanc