Skip to content

Commit

Permalink
Merge branch 'feat-pywheels'
Browse files Browse the repository at this point in the history
  • Loading branch information
alwinw committed Mar 21, 2022
2 parents 9b2f407 + 99cea23 commit d80ec94
Show file tree
Hide file tree
Showing 11 changed files with 120 additions and 34 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/cmake-build.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# Heavily inspired from https://gist.github.com/NickNaso/0d478f1481686d5bcc868cac06620a60
name: CMake Build Matrix
name: CMake Build Janus

# Controls when the action will run. Triggers the workflow on push
on:
push:
branches:
- master
workflow_dispatch:
pull_request:
push:
branches:
- master
release:
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
name: pytest
# Heavily inspired from https://github.com/pybind/cmake_example/blob/master/.github/workflows/pip.yml
name: Test pyJanus

on:
workflow_dispatch:
pull_request:
push:
# branches:
# - master
branches:
- master

jobs:
build:
name: ${{ matrix.config.name }} - py${{ matrix.python-version }}
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
Expand All @@ -18,9 +21,6 @@ jobs:
- { name: "Ubuntu Latest GCC", os: ubuntu-latest }
- { name: "macOS Latest Clang", os: macos-latest }

name: ${{ matrix.config.name }} - py${{ matrix.python-version }}
runs-on: ${{ matrix.config.os }}

steps:
- uses: actions/checkout@v2
with:
Expand Down
79 changes: 79 additions & 0 deletions .github/workflows/pywheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Heavily inspired from https://github.com/pybind/cmake_example/blob/master/.github/workflows/wheels.yml
name: Build & Publish pyJanus Wheels

on:
workflow_dispatch:
# pull_request:
push:
branches:
- master
release:
types:
- published

jobs:
build_sdist:
name: Build SDist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true

- name: Build SDist
run: pipx run build --sdist

- name: Check metadata
run: pipx run twine check dist/*

- uses: actions/upload-artifact@v2
with:
path: dist/*.tar.gz

build_wheels:
name: Wheels on ${{ matrix.config.os }}
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- { name: "Windows Latest MSVC", os: windows-latest }
- { name: "Ubuntu Latest GCC", os: ubuntu-latest }
- { name: "macOS Latest Clang", os: macos-latest }

steps:
- uses: actions/checkout@v2
with:
submodules: true

- uses: pypa/cibuildwheel@v2.3.1
env:
CIBW_ARCHS_MACOS: auto universal2

- name: Verify clean directory
run: git diff --exit-code
shell: bash

- name: Upload wheels
uses: actions/upload-artifact@v2
with:
path: wheelhouse/*.whl

upload_all:
name: Upload if release
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'

steps:
- uses: actions/setup-python@v2

- uses: actions/download-artifact@v2
with:
name: artifact
path: dist

- uses: pypa/gh-action-pypi-publish@v1.5.0
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
3 changes: 2 additions & 1 deletion Python/tests/test_combined_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@
# SOFTWARE.
#

import os
import pyJanus


def test_combined_example():
"""
This checks pyJanus against the Examples/CombinedExample.cpp program
"""
xml_path = "Examples/CombinedExample.xml"
xml_path = f"{os.path.dirname(__file__)}/../../Examples/CombinedExample.xml"
janus = pyJanus.Janus(xml_path)

angle_of_attack = janus.get_variabledef("angleOfAttack")
Expand Down
5 changes: 3 additions & 2 deletions Python/tests/test_gridded_table_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@
# SOFTWARE.
#

import os
import pyJanus


def test_gridded_table_example():
"""
This checks pyJanus against the Examples/GriddedTableExample.cpp program
"""
xml_path = "Examples/GriddedTableExample.xml"
xml_path = f"{os.path.dirname(__file__)}/../../Examples/GriddedTableExample.xml"
janus = pyJanus.Janus(xml_path)

angle_of_attack = janus.get_variabledef("angleOfAttack")
Expand All @@ -38,7 +39,7 @@ def test_gridded_table_example():

angle_of_attack.set_value(10)
reynolds_number.set_value(0.36e6)
assert round(drag_coefficient.get_value(), 2) == 0.01
assert round(drag_coefficient.get_value(), 2) == 0.01

angle_of_attack.set_value(30)
assert round(drag_coefficient.get_value(), 2) == 0.58
Expand Down
9 changes: 7 additions & 2 deletions Python/tests/test_janus_variable_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,17 @@
# SOFTWARE.
#

import os
import pyJanus


def test_janus_variable_manager_example_00():
"""
This checks pyJanus against the Examples/SetVarDefExample.cpp program 00
"""
xml_path = "Examples/JanusVariableManagerExample.xml"
xml_path = (
f"{os.path.dirname(__file__)}/../../Examples/JanusVariableManagerExample.xml"
)
jvm = pyJanus.JanusVariableManager(xml_path)

input00 = pyJanus.JanusVariable(
Expand Down Expand Up @@ -60,7 +63,9 @@ def test_janus_variable_manager_example_01():
"""
This checks pyJanus against the Examples/SetVarDefExample.cpp program 01
"""
xml_path = "Examples/JanusVariableManagerExample.xml"
xml_path = (
f"{os.path.dirname(__file__)}/../../Examples/JanusVariableManagerExample.xml"
)
jvm = pyJanus.JanusVariableManager(xml_path)

input00 = pyJanus.JanusVariable(
Expand Down
3 changes: 2 additions & 1 deletion Python/tests/test_mathml_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@
# SOFTWARE.
#

import os
import pyJanus


def test_mathml_example():
"""
This checks pyJanus against the Examples/MathMLExample.cpp program
"""
xml_path = "Examples/MathMLExample.xml"
xml_path = f"{os.path.dirname(__file__)}/../../Examples/MathMLExample.xml"
janus = pyJanus.Janus(xml_path)

x = janus.get_variabledef("x")
Expand Down
7 changes: 5 additions & 2 deletions Python/tests/test_return_type_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
# SOFTWARE.
#

import os
import pyJanus


Expand All @@ -32,7 +33,7 @@ def test_Janus_return_type_policy():
Reference: <https://pybind11.readthedocs.io/en/stable/advanced/functions.html#return-value-policies>
"""
xml_path = "Examples/CombinedExample.xml"
xml_path = f"{os.path.dirname(__file__)}/../../Examples/CombinedExample.xml"
janus = pyJanus.Janus(xml_path)

angle_of_attack = janus.get_variabledef("angleOfAttack")
Expand All @@ -53,7 +54,9 @@ def test_JanusVariableManager_return_type_policy():
Reference: <https://pybind11.readthedocs.io/en/stable/advanced/functions.html#return-value-policies>
"""
xml_path = "Examples/JanusVariableManagerExample.xml"
xml_path = (
f"{os.path.dirname(__file__)}/../../Examples/JanusVariableManagerExample.xml"
)
jvm = pyJanus.JanusVariableManager(xml_path)

input00 = pyJanus.JanusVariable(
Expand Down
15 changes: 8 additions & 7 deletions Python/tests/test_set_var_def_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@
# SOFTWARE.
#

import os
import pyJanus


def test_set_var_def_example_00():
"""
This checks pyJanus against the Examples/SetVarDefExample.cpp program 00
"""
xml_path = "Examples/SetVarDefExample.xml"
xml_path = f"{os.path.dirname(__file__)}/../../Examples/SetVarDefExample.xml"
janus = pyJanus.Janus(xml_path)

input00 = janus.get_variabledef("input00")
Expand All @@ -43,7 +44,7 @@ def test_set_var_def_example_01():
"""
This checks pyJanus against the Examples/SetVarDefExample.cpp program 01
"""
xml_path = "Examples/SetVarDefExample.xml"
xml_path = f"{os.path.dirname(__file__)}/../../Examples/SetVarDefExample.xml"
janus = pyJanus.Janus(xml_path)

incrementer = janus.get_variabledef("incrementer")
Expand All @@ -63,7 +64,7 @@ def test_set_var_def_example_02():
"""
This checks pyJanus against the Examples/SetVarDefExample.cpp program 02
"""
xml_path = "Examples/SetVarDefExample.xml"
xml_path = f"{os.path.dirname(__file__)}/../../Examples/SetVarDefExample.xml"
janus = pyJanus.Janus(xml_path)

input02 = janus.get_variabledef("input02")
Expand All @@ -79,7 +80,7 @@ def test_set_var_def_example_03():
"""
This checks pyJanus against the Examples/SetVarDefExample.cpp program 03
"""
xml_path = "Examples/SetVarDefExample.xml"
xml_path = f"{os.path.dirname(__file__)}/../../Examples/SetVarDefExample.xml"
janus = pyJanus.Janus(xml_path)

input03 = janus.get_variabledef("input03")
Expand All @@ -95,7 +96,7 @@ def test_set_var_def_example_04():
"""
This checks pyJanus against the Examples/SetVarDefExample.cpp program 04
"""
xml_path = "Examples/SetVarDefExample.xml"
xml_path = f"{os.path.dirname(__file__)}/../../Examples/SetVarDefExample.xml"
janus = pyJanus.Janus(xml_path)

function04_00 = janus.get_variabledef("function04_00")
Expand All @@ -109,7 +110,7 @@ def test_set_var_def_example_05():
"""
This checks pyJanus against the Examples/SetVarDefExample.cpp program 05
"""
xml_path = "Examples/SetVarDefExample.xml"
xml_path = f"{os.path.dirname(__file__)}/../../Examples/SetVarDefExample.xml"
janus = pyJanus.Janus(xml_path)

output05_00 = janus.get_variabledef("output05_00")
Expand All @@ -123,7 +124,7 @@ def test_set_var_def_example_06():
"""
This checks pyJanus against the Examples/SetVarDefExample.cpp program 06
"""
xml_path = "Examples/SetVarDefExample.xml"
xml_path = f"{os.path.dirname(__file__)}/../../Examples/SetVarDefExample.xml"
janus = pyJanus.Janus(xml_path)

output06_00 = janus.get_variabledef("output06_00")
Expand Down
12 changes: 4 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,23 @@
#

[build-system]
requires = [
"setuptools>=42",
"wheel",
"ninja",
"cmake>=3.12",
]
requires = ["setuptools>=42", "wheel", "ninja", "cmake>=3.12"]
build-backend = "setuptools.build_meta"

[tool.isort]
profile = "black"

[tool.pytest.ini_options]
minversion = "6.0"
addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"]
addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config", "-v"]
xfail_strict = true
filterwarnings = ["error"]
testpaths = ["Python/tests"]

[tool.cibuildwheel]
test-skip = ["*universal2:arm64"]
build-verbosity = 1
test-command = "pytest {project}/Python/tests"
test-extras = ["test"]
test-skip = ["*universal2:arm64"]
# Setuptools bug causes collision between pypy and cpython artifacts
before-build = "rm -rf {project}/build"
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def build_extension(self, ext): # sourcery skip: use-named-expression
# logic and declaration, and simpler if you include description/version in a file.
setup(
name="python-janus",
version="0.2.1",
version="0.2.2",
author="Alwin Wang",
author_email="16846521+AlwinW@users.noreply.github.com",
url="https://github.com/alwinw/pyJanus",
Expand Down

0 comments on commit d80ec94

Please sign in to comment.