diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml new file mode 100644 index 00000000..13e3b051 --- /dev/null +++ b/.github/workflows/macos.yml @@ -0,0 +1,45 @@ +name: pomdp-py macOS build + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + build: + runs-on: macos-latest + strategy: + fail-fast: true + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.10' + - name: Build dependencies + run: | + # Install pomdp-solve macOS binary + wget -P thirdparty https://www.pomdp.org/code/pomdp-solve-os-x.bin + chmod +x thirdparty/pomdp-solve-os-x.bin + + # Build and install SARSOP + git clone https://github.com/personalrobotics/appl.git thirdparty/appl + # Fix Arm build (remove -mfpmath=sse) and declare implict functions + git -C thirdparty/appl apply ../../tests/appl.patch + make -C thirdparty/appl/src + make -C thirdparty/appl/src install + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -e . + - name: Test + working-directory: . + run: | + export POMDP_SOLVE_PATH=./thirdparty/pomdp-solve-os-x.bin + export POMDPSOL_PATH=./thirdparty/appl/bin/pomdpsol + export POMDPCONVERT_PATH=./thirdparty/appl/src/pomdpconvert + python tests/test_all.py diff --git a/.gitignore b/.gitignore index 7ba9b34b..a2875694 100644 --- a/.gitignore +++ b/.gitignore @@ -60,7 +60,6 @@ Demos/*/*.html /dist/ .gitrev .coverage -*.patch *.diff *.orig *.prof @@ -135,3 +134,5 @@ Thumbs.db ############################# *.alpha *.pg + +.DS_Store diff --git a/setup.py b/setup.py index 6ed6be1d..70655dda 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -from setuptools import setup, Extension +from setuptools import setup, Extension, find_packages from Cython.Build import cythonize import os.path @@ -41,6 +41,7 @@ def build_extensions(pkg_name, major_submodules): ext_modules=cythonize( extensions, build_dir="build", compiler_directives={"language_level": "3"} ), + packages=find_packages(exclude=["thirdparty", "thirdparty.*"]), package_data={ "pomdp_py": ["*.pxd", "*.pyx", "*.so", "*.c"], "pomdp_problems": ["*.pxd", "*.pyx", "*.so", "*.c"], diff --git a/tests/appl.patch b/tests/appl.patch new file mode 100644 index 00000000..9047e3f3 --- /dev/null +++ b/tests/appl.patch @@ -0,0 +1,77 @@ +diff --git a/src/Makefile b/src/Makefile +index 456cef1..a58539b 100644 +--- a/src/Makefile ++++ b/src/Makefile +@@ -57,7 +57,7 @@ endif + + CC = gcc + +-CFLAGS = -g -w -O3 $(INCDIR) -msse2 -mfpmath=sse $(CYGWIN_CFLAGS) #-DDEBUG_LOG_ON ++CFLAGS = -g -w -O3 $(INCDIR) -msse2 $(CYGWIN_CFLAGS) #-DDEBUG_LOG_ON + + CXX = g++ + +diff --git a/src/Parser/Cassandra/decision-tree.h b/src/Parser/Cassandra/decision-tree.h +index 9005cef..90da271 100644 +--- a/src/Parser/Cassandra/decision-tree.h ++++ b/src/Parser/Cassandra/decision-tree.h +@@ -23,13 +23,13 @@ permissions and limitations under the License. + + #ifndef INCdecision_tree_h + #define INCdecision_tree_h +- +-#include "Const.h" +- +-#ifdef __cplusplus +-extern "C" { +-#endif +- ++ ++#include "Const.h" ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ + + /********************************************************************** + See an example of how to use this library in testDecisionTree.c. +@@ -70,9 +70,11 @@ extern "C" { + stdout. Intended for debugging. */ + extern void dtDebugPrint(const char* header); + +-#ifdef __cplusplus +-} +-#endif ++ extern void checkAllocatedPointer(void * ptr); ++ ++#ifdef __cplusplus ++} ++#endif + + + +diff --git a/src/Parser/Cassandra/parse_err.h b/src/Parser/Cassandra/parse_err.h +index f2f60bf..01665ba 100644 +--- a/src/Parser/Cassandra/parse_err.h ++++ b/src/Parser/Cassandra/parse_err.h +@@ -157,6 +157,7 @@ void ERR_enter( char *source, + char *modificationString ); + void ERR_initialize(void); + void ERR_cleanUp(void); ++void checkAllocatedPointer(void * ptr); + + #ifdef __cplusplus + } /* extern "C" */ +diff --git a/src/Parser/Cassandra/sparse-matrix.h b/src/Parser/Cassandra/sparse-matrix.h +index 68ae1d1..7324db6 100644 +--- a/src/Parser/Cassandra/sparse-matrix.h ++++ b/src/Parser/Cassandra/sparse-matrix.h +@@ -100,6 +100,7 @@ extern Matrix transformIMatrix( I_Matrix i_matrix ); + extern void displayMatrix( Matrix matrix ); + extern REAL_VALUE sumRowValues( Matrix matrix, int row ); + extern REAL_VALUE getEntryMatrix( Matrix matrix, int row, int col ); ++extern void checkAllocatedPointer(void * ptr); + + #ifdef __cplusplus + } /* extern "C" */