Skip to content

Auto-detect GSL paths in setup.py to fix compilation failures when CFLAGS/LDFLAGS are unset#831

Merged
jobovy merged 9 commits intomainfrom
copilot/fix-gsl-installation-issues
Feb 25, 2026
Merged

Auto-detect GSL paths in setup.py to fix compilation failures when CFLAGS/LDFLAGS are unset#831
jobovy merged 9 commits intomainfrom
copilot/fix-gsl-installation-issues

Conversation

Copy link
Contributor

Copilot AI commented Feb 24, 2026

GSL installed in non-standard prefixes (Homebrew on macOS, conda on Windows) causes fatal error: 'gsl/gsl_math.h' file not found when users haven't manually set CFLAGS/LDFLAGS.

setup.py

After the existing gsl-config --version call, invoke gsl-config --cflags and gsl-config --libs and inject discovered paths directly into both C extensions via include_dirs, library_dirs, and runtime_library_dirs (rpath on Unix/macOS; empty on Windows).

Key details:

  • All platforms: runs on Unix/macOS/Windows; uses shell=True on Windows for .bat execution
  • Deduplication: skips paths already in CFLAGS/LDFLAGS (Unix) or INCLUDE/LIB (Windows)
  • Validation: paths are only used if they contain actual GSL files — gsl/gsl_math.h for include dirs, libgsl* or gsl.lib for lib dirs — silently skipping garbage output (e.g. when CONDA_PREFIX is unset on Windows)

CI

build.yml (Linux/macOS):

  • Splits macOS GSL+OpenMP install step: software install always runs; env-var export is skipped for all macos-* jobs with test_energy_jacobi_conservation or from_name in TEST_FILES (robust to runner version changes)
  • A companion step sets only the libomp paths for those jobs, since OpenMP location isn't auto-detected

build_windows.yml:

  • Splits "Set GSL environment variables": a PATH-only step always runs (exposes gsl-config.bat and exports CONDA_PREFIX so the .bat resolves paths correctly); INCLUDE/LIB/LIBPATH is skipped for the test_actionAngle.py Python 3.14 job to exercise auto-detection

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…ne Linux and one Mac job

Co-authored-by: jobovy <1044876+jobovy@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix GSL installation failures due to missing paths Auto-detect GSL paths in setup.py to fix compilation failures when CFLAGS/LDFLAGS are unset Feb 24, 2026
Copilot AI requested a review from jobovy February 24, 2026 02:53
@jobovy
Copy link
Owner

jobovy commented Feb 24, 2026

pre-commit.ci autofix

@jobovy jobovy marked this pull request as ready for review February 24, 2026 02:54
@codecov
Copy link

codecov bot commented Feb 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.91%. Comparing base (5b3ae02) to head (15ce76f).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #831   +/-   ##
=======================================
  Coverage   99.91%   99.91%           
=======================================
  Files         215      215           
  Lines       30920    30920           
  Branches      613      613           
=======================================
  Hits        30893    30893           
  Misses         27       27           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Owner

@jobovy jobovy left a comment

Choose a reason for hiding this comment

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

@copilot Actually, the gsl-config.bat file seems to allow gsl-config to be run with the --cflags and --libs arguments, so we can probably run it on Windows as well. Test it in the build_windows.yml workflow in a similar way as for macs.

…P-only step; split Windows GSL env step

Co-authored-by: jobovy <1044876+jobovy@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 24, 2026

@copilot Actually, the gsl-config.bat file seems to allow gsl-config to be run with the --cflags and --libs arguments, so we can probably run it on Windows as well. Test it in the ``build_windows.yml`...

Done in 4d87e23. The not WIN32 guard is removed so gsl-config --cflags/--libs is now called on Windows too (with shell=True for .bat execution). Windows-specific details: deduplication checks INCLUDE/LIB env vars instead of CFLAGS/LDFLAGS, and quoted paths from gsl-config.bat output are stripped. runtime_library_dirs is left empty on Windows (no rpath concept).

In build_windows.yml, the "Set GSL environment variables" step is split: a PATH-only step (always runs, making gsl-config.bat accessible) and the INCLUDE/LIB/LIBPATH step (skipped for the test_actionAngle.py Python 3.14 job to test auto-detection).

Copilot AI requested a review from jobovy February 24, 2026 04:08
@jobovy
Copy link
Owner

jobovy commented Feb 24, 2026

pre-commit.ci autofix

Co-authored-by: jobovy <1044876+jobovy@users.noreply.github.com>
Co-authored-by: jobovy <1044876+jobovy@users.noreply.github.com>
@jobovy jobovy merged commit a1150fa into main Feb 25, 2026
169 of 170 checks passed
@jobovy jobovy deleted the copilot/fix-gsl-installation-issues branch February 25, 2026 04:27
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.

2 participants