-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e44a2a3
commit f3252f6
Showing
9 changed files
with
295 additions
and
93 deletions.
There are no files selected for viewing
This file contains 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 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,177 @@ | ||
name: release | ||
|
||
# Shamelessly taken from: https://github.com/ArjanCodes/examples/blob/main/2024/publish_pypi/release.yaml | ||
|
||
on: | ||
push: | ||
tags: | ||
- "v[0-9]+.[0-9]+.[0-9]+" | ||
- "v[0-9]+.[0-9]+.[0-9]+a[0-9]+" | ||
- "v[0-9]+.[0-9]+.[0-9]+b[0-9]+" | ||
- "v[0-9]+.[0-9]+.[0-9]+rc[0-9]+" | ||
- "v[0-9]+.[0-9]+.[0-9]+dev[0-9]+" | ||
|
||
env: | ||
PACKAGE_NAME: "ngsPETSc" | ||
OWNER: "uzerbinati" | ||
|
||
jobs: | ||
details: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
new_version: ${{ steps.release.outputs.new_version }} | ||
suffix: ${{ steps.release.outputs.suffix }} | ||
tag_name: ${{ steps.release.outputs.tag_name }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Extract tag and Details | ||
id: release | ||
run: | | ||
if [ "${{ github.ref_type }}" = "tag" ]; then | ||
TAG_NAME=${GITHUB_REF#refs/tags/} | ||
NEW_VERSION=$(echo $TAG_NAME | awk -F'-' '{print $1}') | ||
SUFFIX=$(echo $TAG_NAME | grep -oP '([a-u,w-z]|dev)+[0-9]+' || echo "") | ||
echo "TAG_NAME=$TAG_NAME" | ||
echo "new_version=${NEW_VERSION:1}" >> "$GITHUB_OUTPUT" | ||
echo "suffix=$SUFFIX" >> "$GITHUB_OUTPUT" | ||
echo "tag_name=$TAG_NAME" >> "$GITHUB_OUTPUT" | ||
echo "Version is ${NEW_VERSION:1}" | ||
echo "Suffix is $SUFFIX" | ||
echo "Tag name is $TAG_NAME" | ||
else | ||
echo "No tag found" | ||
exit 1 | ||
fi | ||
check_pypi: | ||
needs: details | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Fetch information from PyPI | ||
run: | | ||
response=$(curl -s https://pypi.org/pypi/${{ env.PACKAGE_NAME }}/json || echo "{}") | ||
latest_previous_version=$(echo $response | jq --raw-output "select(.releases != null) | .releases | keys_unsorted | last") | ||
if [ -z "$latest_previous_version" ]; then | ||
echo "Package not found on PyPI." | ||
latest_previous_version="0.0.0" | ||
fi | ||
echo "Latest version on PyPI: $latest_previous_version" | ||
echo "latest_previous_version=$latest_previous_version" >> $GITHUB_ENV | ||
- name: Compare versions and exit if not newer | ||
run: | | ||
NEW_VERSION=${{ needs.details.outputs.new_version }} | ||
LATEST_VERSION=$latest_previous_version | ||
if [ "$(printf '%s\n' "$LATEST_VERSION" "$NEW_VERSION" | sort -rV | head -n 1)" != "$NEW_VERSION" ] || [ "$NEW_VERSION" == "$LATEST_VERSION" ]; then | ||
echo "The new version $NEW_VERSION is not greater than the latest version $LATEST_VERSION on PyPI." | ||
exit 1 | ||
else | ||
echo "The new version $NEW_VERSION is greater than the latest version $LATEST_VERSION on PyPI." | ||
fi | ||
setup_and_build: | ||
needs: [details, check_pypi] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.12" | ||
|
||
- name: Setup MPI | ||
uses: mpi4py/setup-mpi@v1 | ||
with: | ||
mpi: "mpich" | ||
|
||
- name: Build and install PETSc | ||
run: | | ||
pip install numpy setuptools | ||
cd .. | ||
git clone https://gitlab.com/petsc/petsc.git petsc | ||
cd petsc | ||
git checkout -b stefanozampini/fix-petsc4py-sdist | ||
./configure \ | ||
--with-c2html=0 \ | ||
--with-debugging=0 \ | ||
--with-fortran-bindings=0 \ | ||
--with-shared-libraries=1 \ | ||
--with-petsc4py | ||
make | ||
- name: Install Poetry | ||
run: | | ||
curl -sSL https://install.python-poetry.org | python3 - | ||
echo "$HOME/.local/bin" >> $GITHUB_PATH | ||
- name: Set project version with Poetry | ||
run: | | ||
poetry version ${{ needs.details.outputs.new_version }} | ||
- name: Install dependencies | ||
run: | | ||
export PETSC_DIR=/home/runner/work/ngsPETSc/petsc | ||
export PETSC_ARCH=arch-linux-c-opt | ||
# Hopefully this song and dance goes away after petsc4py release 3.22.2 | ||
poetry remove petsc4py | ||
poetry install --sync --no-interaction | ||
poetry add ../petsc/src/binding/petsc4py | ||
sed -i -E "s/petsc4py = (\{.+\})/petsc4py = \"^3.22.1\"/" pyproject.toml | ||
# Replace when fixed with: | ||
# poetry install --sync --no-interaction | ||
- name: Build source and wheel distribution | ||
run: | | ||
poetry build | ||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: dist | ||
path: dist/ | ||
|
||
pypi_publish: | ||
name: Upload release to PyPI | ||
needs: [setup_and_build, details] | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: release | ||
permissions: | ||
id-token: write | ||
steps: | ||
- name: Download artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: dist | ||
path: dist/ | ||
|
||
- name: Publish distribution to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
|
||
github_release: | ||
name: Create GitHub Release | ||
needs: [setup_and_build, details] | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Download artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: dist | ||
path: dist/ | ||
|
||
- name: Create GitHub Release | ||
id: create_release | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
run: | | ||
gh release create ${{ needs.details.outputs.tag_name }} dist/* --title ${{ needs.details.outputs.tag_name }} --generate-notes | ||
This file contains 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 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,24 +1,29 @@ | ||
# ngsPETSc | ||
|
||
ngsPETSc is an interface between PETSc and NGSolve/NETGEN that enables the use of NETGEN meshes and geometries in PETSc-based solvers while providing NGSolve users access to the wide array of linear, nonlinear solvers, and time-steppers available in PETSc. | ||
|
||
[![ngsPETSc](https://github.com/UZerbinati/ngsPETSc/actions/workflows/ngsPETSc.yml/badge.svg)](https://github.com/UZerbinati/ngsPETSc/actions/workflows/ngsPETSc.yml) | ||
[![Documentation Status](https://readthedocs.org/projects/ngspetsc/badge/?version=latest)](https://ngspetsc.readthedocs.io/en/latest/?badge=latest) | ||
ngsPETSc is an interface between PETSc and NGSolve/NETGEN that enables the use of NETGEN meshes and geometries in PETSc-based solvers while providing NGSolve users access to the wide array of linear, nonlinear solvers, and time-steppers available in PETSc. | ||
|
||
## Installation | ||
If you already have NGSolve (with MPI support) and PETSc installed, you can install ngsPETSc via pip: | ||
ngsPETSc is available on [PyPI](https://pypi.org/project/ngsPETSc/). | ||
If you have PETSc installed be sure to set the `PETSC_DIR` and `PETSC_ARCH` environment variables to the required values. | ||
You can install by running: | ||
```bash | ||
|
||
git clone https://github.com/UZerbinati/ngsPETSc.git | ||
cd ngsPETSc | ||
pip install . | ||
pip install ngsPETSc | ||
``` | ||
Alternatively, you can also build PETSc, SLEPc, and NGSolve from source following the instructions in the [documentation](https://ngspetsc.readthedocs.io/en/latest/install.html). | ||
|
||
## Getting started | ||
|
||
To get started with ngsPETSc, check out the [documentation](https://ngspetsc.readthedocs.io/en/latest/). | ||
|
||
## Development | ||
If you already have NGSolve (with MPI support) and PETSc installed, you can install ngsPETSc via pip: | ||
```bash | ||
git clone https://github.com/UZerbinati/ngsPETSc.git | ||
pip install ./ngsPETSc | ||
``` | ||
Alternatively, you can also build PETSc, SLEPc, and NGSolve from source following the instructions in the [documentation](https://ngspetsc.readthedocs.io/en/latest/install.html). | ||
|
||
### Testing | ||
To test the installation, you can run the tests in the `tests` folder, via the Makefile in the root directory of the repository: | ||
```bash | ||
make test | ||
make test | ||
``` |
This file contains 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,54 @@ | ||
# Poetry notes for Umberto | ||
|
||
## Poetry | ||
Remember that poetry cannot be installed in the same environment as the project. | ||
Create a virtual environment somewhere permanent and you can use a bash alias to drive poetry: | ||
|
||
```bash | ||
python -m venv ~/.poetry | ||
source ~/.poetry/bin/activate | ||
pip install poetry | ||
|
||
# check location of executable with | ||
which poetry | ||
|
||
# create alias (could be added to ~/.bash_profile) | ||
alias poetry="$HOME/.poetry/bin/poetry" | ||
``` | ||
|
||
When carrying out any of the below tasks create a new empty virtual environment! | ||
```bash | ||
python -m venv temp | ||
source temp/bin/activate | ||
``` | ||
|
||
## Add a dependency | ||
[Docs](https://python-poetry.org/docs/cli/#add) | ||
```bash | ||
poetry add numpy@^2 | ||
``` | ||
|
||
## Build ngsPETSc | ||
[Docs](https://python-poetry.org/docs/cli/#build) | ||
```bash | ||
poetry build | ||
``` | ||
|
||
## Create a release | ||
Follow these steps to create a release: | ||
```bash | ||
# For a bug fix: | ||
poetry version patch | ||
# OR for a minor version bump: | ||
poetry version minor | ||
# OR for a major release: | ||
poetry version minor | ||
|
||
git add pyproject.toml | ||
git commit -m "Release v$(poetry version)" | ||
|
||
git tag -a -m "Release v$(poetry version)" v$(poetry version) | ||
|
||
git push | ||
git push origin v$(poetry version) | ||
``` |
This file contains 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 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
Oops, something went wrong.