fix: use versioned Python sitepackages paths instead of symlinks#271
fix: use versioned Python sitepackages paths instead of symlinks#271olantwin wants to merge 1 commit into
Conversation
Replace the unversioned lib/python symlink with direct use of versioned paths (e.g. lib/python3.12/site-packages) for robustness.
📝 WalkthroughWalkthroughThirty-five build recipe scripts are updated to use version-specific Python site-packages paths ( ChangesPython site-packages versioning
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
xrootd.sh (1)
95-95: ⚡ Quick winConsider breaking the long verification command into multiple lines for readability.
The verification command on line 95 is very long and difficult to read. Consider splitting it into multiple lines or using intermediate variables.
♻️ Proposed refactor
- LD_LIBRARY_PATH="$INSTALLROOT/lib${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH" PYTHONPATH="$INSTALLROOT/lib/python${PYTHON_VER}/site-packages${PYTHONPATH:+:}$PYTHONPATH" ${PYTHON_EXECUTABLE} -c 'from XRootD import client as xrd_client;print(f"{xrd_client.__version__}\n{xrd_client.__file__}");' + export LD_LIBRARY_PATH="$INSTALLROOT/lib${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH" + export PYTHONPATH="$INSTALLROOT/lib/python${PYTHON_VER}/site-packages${PYTHONPATH:+:}$PYTHONPATH" + ${PYTHON_EXECUTABLE} -c 'from XRootD import client as xrd_client; print(f"{xrd_client.__version__}\n{xrd_client.__file__}");'🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@xrootd.sh` at line 95, The long one-liner that sets LD_LIBRARY_PATH, PYTHONPATH and runs PYTHON_EXECUTABLE to import XRootD client should be split for readability: extract the environment prefixes into descriptive variables (e.g., ld_lib_prefix, py_path_prefix) or build PYTHONPATH and LD_LIBRARY_PATH across multiple lines with backslash continuations, then invoke ${PYTHON_EXECUTABLE} with the import/print command; update the existing line that references LD_LIBRARY_PATH, PYTHONPATH and ${PYTHON_EXECUTABLE} so the final invocation uses the composed variables (and preserves the print of xrd_client.__version__ and xrd_client.__file__) while keeping the command readable and maintainable.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@xrootd.sh`:
- Line 85: The mv invocation uses an unquoted variable and may suffer from
globbing or word-splitting; update the mv command that moves
../lib64/python${PYTHON_VER} to quote the variable (reference the mv line and
the ${PYTHON_VER} variable) so the destination/source path is treated as a
single token and special characters or spaces are handled safely.
- Line 87: The error message uses uppercase "PYTHON${PYTHON_VER}" but the
directory test checks for lowercase "python${PYTHON_VER}"; update the echo to
match the checked path by replacing "NO PYTHON${PYTHON_VER} DIRECTORY in: $(pwd
-P)" with "NO python${PYTHON_VER} DIRECTORY in: $(pwd -P)" so the displayed path
matches the actual directory name checked (referencing the [[ ! -d
python${PYTHON_VER} ]] test and the PYTHON_VER variable).
---
Nitpick comments:
In `@xrootd.sh`:
- Line 95: The long one-liner that sets LD_LIBRARY_PATH, PYTHONPATH and runs
PYTHON_EXECUTABLE to import XRootD client should be split for readability:
extract the environment prefixes into descriptive variables (e.g.,
ld_lib_prefix, py_path_prefix) or build PYTHONPATH and LD_LIBRARY_PATH across
multiple lines with backslash continuations, then invoke ${PYTHON_EXECUTABLE}
with the import/print command; update the existing line that references
LD_LIBRARY_PATH, PYTHONPATH and ${PYTHON_EXECUTABLE} so the final invocation
uses the composed variables (and preserves the print of xrd_client.__version__
and xrd_client.__file__) while keeping the command readable and maintainable.
🪄 Autofix (Beta)
❌ Autofix failed (check again to retry)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 2efcbc82-b536-42be-a7fe-63d4ab6808ae
📒 Files selected for processing (39)
alibuild.shbitsorg.shpython-awkward-cpp.shpython-awkward.shpython-certifi.shpython-charset-normalizer.shpython-contourpy.shpython-cramjam.shpython-cycler.shpython-dateutil.shpython-distro.shpython-execnet.shpython-fonttools.shpython-fsspec.shpython-idna.shpython-iniconfig.shpython-jinja2.shpython-kiwisolver.shpython-markupsafe.shpython-matplotlib.shpython-numpy.shpython-packaging.shpython-pandas.shpython-pillow.shpython-pluggy.shpython-pygments.shpython-pyparsing.shpython-pytest-xdist.shpython-pytest.shpython-pyyaml.shpython-requests.shpython-scipy.shpython-six.shpython-tabulate.shpython-uproot.shpython-urllib3.shpython-xxhash.shpython.shxrootd.sh
| ln -s ../lib64/python${PYTHON_VER} python | ||
| elif [[ -d python${PYTHON_VER} ]]; then | ||
| ln -s python${PYTHON_VER} python | ||
| mv ../lib64/python${PYTHON_VER} . |
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win
Quote the variable to prevent globbing and word splitting.
The mv command should quote ${PYTHON_VER} to handle edge cases where the variable might contain spaces or special characters.
🛡️ Proposed fix
- mv ../lib64/python${PYTHON_VER} .
+ mv "../lib64/python${PYTHON_VER}" .📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| mv ../lib64/python${PYTHON_VER} . | |
| mv "../lib64/python${PYTHON_VER}" . |
🧰 Tools
🪛 Shellcheck (0.11.0)
[info] 85-85: Double quote to prevent globbing and word splitting.
(SC2086)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@xrootd.sh` at line 85, The mv invocation uses an unquoted variable and may
suffer from globbing or word-splitting; update the mv command that moves
../lib64/python${PYTHON_VER} to quote the variable (reference the mv line and
the ${PYTHON_VER} variable) so the destination/source path is treated as a
single token and special characters or spaces are handled safely.
| mv ../lib64/python${PYTHON_VER} . | ||
| fi | ||
| [[ ! -e python ]] && echo "NO PYTHON SYMLINK CREATED in: $(pwd -P)" | ||
| [[ ! -d python${PYTHON_VER} ]] && echo "NO PYTHON${PYTHON_VER} DIRECTORY in: $(pwd -P)" |
There was a problem hiding this comment.
Fix case inconsistency in error message.
The directory check uses python${PYTHON_VER} (lowercase) but the error message displays PYTHON${PYTHON_VER} (uppercase). This inconsistency could confuse someone debugging the issue.
📝 Proposed fix
- [[ ! -d python${PYTHON_VER} ]] && echo "NO PYTHON${PYTHON_VER} DIRECTORY in: $(pwd -P)"
+ [[ ! -d python${PYTHON_VER} ]] && echo "NO python${PYTHON_VER} DIRECTORY in: $(pwd -P)"🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@xrootd.sh` at line 87, The error message uses uppercase "PYTHON${PYTHON_VER}"
but the directory test checks for lowercase "python${PYTHON_VER}"; update the
echo to match the checked path by replacing "NO PYTHON${PYTHON_VER} DIRECTORY
in: $(pwd -P)" with "NO python${PYTHON_VER} DIRECTORY in: $(pwd -P)" so the
displayed path matches the actual directory name checked (referencing the [[ !
-d python${PYTHON_VER} ]] test and the PYTHON_VER variable).
|
Note Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it. ❌ Cannot run autofix: This PR has merge conflicts. Please resolve the conflicts with the base branch and try again. Alternatively, use |
Summary
lib/python→lib/python$pyversymlink with direct use of versioned paths (e.g.lib/python3.12/site-packages) across all 39 Python-related recipesprepend_pathnow uses command substitution to resolve the Python version dynamicallyln -snf "python$pyver"symlink creation linesSummary by CodeRabbit