Skip to content

fix: use versioned Python sitepackages paths instead of symlinks#271

Open
olantwin wants to merge 1 commit into
mainfrom
worktree-python_versions
Open

fix: use versioned Python sitepackages paths instead of symlinks#271
olantwin wants to merge 1 commit into
mainfrom
worktree-python_versions

Conversation

@olantwin
Copy link
Copy Markdown
Contributor

@olantwin olantwin commented May 26, 2026

Summary

  • Replace the fragile lib/pythonlib/python$pyver symlink with direct use of versioned paths (e.g. lib/python3.12/site-packages) across all 39 Python-related recipes
  • YAML prepend_path now uses command substitution to resolve the Python version dynamically
  • Modulefiles embed the versioned path at build time
  • Removes all ln -snf "python$pyver" symlink creation lines

Summary by CodeRabbit

  • Chores
    • Updated build configurations for numerous Python packages to standardize version-specific site-packages directory handling. Changes affect installation paths, runtime environment setup, and generated module files across the Python package ecosystem. These updates improve path consistency and reliability while eliminating legacy symlink-based fallback mechanisms.

Review Change Stack

Replace the unversioned lib/python symlink with direct use of
versioned paths (e.g. lib/python3.12/site-packages) for robustness.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 26, 2026

📝 Walkthrough

Walkthrough

Thirty-five build recipe scripts are updated to use version-specific Python site-packages paths (lib/python$pyver/site-packages) instead of unversioned paths, with symlink-based fallbacks removed. PYTHONPATH environment variables and generated modulefile directives are updated consistently across all recipes.

Changes

Python site-packages versioning

Layer / File(s) Summary
Core Python and build infrastructure
python.sh, alibuild.sh, bitsorg.sh
Core Python runtime and primary build tools are updated to compute and export version-specific site-packages paths using sysconfig.get_python_version(). Symlink creation steps that previously provided unversioned path aliases are removed. Generated modulefiles now emit prepend-path PYTHONPATH directives targeting the versioned directories.
Python package recipes
python-numpy.sh, python-scipy.sh, python-pandas.sh, python-matplotlib.sh, python-awkward.sh, python-awkward-cpp.sh, python-certifi.sh, python-charset-normalizer.sh, python-contourpy.sh, python-cramjam.sh, python-cycler.sh, python-dateutil.sh, python-distro.sh, python-execnet.sh, python-fonttools.sh, python-fsspec.sh, python-idna.sh, python-iniconfig.sh, python-jinja2.sh, python-kiwisolver.sh, python-markupsafe.sh, python-packaging.sh, python-pillow.sh, python-pluggy.sh, python-pygments.sh, python-pyparsing.sh, python-pytest.sh, python-pytest-xdist.sh, python-pyyaml.sh, python-requests.sh, python-six.sh, python-tabulate.sh, python-uproot.sh, python-urllib3.sh, python-xxhash.sh
All 35 Python package recipes systematically update their prepend_path PYTHONPATH configuration to point to the Python version-specific site-packages directory and update generated modulefiles to match. The pattern is consistent: PYTHONPATH now includes the computed Python minor/major version from sysconfig in the path, replacing hardcoded lib/python/site-packages with lib/python$pyver/site-packages.
XRootD Python bindings configuration
xrootd.sh
XRootD script is updated to use the detected Python version (python${PYTHON_VER}) when setting PYTHONPATH and when validating Python bindings installation. Post-install handling for locating bindings is adjusted to use versioned directory paths, and the runtime verification command's PYTHONPATH is updated to reference the versioned site-packages location.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately describes the main change: replacing symlink-based Python site-packages paths with version-specific direct paths across 39 Python recipe files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch worktree-python_versions
⚔️ Resolve merge conflicts
  • Resolve merge conflict in branch worktree-python_versions

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
xrootd.sh (1)

95-95: ⚡ Quick win

Consider 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

📥 Commits

Reviewing files that changed from the base of the PR and between a5ae7ab and 11f0ef5.

📒 Files selected for processing (39)
  • alibuild.sh
  • bitsorg.sh
  • python-awkward-cpp.sh
  • python-awkward.sh
  • python-certifi.sh
  • python-charset-normalizer.sh
  • python-contourpy.sh
  • python-cramjam.sh
  • python-cycler.sh
  • python-dateutil.sh
  • python-distro.sh
  • python-execnet.sh
  • python-fonttools.sh
  • python-fsspec.sh
  • python-idna.sh
  • python-iniconfig.sh
  • python-jinja2.sh
  • python-kiwisolver.sh
  • python-markupsafe.sh
  • python-matplotlib.sh
  • python-numpy.sh
  • python-packaging.sh
  • python-pandas.sh
  • python-pillow.sh
  • python-pluggy.sh
  • python-pygments.sh
  • python-pyparsing.sh
  • python-pytest-xdist.sh
  • python-pytest.sh
  • python-pyyaml.sh
  • python-requests.sh
  • python-scipy.sh
  • python-six.sh
  • python-tabulate.sh
  • python-uproot.sh
  • python-urllib3.sh
  • python-xxhash.sh
  • python.sh
  • xrootd.sh

Comment thread xrootd.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} .
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ 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.

Suggested change
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.

Comment thread xrootd.sh
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)"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

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).

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 26, 2026

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 @coderabbitai resolve merge conflict to automatically resolve the conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant