Repository navigation
ENH: Add script to install python packages locally - #978
Conversation
SimonRit
left a comment
There was a problem hiding this comment.
Nice, just two small questions below
6ed7d44 to
87bf024
Compare
|
I made some tests, the script does not do a full rebuild each time a cxx files is changed, so ready to be merged I think |
SimonRit
left a comment
There was a problem hiding this comment.
I'd change the script to compile ITK with CudaCommon and RTK ON instead of compiling RTK separately. What do you think?
| # Prerequisites: | ||
| # - An ITK build tree with Python wrapping enabled (set ITK_DIR) | ||
| # - Optionally CUDA (set RTK_USE_CUDA=ON). | ||
| # When CUDA is enabled, CudaCommon must be findable by ITK. |
There was a problem hiding this comment.
I'd remove this line, CudaCommon is in ITK as a remote module so it's always findable. CUDA might not be findable but that's beyond the scope of this script.
| # Verify that ITK Python wrapping is installed in site-packages. RTK wrapping | ||
| # builds on top of the ITK wrapping infrastructure, so ITK's wrapping shared | ||
| # libraries must already be present. | ||
| ITK_PYTHON_DIR=$(python -c "import itk; import os; print(os.path.dirname(itk.__file__))") |
There was a problem hiding this comment.
If I understand correctly, you must compile ITK first. Why not provide a script that jointly compiles an editable ITK and RTK?
| * Manually download RTK's source repository from [GitHub](https://github.com/RTKConsortium/RTK) with `git` (recommended) or as a [zip package](https://codeload.github.com/RTKConsortium/RTK/zip/main). | ||
| * Configure the project with CMake pointing to RTK's source directory and setting the CMake option `ITK_DIR` to ITK's compilation directory. All CMake options above can be set except `Module_RTK`. | ||
|
|
||
| A convenience script at `utilities/build_rtk_python.sh` builds and installs RTK as a Python package. It must be run from the RTK source directory. It requires ITK and, when using CUDA, CudaCommon, both built with Python wrapping enabled: |
There was a problem hiding this comment.
Replace
A convenience script at `utilities/build_rtk_python.sh`
by
The convenience script [build_rtk_python.sh](utilities/build_rtk_python.sh)
please.
I'm not sure the joint/editable build is the solution. We can't pip install an ITK source tree, it has no pip build system. |
87bf024 to
1291dd9
Compare
Ok, I didn't know one couldn't pip install an ITK source tree. So with this script, one needs to
It's currently not clear that one needs to pip install itk first, I would clarify this if this is the proposed procedure. |
We don't need to pip install itk, we just need to build and install itk with python wrapping (and optionally CudaCommon) and give the build path to the script |
I tried to test this (fresh Python env, built ITK, run the script). Here is the result: So pip install itk is required? |
| * Manually download RTK's source repository from [GitHub](https://github.com/RTKConsortium/RTK) with `git` (recommended) or as a [zip package](https://codeload.github.com/RTKConsortium/RTK/zip/main). | ||
| * Configure the project with CMake pointing to RTK's source directory and setting the CMake option `ITK_DIR` to ITK's compilation directory. All CMake options above can be set except `Module_RTK`. | ||
|
|
||
| The convenience script [build_rtk_python.sh](utilities/build_rtk_python.sh) builds and installs RTK as a Python package. It must be run from the RTK source directory. It requires ITK and, when using CUDA, CudaCommon, both built with Python wrapping enabled: |
There was a problem hiding this comment.
My bad, the link doesn't work. I guess it only works for the .md files copied for readthedocs. Is there a proper way to link to files in the GitHub repository?
So I progressed by adding the ITK bindings to the PYTHONPATH, as I usually do with my local ITK compilation. Then I had to install |
|
Ok, it worked with the additional patch I have pushed: |
2ea758a to
0d78831
Compare
a9f9f82 to
cd15636
Compare
|
I confirmed that the editable mod of pip does not work, so there is no reason to use pip install, we can install rtk with cmake and create symlinks in the script like I did. |
cd15636 to
ca88790
Compare
ca88790 to
82dcb0b
Compare
82dcb0b to
09995d9
Compare
09995d9 to
67ab72a
Compare
c4bb53d to
242d3d6
Compare
| [ -f "$src" ] || continue | ||
| name=$(basename "$src" .py) | ||
| cat > "$SCRIPTS_DIR/$name" <<EOF | ||
| #!$PYTHON_BIN |
There was a problem hiding this comment.
Spaces prevent commands from starting
If the selected Python environment lives in a directory containing spaces, #!$PYTHON_BIN produces an invalid interpreter line on Linux. The generated commands fail before importing the application, even though installation succeeds. Generate a shell launcher that quotes the interpreter path, as Python package installers do.
242d3d6 to
13db3b0
Compare


Confidence Score: 5/5
The PR appears safe to merge, with the existing non-blocking issue for interpreter paths containing spaces.Findings
Summary
Adds a script to build and install RTK's Python files beside an existing ITK package.
SimonRit dismissed the earlier Python 3.8 concern because ITK no longer supports it; Greptile withdrew that finding.
Reviews (7) · Last reviewed commit: "ENH: Add RTK Python package install scri..." · Reviewed by Greptile