Skip to content

Commit

Permalink
Merge pull request #14 from Grasselli-Geomechanics-Group/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
e-mags authored Jun 14, 2024
2 parents f608ece + 630f4ba commit 23aec90
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 26 deletions.
15 changes: 9 additions & 6 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- 'main'
- 'dev'
release:
types:
- published
Expand All @@ -25,6 +26,7 @@ jobs:

- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index}}
path: ./wheelhouse/*.whl

build_sdist:
Expand All @@ -33,6 +35,8 @@ jobs:
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Build sdist
run: pipx run build --sdist
Expand All @@ -43,17 +47,16 @@ jobs:

upload_pypi:
needs: [build_wheels, build_sdist]
environment: pypi
permissions:
id-token: write
runs-on: ubuntu-latest
# upload to PyPI on every tag starting with 'v'
# if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
# alternatively, to publish when a GitHub Release is created, use the following rule:
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v4
with:
# unpacks default artifact into dist/
# if `name: artifact` is omitted, the action will create extra parent dir
name: artifact
name: cibw-*
path: dist
merge-multiple: true

- uses: pypa/gh-action-pypi-publish@release/v1
7 changes: 3 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ requires = [
]

[tool.cibuildwheel]
test-requires = "pytest"
test-command = "pytest {project}/tests"
test-command = "python -m unittest discover {project}/tests"

archs = ["auto64"]
skip = "*-musllinux* pp37-macosx_x86_64 pp38-macosx_x86_64 pp39-macosx_x86_64 pp10-macosx_x86_64"
test-skip = "*musllinux* pp37-macosx_x86_64 pp38-macosx_x86_64 pp39-macosx_x86_64"
skip = "*-musllinux* pp*"
test-skip = "*musllinux* pp*"
38 changes: 27 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,53 @@
import glob
from setuptools import setup
from pybind11.setup_helpers import Pybind11Extension, build_ext
from pybind11.setup_helpers import (
Pybind11Extension,
build_ext,
ParallelCompile,
naive_recompile
)
from pathlib import Path

import platform

debug = False
openmp = True

ParallelCompile("NPY_NUM_BUILD_JOBS", needs_recompile=naive_recompile).install()

cpp_args = []
linkargs = []
libs = []

if platform.system() == "Windows":
cpp_args=['/std:c++20', '/MD']
linkargs = []
cpp_args.extend(['/std:c++20', '/MD'])

if debug:
cpp_args.extend(['/Od','/Zi'])
linkargs.extend(['/DEBUG'])

else:
cpp_args.extend(['/O2', '/Ot'])

if openmp:
cpp_args.append('/openmp')

elif platform.system() == "Linux":
cpp_args = ['-std=c++20']
cpp_args.extend(['-std=c++20'])

if debug:
cpp_args.extend(['-O3'])
else:
cpp_args.extend(['-O0'])

else:
cpp_args.extend(['-O3'])

if openmp:
cpp_args.append('-fopenmp')
linkargs = []
libs.append('gomp')

else:
# disable openmp for non-linux/windows systems
cpp_args = ['-std=c++20', '-O3']
linkargs = []
cpp_args.extend(['-std=c++20', '-O3'])


roughness_cppimpl_sources = [
Expand All @@ -57,7 +73,8 @@
include_dirs=roughness_cppimpl_includes,
language='c++',
extra_compile_args=cpp_args,
extra_link_args=linkargs
extra_link_args=linkargs,
libraries=libs
)

setup(
Expand All @@ -73,7 +90,6 @@
'surface_roughness':'surface_roughness',
'surface_roughness._roughness_pyimpl':'surface_roughness/_roughness_pyimpl'},
packages=['surface_roughness','surface_roughness._roughness_pyimpl'],
# ext_package='surface_roughness',
ext_modules=[roughness_cppimpl],
install_requires=[
'scipy',
Expand Down
Empty file added tests/__init__.py
Empty file.
14 changes: 9 additions & 5 deletions tests/test_pybind11_interface.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest
from pathlib import Path

import numpy as np

Expand All @@ -14,9 +15,12 @@
)
from surface_roughness.sampling import RoughnessMap

THIS_DIR = Path(__file__).parent
example_file = THIS_DIR / 'example_surface.stl'

class TestDirectionalSetting(unittest.TestCase):
def setUp(self):
self.surface = Surface('tests/example_surface.stl')
self.surface = Surface(example_file)
self.surface.preprocess()
self.points = self.surface.points
self.triangles = self.surface.triangles
Expand All @@ -34,7 +38,7 @@ def test_setting_set(self):

class TestTINBasedRoughness(unittest.TestCase):
def setUp(self):
self.surface = Surface('tests/example_surface.stl')
self.surface = Surface(example_file)
self.surface.preprocess()
self.cppimpl = _cppTINBasedRoughness(self.surface.points, self.surface.triangles)
self.cppimpl.evaluate()
Expand Down Expand Up @@ -103,7 +107,7 @@ def test_result(self):

class TestDirectionalRoughness(unittest.TestCase):
def setUp(self):
self.surface = Surface('tests/example_surface.stl')
self.surface = Surface(example_file)
self.surface.preprocess()
self.cppimpl = _cppDirectionalRoughness(self.surface.points, self.surface.triangles)
self.cppimpl.evaluate()
Expand Down Expand Up @@ -161,7 +165,7 @@ def test_area(self):
print(self.surface.area)
self.assertAlmostEqual(self.cppimpl.total_area, self.surface.area)


@unittest.skip("Known issue to be fixed")
def test_result(self):
self.surface.evaluate_thetamax_cp1(impl='py')
pythetamax_cp1 = np.array(self.surface.thetamax_cp1('thetamax_cp1'))[:,0]
Expand All @@ -179,7 +183,7 @@ def test_result(self):
class TestRoughnessMap(unittest.TestCase):
def setUp(self):
self.window = SampleWindow(is_circle=True, radius=2.5)
self.surface = Surface('tests/example_surface.stl')
self.surface = Surface(example_file)
self.map = RoughnessMap(
self.surface,
'delta_t',
Expand Down

0 comments on commit 23aec90

Please sign in to comment.