-
Notifications
You must be signed in to change notification settings - Fork 8
Add Python venv setup script and fix pyproject.toml #322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
krystophny
wants to merge
1
commit into
main
Choose a base branch
from
feature/venv-setup
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,3 +61,4 @@ thirdparty/pyplot_module.F90 | |
| .claude | ||
| docs/_build/ | ||
| build*/ | ||
| .venv/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,20 @@ | ||
| # Python dependencies for SIMPLE | ||
| # Pin exact versions for reproducibility in CI | ||
| # Use minimum versions for compatibility across Python releases. | ||
| # Exact pins break on newer Python versions that lack prebuilt wheels. | ||
|
|
||
| # Core dependencies | ||
| numpy==2.2.6 | ||
| scikit-build-core==0.10.0 | ||
| numpy>=2.2 | ||
| scikit-build-core>=0.10 | ||
|
|
||
| # F90wrap - pinned to release version | ||
| # F90wrap - pinned to release version (API-sensitive) | ||
| f90wrap==0.2.16 | ||
|
|
||
| # Optional dependencies for testing | ||
| pytest==7.4.3 | ||
| pytest-cov==6.2.1 | ||
| netCDF4==1.7.2 | ||
| # Testing | ||
| pytest>=7.4 | ||
| pytest-cov>=6.0 | ||
| netCDF4>=1.7 | ||
|
|
||
| # Optional dependencies for examples/plotting | ||
| matplotlib==3.9.4 | ||
| scipy==1.15.2 | ||
| shapely==2.0.5 | ||
| # Plotting and examples | ||
| matplotlib>=3.9 | ||
| scipy>=1.15 | ||
| shapely>=2.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| #!/bin/bash | ||
| # Create and populate a Python virtual environment for SIMPLE. | ||
| # Usage: ./setup-venv.sh [--no-pysimple] | ||
| # | ||
| # Options: | ||
| # --no-pysimple Skip building pysimple (Fortran-Python bindings). | ||
| # Use this if you only need Python test/plot dependencies. | ||
| # | ||
| # Prerequisites (system packages): | ||
| # - python3 (>= 3.9) with venv module | ||
| # - gfortran, cmake, ninja-build | ||
| # - libnetcdff-dev (or netcdf-fortran-devel), liblapack-dev | ||
| # See docs/PREREQUISITES.md for distro-specific install commands. | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" | ||
| VENV_DIR="${SCRIPT_DIR}/.venv" | ||
| BUILD_PYSIMPLE=1 | ||
|
|
||
| for arg in "$@"; do | ||
| case "$arg" in | ||
| --no-pysimple) BUILD_PYSIMPLE=0 ;; | ||
| -h|--help) | ||
| sed -n '2,/^$/s/^# //p' "$0" | ||
| exit 0 | ||
| ;; | ||
| *) | ||
| echo "Unknown option: $arg" >&2 | ||
| exit 1 | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| echo "Creating virtual environment in ${VENV_DIR} ..." | ||
| python3 -m venv "$VENV_DIR" | ||
| # shellcheck disable=SC1091 | ||
| source "${VENV_DIR}/bin/activate" | ||
|
|
||
| echo "Upgrading pip ..." | ||
| pip install --upgrade pip | ||
|
|
||
| echo "Installing Python dependencies from requirements.txt ..." | ||
| pip install --prefer-binary -r "${SCRIPT_DIR}/requirements.txt" | ||
|
|
||
| if [ "$BUILD_PYSIMPLE" -eq 1 ]; then | ||
| echo "Building pysimple (Fortran-Python bindings) ..." | ||
| # Build SIMPLE first if not already built | ||
| if [ ! -f "${SCRIPT_DIR}/build/build.ninja" ]; then | ||
| echo " Configuring CMake ..." | ||
| cmake -S "$SCRIPT_DIR" -B"${SCRIPT_DIR}/build" -GNinja \ | ||
| -DCMAKE_BUILD_TYPE=Release -DCMAKE_COLOR_DIAGNOSTICS=ON | ||
| fi | ||
| echo " Building Fortran library ..." | ||
| cmake --build "${SCRIPT_DIR}/build" --config Release | ||
|
|
||
| echo " Installing pysimple in editable mode ..." | ||
| pip install --no-build-isolation -e "$SCRIPT_DIR" | ||
| else | ||
| echo "Skipping pysimple build (--no-pysimple)." | ||
| fi | ||
|
|
||
| echo "" | ||
| echo "Done. Activate with:" | ||
| echo " source .venv/bin/activate" | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1. Stale cmake disables bindings
🐞 Bug✓ CorrectnessAgent Prompt
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools