diff --git a/README.md b/README.md index 61ffef4..6a24799 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ matplotlib-cpp ============== +[![Build status](https://ci.appveyor.com/api/projects/status/qcv0r9y4jf5bvxa8?svg=true)](https://ci.appveyor.com/project/Chachay/matplotlib-cpp) + Welcome to matplotlib-cpp, possibly the simplest C++ plotting library. It is built to resemble the plotting API used by Matlab and matplotlib. diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..8578305 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,31 @@ +version: 1.0.{build} +branches: + only: + - dev3 +image: +- Visual Studio 2015 +- Visual Studio 2017 +- Visual Studio 2019 +configuration: Release +platform: x64 +init: +- cmd: >- + echo %APPVEYOR_BUILD_WORKER_IMAGE% + + if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2015" set MSVC_VERSION=14 + + if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" set MSVC_VERSION=15 + + if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2019" set MSVC_VERSION=19 + + set PATH=%PYTHONHOME%;%PYTHONHOME%\Scripts;%ProgramFiles(x86)%\Microsoft Visual Studio\Installer;%PATH% +environment: + PYTHONHOME: C:\Miniconda37-x64 +install: +- cmd: >- + conda install --yes numpy matplotlib +build_script: +- cmd: >- + cd contrib + + call WinBuild.cmd \ No newline at end of file diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index edb40b1..b402d9b 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -9,6 +9,7 @@ include_directories(${PYTHONHOME}/Lib/site-packages/numpy/core/include) link_directories(${PYTHONHOME}/libs) add_definitions(-DMATPLOTLIBCPP_PYTHON_HEADER=Python.h) +add_compile_definitions(WITHOUT_NUMPY) # message(STATUS "*** dump start cmake variables ***") # get_cmake_property(_variableNames VARIABLES) diff --git a/contrib/README.md b/contrib/README.md index 0af8515..19dffd2 100644 --- a/contrib/README.md +++ b/contrib/README.md @@ -30,3 +30,8 @@ The `WinBuild.cmd` will set up temporal ENV variables and build binaries in (mat 3. Find exe files in examples/build/Release Note: platforms folder is necessary to make qt works. + + +### Check before run examples +If you use Anaconda on Windows, you might need to set PYTHONHOME to Anaconda home directory and QT_QPA_PLATFORM_PLUGIN_PATH to %PYTHONHOME%Library/plugins/platforms. The latter is for especially when you get the error which says 'This application failed to start because it could not find or load the Qt platform plugin "windows" +in "".' diff --git a/contrib/WinBuild.cmd b/contrib/WinBuild.cmd index 9dfd627..f70c736 100644 --- a/contrib/WinBuild.cmd +++ b/contrib/WinBuild.cmd @@ -2,9 +2,9 @@ @setlocal EnableDelayedExpansion REM ------Set Your Environment------------------------------- -if NOT DEFINED MSVC_VERSION set MSVC_VERSION=15 +if NOT DEFINED MSVC_VERSION set MSVC_VERSION=19 if NOT DEFINED CMAKE_CONFIG set CMAKE_CONFIG=Release -if NOT DEFINED PYTHONHOME set PYTHONHOME=C:/Users/%username%/Anaconda3 +if NOT DEFINED PYTHONHOME set PYTHONHOME=C:/Users/%username%/miniconda3 REM --------------------------------------------------------- set KEY_NAME="HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\SxS\VS7" @@ -28,9 +28,13 @@ if "%MSVC_VERSION%"=="14" ( ) else ( set CMAKE_GENERATOR=Visual Studio 15 2017 ) +) else if "%MSVC_VERSION%"=="19" ( + set CMAKE_GENERATOR=Visual Studio 16 2019 ) -if "%MSVC_VERSION%"=="15" ( - for /F "usebackq tokens=1,2,*" %%A in (`REG QUERY %KEY_NAME% /v %VALUE_NAME%`) do ( + +if "%MSVC_VERSION%" GEQ "15" ( + REM Find VC ยท microsoft/vswhere Wiki https://github.com/microsoft/vswhere/wiki/Find-VC + for /F "usebackq tokens=1,2,*" %%A in (`vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do ( set batch_file=%%CVC\Auxiliary\Build\vcvarsall.bat ) ) else ( @@ -43,16 +47,27 @@ pushd examples if NOT EXIST build mkdir build pushd build -cmake -G"!CMAKE_GENERATOR!" ^ - -DPYTHONHOME:STRING=%PYTHONHOME%^ - -DCMAKE_BUILD_TYPE:STRING=%CMAKE_CONFIG% ^ - %~dp0 +if "%MSVC_VERSION%" GEQ "19" ( + cmake -G"!CMAKE_GENERATOR!" -A x64^ + -DPYTHONHOME:STRING=%PYTHONHOME%^ + -DCMAKE_BUILD_TYPE:STRING=%CMAKE_CONFIG% ^ + %~dp0 +) else ( + cmake -G"!CMAKE_GENERATOR!" ^ + -DPYTHONHOME:STRING=%PYTHONHOME%^ + -DCMAKE_BUILD_TYPE:STRING=%CMAKE_CONFIG% ^ + %~dp0 +) cmake --build . --config %CMAKE_CONFIG% +SET BUILD_ERRORLEVEL=!ERRORLEVEL! +IF NOT "!BUILD_ERRORLEVEL!"=="0" ( + EXIT /B !BUILD_ERRORLEVEL! +) pushd %CMAKE_CONFIG% if not EXIST platforms mkdir platforms -if EXIST %PYTHONHOME%/Library/plugins/platforms/qwindows.dll ^ -cp %PYTHONHOME%/Library/plugins/platforms/qwindows.dll ./platforms/ +if EXIST %PYTHONHOME%\Library\plugins\platforms\qwindows.dll ^ +copy %PYTHONHOME%\Library\plugins\platforms\qwindows.dll .\platforms\ popd REM move ./%CMAKE_CONFIG% ../ popd diff --git a/matplotlibcpp.h b/matplotlibcpp.h index 6770074..3774e40 100644 --- a/matplotlibcpp.h +++ b/matplotlibcpp.h @@ -13,6 +13,7 @@ #include #include // requires c++11 support #include +#include #ifndef WITHOUT_NUMPY # define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION @@ -312,9 +313,9 @@ template <> struct select_npy_type { const static NPY_TYPES type = NPY // Sanity checks; comment them out or change the numpy type below if you're compiling on // a platform where they don't apply -static_assert(sizeof(long long) == 8); +static_assert(sizeof(long long) == 8, "long long must be 8 byte"); template <> struct select_npy_type { const static NPY_TYPES type = NPY_INT64; }; -static_assert(sizeof(unsigned long long) == 8); +static_assert(sizeof(unsigned long long) == 8, "unsigned long long must be 8 byte"); template <> struct select_npy_type { const static NPY_TYPES type = NPY_UINT64; }; // TODO: add int, long, etc.