Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 18 additions & 14 deletions .github/workflows/test_python.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
name: Test Python
name: Test Python
on: [push, pull_request]

jobs:
test_linux:
runs-on: ubuntu-latest
test:
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
runner:
- ubuntu-latest
- macos-latest
python-version:
- "3.10"
- "3.x"
steps:
- uses: actions/checkout@v2

- uses: actions/checkout@v6
with:
submodules: recursive

- uses: actions/setup-python@v2
- uses: actions/setup-python@v6
with:
python-version: "3.x"

- name: Upgrade pip
run: pip install -U setuptools wheel pip
python-version: ${{ matrix.python-version }}

- name: Install package for testing
run: pip install ".[test]"
run: python -m pip install ".[test]"

- name: Run tests
run: >
export MPP_DIRECTORY=$(pwd) &&
export MPP_DATA_DIRECTORY=$MPP_DIRECTORY/data &&
pytest
run: pytest
95 changes: 41 additions & 54 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,76 +8,62 @@ jobs:
test_linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v6
with:
submodules: recursive

- uses: actions/setup-python@v2
- uses: actions/setup-python@v6
with:
python-version: "3.x"

- name: Upgrade pip
run: pip install -U setuptools wheel pip

- name: Install package for testing
run: pip install ".[test]"
run: python -m pip install ".[test]"

- name: Run tests
run: >
export MPP_DIRECTORY=$(pwd) &&
export MPP_DATA_DIRECTORY=$MPP_DIRECTORY/data &&
pytest
run: pytest

test_mac:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v6
with:
submodules: recursive

- uses: actions/setup-python@v2
- uses: actions/setup-python@v6
with:
python-version: "3.x"

- name: Upgrade pip
run: pip install -U setuptools wheel pip

- name: Install package for testing
run: pip install ".[test]"
run: python -m pip install ".[test]"

- name: Run tests
run: >
export MPP_DIRECTORY=$(pwd) &&
export MPP_DATA_DIRECTORY=$MPP_DIRECTORY/data &&
pytest
run: pytest

linux_wheels:
strategy:
matrix:
python-version:
- cp36-cp36m
- cp37-cp37m
- cp38-cp38
- cp39-cp39
python-version:
- cp310-cp310
- cp311-cp311
- cp312-cp312
- cp313-cp313
- cp314-cp314

needs: test_linux
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v6
with:
submodules: recursive

- uses: actions/setup-python@v2
- uses: actions/setup-python@v6
with:
python-version: 3.9

- name: Upgrade pip
run: pip install -U setuptools wheel pip
python-version: 3.14

- name: Build manylinux Python wheels
uses: RalfG/python-wheels-manylinux-build@v0.3.4-manylinux2010_x86_64
with:
python-versions: "${{ matrix.python-version }}"
python-versions: ${{ matrix.python-version }}

- uses: actions/upload-artifact@v2
with:
Expand All @@ -88,27 +74,28 @@ jobs:
mac_wheels:
strategy:
matrix:
python-version:
- 3.6
- 3.7
- 3.8
- 3.9
python-version:
- "3.10"
- "3.11"
- "3.12"
- "3.13"
- "3.14"
needs: test_mac
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v6
with:
submodules: recursive

- uses: actions/setup-python@v2
- uses: actions/setup-python@v6
with:
python-version: "${{ matrix.python-version }}"
python-version: ${{ matrix.python-version }}

- name: Upgrade pip
run: pip install -U setuptools wheel pip
- name: Install build
run: python -m pip install build

- name: Build wheels
run: pip wheel . -w dist/
- name: Build wheel
run: python -m build --whell

- uses: actions/upload-artifact@v2
with:
Expand All @@ -120,19 +107,19 @@ jobs:
needs: test_linux
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v6
with:
submodules: recursive

- uses: actions/setup-python@v2
- uses: actions/setup-python@v6
with:
python-version: 3.9
python-version: "3.x"

- name: Upgrade pip
run: pip install -U setuptools wheel pip scikit-build
- name: Install build
run: python -m pip install build

- name: Build sdist
run: python setup.py sdist
run: python -m build --sdist

- uses: actions/upload-artifact@v2
with:
Expand All @@ -159,12 +146,12 @@ jobs:
name: sdist
path: dist

- name: Upgrade pip
run: pip install -U setuptools wheel pip
- uses: actions/setup-python@v6
with:
python-version: "3.x"

- name: Install twine
run: pip install twine
run: python -m pip install twine

- name: Upload wheels
run: twine upload -u __token__ -p "${{ secrets.TESTPYPI_TOKEN }}" --repository testpypi dist/*

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ docs/html/
.vscode/

# Python
dist/
**/__pycache__/
*.pyc
_skbuild/
*.whl

# OS specifics
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ if (BUILD_FORTRAN_WRAPPER)
endif()

#######################################################################
# Python bindings built with pip + scikit-build #
# Python bindings built with scikit-build-core + pybind11 #
#######################################################################

if (SKBUILD)
Expand Down
1 change: 1 addition & 0 deletions interface/python/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
###Build###
build/
dist/
**/__pycache__/
mutationpp.egg-info/
*.so

Expand Down
19 changes: 7 additions & 12 deletions interface/python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
if (CMAKE_VERSION VERSION_LESS 3.18)
set(PY_DEV_MODULE Development)
else()
set(PY_DEV_MODULE Development.Module)
endif()

find_package(Python COMPONENTS Interpreter ${PY_DEV_MODULE} REQUIRED)

execute_process(
COMMAND "${Python_EXECUTABLE}" -m pybind11 --cmakedir
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE pybind11_ROOT)
find_package(Python COMPONENTS Interpreter Development.Module REQUIRED)

find_package(pybind11 CONFIG REQUIRED)

pybind11_add_module(_mutationpp
src/mutationpp_python.cpp
src/pyGlobalOptions.cpp
src/pyMixtureOptions.cpp
src/pyMixture.cpp
)

target_link_libraries(_mutationpp PRIVATE mutation++)

install(TARGETS _mutationpp DESTINATION .)
install(DIRECTORY mutationpp DESTINATION .)

install(TARGETS _mutationpp DESTINATION mutationpp)

install(DIRECTORY "${CMAKE_SOURCE_DIR}/data" DESTINATION mutationpp)
3 changes: 3 additions & 0 deletions interface/python/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<img src="https://raw.githubusercontent.com/mutationpp/mutationpp/HEAD/docs/artwork/mpp-logo.png" alt="Mutation++" width="500"/>

*Mutation++* is an open-source library providing thermodynamic, transport, chemistry, and energy transfer properties associated with subsonic to hypersonic flows.
2 changes: 2 additions & 0 deletions interface/python/mutationpp/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
"""Mutation++ Python bindings"""

from ._mutationpp import *
2 changes: 2 additions & 0 deletions interface/python/src/mutationpp_python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@

namespace py = pybind11;

void py_export_GlobalOptions(py::module &);
void py_export_MixtureOptions(py::module &);
void py_export_Mixture(py::module &);

PYBIND11_MODULE(_mutationpp, m) {
m.doc() = "Mutation++ Python bindings";
py_export_GlobalOptions(m);
py_export_MixtureOptions(m);
py_export_Mixture(m);
}
55 changes: 55 additions & 0 deletions interface/python/src/pyGlobalOptions.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#include <GlobalOptions.h>
#include <pybind11/pybind11.h>

namespace py = pybind11;

/**
* Python wrapper definition for the GlobalOptions class.
*/

namespace {

inline void setDefaultDataDirectory(const std::string& datadir) {
if (std::getenv("MPP_DATA_DIRECTORY") == nullptr) {
Mutation::GlobalOptions::dataDirectory(datadir);
}
};

}

void py_export_GlobalOptions(py::module &m) {

const py::object resources = py::module_::import("importlib.resources");
const py::object pkgname = m.attr("__spec__").attr("parent");
const py::object rootdir = resources.attr("files")(pkgname);
const py::object datadir = rootdir / py::str("data");
const std::string data_directory = py::str(datadir).cast<std::string>();

setDefaultDataDirectory(data_directory);

/**
* Overloaded member functions wrappers
*/

/**
* Python class definition
*/
py::class_<Mutation::GlobalOptions>(m, "GlobalOptions")
.def_static("dataDirectory", [](const std::string& datadir) {
Mutation::GlobalOptions::dataDirectory(datadir);
})
.def_static("dataDirectory", []() {
return Mutation::GlobalOptions::dataDirectory();
})
.def_static("workingDirectory", [](const std::string& workdir) {
Mutation::GlobalOptions::workingDirectory(workdir);
})
.def_static("workingDirectory", []() {
return Mutation::GlobalOptions::workingDirectory();
})
.def_static("reset", [data_directory]() {
Mutation::GlobalOptions::reset();
setDefaultDataDirectory(data_directory);
})
;
}
Loading