diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml new file mode 100644 index 00000000..55ed6cf7 --- /dev/null +++ b/.github/workflows/build_wheels.yml @@ -0,0 +1,35 @@ +name: Build Wheels + +on: + push: + branches: + - main + pull_request: + paths-ignore: + - "**.md" + +jobs: + build_wheels: + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + + steps: + - uses: actions/checkout@v3 + + - name: Build wheels + uses: pypa/cibuildwheel@v2.12.1 + # env: + # CIBW_SOME_OPTION: value + # ... + # with: + # package-dir: . + # output-dir: wheelhouse + # config-file: "{package}/pyproject.toml" + + - uses: actions/upload-artifact@v3 + with: + path: ./wheelhouse/*.whl diff --git a/.gitignore b/.gitignore index 05855f19..c840c1f3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,10 @@ btrack/include/eigen -btrack/__pycache__ -btrack/optimise/__pycache__ +__pycache__ btrack/agents.py btrack/render_movie.py models/MDCK_* examples/napari.png -examples/.ipynb_checkpoints +*.ipynb_checkpoints models/test_config.json notebooks deprecated @@ -25,3 +24,7 @@ docs/api/* coverage.xml .envrc .hypothesis +*.so +*.dylib +*.DLL +wheelhouse diff --git a/Makefile b/Makefile deleted file mode 100644 index 4524ccd1..00000000 --- a/Makefile +++ /dev/null @@ -1,64 +0,0 @@ -UNAME := $(shell uname) - -ifeq ($(UNAME), Linux) - # do something Linux #-fopenmp -static - CXX = g++ - EXT = so - XLDFLAGS = -Wl,--no-undefined -Wl,--no-allow-shlib-undefined - #-L/usr/local/cuda/lib64 -lcuda -lcudart -endif -ifeq ($(UNAME), Darwin) - # do something OSX - CXX = clang++ -arch x86_64 -arch arm64 - EXT = dylib - XLD_FLAGS = -arch x86_64 -arch arm64 -endif -ifeq ($(UNAME), Windows) - # do something Windowsy - CXX = x86_64-w64-mingw32-g++ - EXT = DLL - XLDFLAGS = -static-libgcc -static-libstdc++ -endif - -NVCC = nvcc - - -# automatically get the version numbers from VERSION.txt -VERSION_FILE := ./btrack/VERSION.txt -VERSION_MAJOR = $(shell cat $(VERSION_FILE) | cut -f1 -d.) -VERSION_MINOR = $(shell cat $(VERSION_FILE) | cut -f2 -d.) -VERSION_BUILD = $(shell cat $(VERSION_FILE) | cut -f3 -d.) - -# If your compiler is a bit older you may need to change -std=c++11 to -std=c++0x -#-I/usr/include/python2.7 -L/usr/lib/python2.7 # -O3 -LLDBFLAGS = -CXXFLAGS = -c -std=c++11 -m64 -fPIC -I"./btrack/include" \ - -DDEBUG=false -DVERSION_MAJOR=$(VERSION_MAJOR) \ - -DVERSION_MINOR=$(VERSION_MINOR) -DVERSION_BUILD=$(VERSION_BUILD) \ - -DBUILD_SHARED_LIB -OPTFLAGS = -O3 -LDFLAGS = -shared $(XLDFLAGS) - - -EXE = tracker -SRC_DIR = ./btrack/src -OBJ_DIR = ./btrack/obj -SRC = $(wildcard $(SRC_DIR)/*.cc) -OBJ = $(SRC:$(SRC_DIR)/%.cc=$(OBJ_DIR)/%.o) - -# make it -all: $(EXE) - -$(EXE): $(OBJ) - $(CXX) $(LDFLAGS) -o ./btrack/libs/libtracker.$(EXT) $^ - -$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cc - $(CXX) $(CXXFLAGS) $(OPTFLAGS) $(LLDBFLAGS) -c $< -o $@ - -# make with debug symbols -debug: LLDBFLAGS = -glldb -debug: OPTFLAGS = -debug: all - -clean: - $(RM) $(OBJ) diff --git a/btrack/include/defs.h b/btrack/include/defs.h index c21ebca4..715be34a 100644 --- a/btrack/include/defs.h +++ b/btrack/include/defs.h @@ -23,6 +23,15 @@ #ifndef M_PI #define M_PI 3.14159265358979323846 #endif +#ifndef VERSION_MAJOR + #define VERSION_MAJOR 0 +#endif +#ifndef VERSION_MINOR + #define VERSION_MINOR 0 +#endif +#ifndef VERSION_BUILD + #define VERSION_BUILD 0 +#endif // store some information about the compilation static unsigned int v_major = VERSION_MAJOR; diff --git a/btrack/include/hypothesis.h b/btrack/include/hypothesis.h index 9fc690f8..2f80e6ca 100644 --- a/btrack/include/hypothesis.h +++ b/btrack/include/hypothesis.h @@ -31,7 +31,7 @@ #include "pdf.h" #include "updates.h" #include "bayes.h" - +#include // Store a hypothesis to return to Python diff --git a/btrack/include/tracklet.h b/btrack/include/tracklet.h index bb2bd1ce..772cb6b8 100644 --- a/btrack/include/tracklet.h +++ b/btrack/include/tracklet.h @@ -24,6 +24,7 @@ #include "motion.h" #include "inference.h" #include "defs.h" +#include // #define MAX_LOST 5 diff --git a/btrack/include/types.h b/btrack/include/types.h index 8c239bff..69cff3d1 100644 --- a/btrack/include/types.h +++ b/btrack/include/types.h @@ -23,6 +23,7 @@ #include #include #include "defs.h" +#include diff --git a/btrack/libs/libtracker.DLL b/btrack/libs/libtracker.DLL deleted file mode 100755 index 102ea38c..00000000 Binary files a/btrack/libs/libtracker.DLL and /dev/null differ diff --git a/btrack/libs/libtracker.dylib b/btrack/libs/libtracker.dylib deleted file mode 100755 index 872b3a15..00000000 Binary files a/btrack/libs/libtracker.dylib and /dev/null differ diff --git a/btrack/libs/libtracker.so b/btrack/libs/libtracker.so deleted file mode 100755 index 67f6507f..00000000 Binary files a/btrack/libs/libtracker.so and /dev/null differ diff --git a/btrack/src/tracker.cc b/btrack/src/tracker.cc index 6fe8fb3b..cda31f4b 100644 --- a/btrack/src/tracker.cc +++ b/btrack/src/tracker.cc @@ -14,6 +14,9 @@ -------------------------------------------------------------------------------- */ +#ifndef DEBUG + #define DEBUG 0 +#endif #include "tracker.h" @@ -519,7 +522,7 @@ void BayesianTracker::cost_EXACT( // set up some variables for Bayesian updates double uniform_prior = 1. / (n_objects+1); - double prior_assign, PrDP, posterior, update, safe_update; + double prior_assign, posterior, safe_update; // start by intializing the belief matrix with a uniform prior if (use_uniform_prior) { @@ -586,7 +589,7 @@ void BayesianTracker::cost_APPROXIMATE( std::clock_t t_update_start = std::clock(); // set up some variables for Bayesian updates - double prior_assign, PrDP, posterior, safe_update; + double prior_assign, posterior, safe_update; // Posterior is a misnoma here because it is initially the prior, but // becomes the posterior diff --git a/build.sh b/build.sh index 19ff7e2a..d5b8116c 100755 --- a/build.sh +++ b/build.sh @@ -9,12 +9,3 @@ if [ ! -e ./btrack/include/eigen/signature_of_eigen3_matrix_library ] then git clone https://gitlab.com/libeigen/eigen.git ./btrack/include/eigen fi - -# build the tracker -echo "Compiling btrack from source..." -make clean -make - -# run the installation -echo "Installing btrack python package..." -pip install -e . diff --git a/pyproject.toml b/pyproject.toml index e7d73cd2..b6d76223 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -71,6 +71,23 @@ exclude = ''' line-length = 79 target-version = ["py38", "py39", "py310"] +[tool.cibuildwheel] +before-all = [ + "bash build.sh", +] +test-command = "pytest {project}" +test-extras = [ + "napari", +] +test-requires = [ + "dask", + "pytest", +] +linux.before-all = [ + "yum install -y fontconfig", + "bash build.sh", +] + [tool.coverage] report = {skip_covered = true, sort = "cover"} run = {branch = true, parallel = true, source = ["btrack"]} diff --git a/setup.py b/setup.py new file mode 100644 index 00000000..907dfcad --- /dev/null +++ b/setup.py @@ -0,0 +1,12 @@ +from setuptools import Extension, setup + +setup( + ext_modules=[ + Extension( + "libtracker", + ["btrack/src/tracker.cc"], + include_dirs=["btrack/include"], + extra_compile_args=["-c", "-std=c++17", "-m64", "-fPIC"], + ), + ], +)