Skip to content

Commit 1d0fff3

Browse files
committed
Fix Python/Perl module install paths on macOS via build system
Modules were installed to paths not searched by Homebrew interpreters, requiring fragile PYTHONPATH/PERL5LIB env var workarounds that don't survive subprocess spawning. Fix at the source: builddefs.in now uses --install-lib for Python and INSTALLDIRS=site for Perl on Darwin, targeting paths interpreters actually search. configure.ac adds python_version substitution to support the --install-lib path construction. Remove setup-python from CI workflows and drop PYTHONPATH/PERL5LIB workarounds - modules now install where Homebrew Python/Perl look.
1 parent 0688683 commit 1d0fff3

5 files changed

Lines changed: 1835 additions & 1156 deletions

File tree

.github/workflows/macOS.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ jobs:
1212
run: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
1313
- name: Update Homebrew
1414
run: brew update
15-
- name: Set up Python 3.13
16-
uses: actions/setup-python@v6
17-
with:
18-
python-version: '3.13'
19-
15+
# NOTE: We intentionally use Homebrew Python/Perl rather than GitHub's setup-python action.
16+
# This ensures CI tests mirror how users actually build PCP from source on macOS.
17+
# Our build system installs modules where Homebrew interpreters expect them.
2018
- name: Install macOS dependencies
2119
id: install-deps
2220
uses: ./.github/actions/install-macos-deps

.github/workflows/qa-macos.yml

Lines changed: 15 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ jobs:
1717
- name: Update Homebrew
1818
run: brew update
1919

20-
- name: Set up Python 3.13
21-
uses: actions/setup-python@v6
22-
with:
23-
python-version: '3.13'
24-
2520
- name: Install macOS dependencies
2621
run: bash build/mac/scripts/install-deps.sh # Install all deps (no --minimal)
2722

@@ -37,10 +32,12 @@ jobs:
3732
# This matches the configuration used in Makepkgs for darwin
3833
ETC=$(realpath /etc)
3934
VAR=$(realpath /var)
40-
# Discover Homebrew Python prefix to install bindings to the right location
35+
# NOTE: We use Homebrew Python/Perl, not GitHub's setup-python.
36+
# This mirrors how users actually build PCP from source on macOS, and our build
37+
# system installs modules where Homebrew interpreters look (PYTHON_PREFIX/lib/pythonX.Y/site-packages).
4138
PYTHON_PREFIX=$(python3 -c 'import sys; print(sys.prefix)')
4239
echo "Python prefix: $PYTHON_PREFIX"
43-
./configure --sysconfdir=$ETC --localstatedir=$VAR --prefix=/usr/local --with-python-prefix=$PYTHON_PREFIX --with-qt=no
40+
./configure --sysconfdir=$ETC --localstatedir=$VAR --prefix=/usr/local --with-python_prefix=$PYTHON_PREFIX --with-qt=no
4441
4542
- name: Build PCP
4643
run: |
@@ -91,34 +88,14 @@ jobs:
9188
- name: Install PCP
9289
run: sudo make install
9390

94-
- name: Verify Python/Perl bindings installation
91+
- name: Verify Python/Perl module paths
9592
run: |
96-
echo "=== Phase 2 Verification: Python/Perl Bindings ==="
97-
echo "Python search paths:"
98-
python3 -c "import sys; print('\n'.join(sys.path))"
99-
echo ""
100-
echo "Perl @INC paths:"
101-
perl -e 'print join("\n", @INC), "\n"'
102-
echo ""
103-
echo "Testing Python pcp.pmapi import..."
104-
python3 -c "from pcp import pmapi; print('✓ Python pcp.pmapi OK')" || {
105-
echo "✗ Python pcp.pmapi FAILED - checking installation location"
106-
find /usr/local/lib -name "pmapi.py" 2>/dev/null || echo "pmapi.py not found in /usr/local/lib"
107-
PYTHON_PREFIX=$(python3 -c 'import sys; print(sys.prefix)')
108-
find "$PYTHON_PREFIX/lib" -name "pmapi.py" 2>/dev/null || echo "pmapi.py not found in $PYTHON_PREFIX/lib either"
109-
# Set PYTHONPATH as fallback
110-
PY_VER=$(python3 -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')
111-
export PYTHONPATH="/usr/local/lib/python${PY_VER}/site-packages:${PYTHONPATH:-}"
112-
echo "Setting PYTHONPATH=$PYTHONPATH as fallback"
113-
echo "PYTHONPATH=$PYTHONPATH" >> $GITHUB_ENV
114-
}
93+
echo "=== Verifying Python/Perl module installation ==="
94+
echo "Python prefix: $(python3 -c 'import sys; print(sys.prefix)')"
95+
echo "Python site-packages: $(python3 -c 'import site; print(site.getsitepackages())')"
11596
echo ""
116-
echo "Testing Perl PCP::PMDA module..."
117-
perl -e "use PCP::PMDA; print '✓ Perl PCP::PMDA OK\n'" || {
118-
echo "✗ Perl PCP::PMDA FAILED - setting PERL5LIB"
119-
export PERL5LIB="/usr/local/lib/perl5/site_perl:/usr/local/lib/perl5/vendor_perl:${PERL5LIB:-}"
120-
echo "PERL5LIB=$PERL5LIB" >> $GITHUB_ENV
121-
}
97+
python3 -c "from pcp import pmapi; print('✓ Python pcp.pmapi OK')" || echo "✗ Python pcp.pmapi not yet installed"
98+
perl -e "use PCP::PMDA; print '✓ Perl PCP::PMDA OK\n'" || echo "✗ Perl PCP::PMDA not yet installed"
12299
123100
- name: Rebuild PMNS
124101
run: |
@@ -580,15 +557,18 @@ jobs:
580557
# Capture its output explicitly
581558
if [ ! -f localconfig ]; then
582559
echo "=== localconfig missing, running make setup explicitly ==="
583-
sudo -u pcpqa make setup 2>&1 | tee /tmp/make-setup.log || {
560+
sudo -u pcpqa env TERM=xterm-256color make setup 2>&1 | tee /tmp/make-setup.log || {
584561
echo ""
585562
echo "=== MAKE SETUP FAILED ==="
586563
echo "Full output saved to /tmp/make-setup.log"
587564
exit 1
588565
}
589566
fi
590567
591-
sudo -u pcpqa ./check -g sanity -x not_in_ci
568+
# Modules are installed to system-searchable paths - no PYTHONPATH/PERL5LIB needed
569+
sudo -u pcpqa env \
570+
TERM=xterm-256color \
571+
./check -g sanity -x not_in_ci
592572
593573
- name: Upload QA logs
594574
if: always()

0 commit comments

Comments
 (0)