Skip to content
30 changes: 28 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ env:
CTEST_OUTPUT_ON_FAILURE: 1

jobs:
build:
build-cmake:
runs-on: ubuntu-latest

steps:
Expand All @@ -35,7 +35,7 @@ jobs:
uses: actions/cache@v4
with:
path: build
key: ${{ github.event.pull_request.number }}
key: cmake_${{ github.event.pull_request.number }}

- name: Configure CMake
run: cmake --preset develop -DGINKGO_BUILD_OMP=OFF
Expand All @@ -45,3 +45,29 @@ jobs:

- name: Run specific test
run: ctest --preset develop
build-pip:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.8'
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe you can take a look on https://docs.github.com/en/actions/how-tos/write-workflows/choose-what-workflows-do/run-job-variations
I think we need to publish several python version?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

true, but this is just for testing. I was a bit reluctant to add more versions here since a single build takes already 40minutes. i fear that we might run out of ci credits.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see. When we open source this repo, github action will give unlimited credits for ci


- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libopenmpi-dev
pip install pytest numpy torch build

- name: Set up cache
uses: actions/cache@v4
with:
path: .py-build-cmake_cache
key: pip_${{ github.event.pull_request.number }}

- name: Pip install package
run: python3 -m build --config-setting "override=cmake.build_args=[\"-j\",\"2\"]"
30 changes: 30 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Upload Python Package to PyPI when a Release is Created

on:
release:
types: [created]

jobs:
pypi-publish:
name: Publish release to PyPI
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/pyGinkgo
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel
- name: Build package
run: |
python setup.py sdist bdist_wheel # Could also be python -m build
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ The tests successfully run on the following Python versions:
### Prerequisites

- Python 3.x
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- Python 3.x
- Python 3.8+

- Ginkgo
- Ginkgo (preinstalled, otherwise it will be cloned during build)
- Pybind11
- Ninja # if you want to use cmake presets
- [pybind11-stubgen](https://pypi.org/project/pybind11-stubgen/) # if you want to use [stubs generation](#stubs-generation)

### Building the module
### Building the module via Cmake
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
### Building the module via Cmake
### Building the module via CMake


1. **Clone the repository**:
```bash
Expand Down Expand Up @@ -61,6 +61,17 @@ To run a particular test, say 'pyginkgo_import_test':
ctest -R pyginkgo_import_test
```

### Building the module via pip
You can invoke the build and installation process via pip, this however will require the same dependencies to be present as with the default Cmake installation.
To install pyGinkgo from source use
```bash
pip install .
```
or alternatively getting it from PyPi
```bash
pip install pyGinkgo
```

### Stubs generation
From [Python mypy documentation](https://mypy.readthedocs.io/en/stable/stubgen.html):
> A stub file (see [PEP 484](https://peps.python.org/pep-0484/)) contains only type hints for the public interface of a module, with empty function bodies. Mypy can use a stub file instead of the real implementation to provide type information for the module. They are useful for third-party modules whose authors have not yet added type hints (and when no stubs are available in typeshed) and C extension modules (which mypy can’t directly process).
Expand Down
50 changes: 36 additions & 14 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,57 @@ name = "pyGinkgo"
version = "0.0.0"
description = "PyGinkgo is a Python binding for the Ginkgo framework, providing access to Ginkgo's powerful linear algebra capabilities from Python."
authors = [
{name = "Keshvi Tuteja ", email = "[email protected]"},
{name = "Gregor Olenik", email = "[email protected]"},
{name = "Keshvi Tuteja", email= "[email protected]"},
{name = "Roman Mishchuk", email= "[email protected]"},
{name = "Yu-Hsiang M. Tsai", email= "[email protected]"},
{name = "Gregor Olenik", email = "[email protected]"},
]
license = {text = "MIT"}
readme="Readme.md"
readme="README.md"
classifiers = [
"Intended Audience :: Developers",
"Programming Language :: Python :: 3",
"Programming Language :: C++",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Environment :: GPU",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"Topic :: Scientific/Engineering :: Mathematics",
]
requires-python = ">=3.6"
keywords = ["sparse-linear-algebra", "high-performance-computing", "krylov-methods", "spmv", "gpu-computing"]
requires-python = ">=3.8"
dependencies = [
"numpy",
"pybind11",
"pybind11==2.12.0"
]

[build-system]
requires = ["py-build-cmake~=0.5.0"]
build-backend = "py_build_cmake.build"

[tool.py-build-cmake.module]
name = "pyGinkgo"

[tool.py-build-cmake.sdist]
include = ["CMakeLists.txt", "src", "cmake/*", "tests"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
include = ["CMakeLists.txt", "src", "cmake/*", "tests"]
include = ["CMakeLists.txt", "src", "cmake/*", "tests", "CTestConfig.cmake"]


[tool.py-build-cmake.cmake]
minimum_version="3.20"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
minimum_version="3.20"
minimum_version="3.21"

Is there any reason for 3.20?
When using ginkgo hip, we require 3.21.
Maybe for simplicity, we use 3.21 here?

build_type="Release"
build_args=["-j", "8"]

[project_urls]
Documentation= "https://obr.readthedocs.io/"
Documentation= "https://github.com/Helmholtz-AI-Energy/pyGinkgo/blob/main/README.md"
Changelog= "https://github.com/Helmholtz-AI-Energy/pyGinkgo/blob/main/CHANGELOG.md"
Issues= "https://github.com/Helmholtz-AI-Energy/pyGinkgo/issues"

[project.optional-dependencies]
doc = [
"sphinx==6.2.1",
"sphinx-autoapi==3.0.0",
"sphinxcontrib.applehelp==1.0.7",
"furo",
"myst_parser",
]
test = [
"pytest",
]

[tool.cibuildwheel]
build-verbosity = 1
environment = { PY_BUILD_CMAKE_VERBOSE="1" }
test-command = "pytest {package}/tests"
test-extras = ["test"]
Loading