Integrate papiex C library compilation into pip install (setup.py + compile_papiex.sh)#171
Integrate papiex C library compilation into pip install (setup.py + compile_papiex.sh)#171Copilot wants to merge 17 commits into
Conversation
…mpile_papiex.sh Co-authored-by: ilaflott <6273252+ilaflott@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #171 +/- ##
==========================================
+ Coverage 77.63% 77.67% +0.04%
==========================================
Files 34 34
Lines 6765 6765
==========================================
+ Hits 5252 5255 +3
+ Misses 1513 1510 -3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…ubprocess stdout stderr piping which obscures good output in the github CI
Makefile: - Remove OUTSIDE_DOCKER branch from papiex-dist rule (docker-dist only) - Update python-dist comments to document Docker-only usage - Clean up extracted papiex-epmt-install/ dir after copying .so files build_and_test_epmt.yml: - Remove OUTSIDE_DOCKER papiex tarball cache/build steps - Replace sdist-based install with direct pip install ./src - Remove -v -v flags (output now visible by default) weekly_cache_builds.yml: - Remove OUTSIDE_DOCKER papiex build/verify/cache steps setup.py: - Tee compile_papiex.sh output to /dev/tty (bypasses pip capture) - Fall back to stderr when no TTY available (CI) - Always write to install_papiex.log .gitignore: - Add src/build/, src/epmt/bin/, src/epmt/include/ Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
appears to work at this point- freezing but not merging yet |
|
this will not be ready for releasing |
…mpile_papiex.sh Co-authored-by: ilaflott <6273252+ilaflott@users.noreply.github.com>
…ubprocess stdout stderr piping which obscures good output in the github CI
928557f to
52ac9f7
Compare
…ove-outside-docker-papiex-v2
…papiex-v2 Remove OUTSIDE_DOCKER papiex path, show build output at install time
| always visible to interactive users. In non-interactive contexts | ||
| (CI, no TTY) the output still goes to the log file and stderr. | ||
| """ | ||
| tty_fh = _open_tty() |
|
this is doing somethings right...
todo: forseeable problem, with possible alternative: |
ilaflott
left a comment
There was a problem hiding this comment.
review your changes against the recent test-PyPI packaging efforts, see .github/workflows/pip_publish.yml
review the feedback to your code generally
we're going to off-ramp this PR into a set of plans/notes for a fresh attempt
| def _open_tty(): | ||
| """Open /dev/tty for direct user output, bypassing pip's capture.""" | ||
| try: | ||
| return open("/dev/tty", "w", encoding="utf-8") |
Folds papiex native library compilation into
pip install epmtusing the samepyproject.toml+setup.pyhybrid pattern as NOAA-GFDL/pyFMS. Compilation is best-effort: EPMT installs cleanly even when build tools or network are unavailable.New files
src/compile_papiex.sh— Downloads papiex source (or usessrc/vendor/papiex/if pre-populated) and runsmake PREFIX=<epmt_lib_dir> install. Skips gracefully (exit 0) when.sofiles are already present,gcc/make/curlare missing, or the source download fails. Exits non-zero only on actualmakefailure (caught and warned bysetup.py). RespectsPAPIEX_SRC_BRANCH,CONFIG_PAPIEX_PAPI,CONFIG_PAPIEX_DEBUG.src/setup.py— Minimal hook following pyFMS pattern. All metadata stays inpyproject.toml.Modified files
src/MANIFEST.in— Includecompile_papiex.shin sdist so it ships with the package.Makefile—vendor-papiextarget downloads papiex source intosrc/vendor/papiex/for air-gapped installs;pip-installtarget runsvendor-papiexthenpip3 install ./src;papiexcleannow also removessrc/vendor/papiexandsrc/epmt/lib..gitignore— Excludesrc/vendor/,src/epmt/lib/,install_papiex.log.build_and_test_epmt.yml— New CI step exercisespip install ./src(with papiex compiled from source) before the existing sdist-based path.epmtdocs/docs/INSTALL.md— Documentspip install epmt, themake vendor-papiex/make pip-installtargets, and the controlling environment variables.Backward compatibility
The existing Makefile workflow (
make python-dist) pre-copies.sofiles intosrc/epmt/lib/before building the sdist.compile_papiex.shdetects those files and skips compilation, so the current Docker/CI release path is unaffected.Checklist
Original prompt
Goal
Integrate the papiex C library compilation step into
pip install epmt, following the same pattern that NOAA-GFDL/pyFMS uses to compile cFMS during pip install. The approach uses declarative metadata inpyproject.tomland imperative build logic insetup.py— the recommended setuptools pattern for custom build steps.Context
Currently, EPMT and papiex are built and distributed separately:
src/pyproject.tomlusingsetuptools.build_metaas the build backend.make PREFIX=... install, producing shared libraries (libpapiex.so,libmonitor.so, etc.).Makefiledownloads the papiex source tarball viacurl, compiles it (natively or in Docker), and bundles the resultingpapiex-epmt-*.tgzalongside the EPMT pip package in the release..sofiles are included in the EPMT package via[tool.setuptools.package-data]with"lib/*.so*".pyFMS demonstrates the pattern we want to follow. Its
pyproject.tomldeclaresbuild-backend = "setuptools.build_meta"and itssetup.pydefines aCustomBuildclass that runscompile_c_libs.shbefore the normal build:Implementation Plan
1. Create
compile_papiex.shin thesrc/directory (next topyproject.toml)This script should:
src/vendor/papiexor already present).https://github.com/NOAA-GFDL/papiex(using the branch/tag configured in the top-level Makefile variablesPAPIEX_SRC_BRANCH).gccandmakeare available on the system.epmt check).make PREFIX=<target> installintosrc/epmt/lib/so the resulting.sofiles are picked up by the existing[tool.setuptools.package-data]glob"lib/*.so*".CONFIG_PAPIEX_PAPIandCONFIG_PAPIEX_DEBUGthat control papiex build options.install_papiex.logfile.2. Create
src/setup.pyFollowing pyFMS's pattern, create a minimal
setup.pythat hooks into setuptools' build step:3. Update
src/pyproject.tomlbuild-backend = "setuptools.build_meta"is set (it already is).[tool.setuptools.package-data]section already includes"lib/*.so*"which will pick up the compiled papiex libraries.pyproject.tomlsince all declarative metadata remains there.4. Update the top-level
Makefilepapiex-dist,$(PAPIEX_RELEASE),$(PAPIEX_SRC),$(PAPIEX_SRC_TARBALL)) to see if they can be simplified or if they need to reference the newcompile_papiex.sh.pip-installorinstall-with-papiex) that demonstratespip install ./srcwith papiex compilation.vendor-papiextarget that clones/downloads the papiex source intosrc/vendor/papiex/.5. Update
.github/workflowsReview...
This pull request was created from Copilot chat.
💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.