diff --git a/.travis.yml b/.travis.yml index 421e5fba1..c044e085f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,6 +24,19 @@ jobs: CXX: g++ CC: gcc + - os: windows + language: c++ + env: + - MINCONDA_VERSION="latest" + - CMAKE_GENERATOR="Visual Studio 15 2017 Win64" + - TESTS_TARGET="RUN_TESTS"; + install: + - choco install --yes miniconda3 + - source C:/Tools/miniconda3/Scripts/activate + - conda config --set always_yes yes --set changeps1 no + - conda update -q conda + - conda install -c conda-forge hdf5 + addons: homebrew: packages: @@ -32,7 +45,6 @@ addons: packages: - libhdf5-dev - cache: directories: - $HOME/.cache/pip @@ -42,6 +54,7 @@ python: - 3.7 install: skip + script: - ./ci/python_test.sh - ./ci/cpp_test.sh diff --git a/CMake/CompilerFlags.cmake b/CMake/CompilerFlags.cmake index eea2246f5..ecebe0e16 100644 --- a/CMake/CompilerFlags.cmake +++ b/CMake/CompilerFlags.cmake @@ -1,5 +1,7 @@ # Taken from https://github.com/BlueBrain/hpc-coding-conventions/blob/master/cpp/cmake/bob.cmake#L192-L255 -if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") +if (WIN32) + set(FLAGS "${FLAGS} /DH5_BUILT_AS_DYNAMIC_LIB /EHsc /D_USE_MATH_DEFINES") +elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") if(${PROJECT_NAME}_CXX_WARNINGS) set(FLAGS "${FLAGS} -Werror -Weverything") # Using std=c++11, no need for 98 compat diff --git a/ci/cpp_test.sh b/ci/cpp_test.sh index 6fca7a16d..96c82fbd4 100755 --- a/ci/cpp_test.sh +++ b/ci/cpp_test.sh @@ -7,7 +7,7 @@ set -euxo pipefail rm -rf build mkdir build -cd build -cmake .. -DMorphIO_CXX_WARNINGS=ON -make -j2 -make test +pushd build +cmake -DMorphIO_CXX_WARNINGS=ON -G "${CMAKE_GENERATOR:-Unix Makefiles}" .. +cmake --build . +popd diff --git a/ci/python_test.sh b/ci/python_test.sh index 0d68d425b..cc4b8faaf 100755 --- a/ci/python_test.sh +++ b/ci/python_test.sh @@ -4,21 +4,22 @@ set -euxo pipefail VENV=env -rm -rf "$VENV" -python3 -mvenv "$VENV" +if [[ "$OSTYPE" != "msys" ]]; then + rm -rf "$VENV" + python3 -mvenv "$VENV" -set +u # ignore errors in virtualenv's activate -source "$VENV/bin/activate" -set -u + set +u # ignore errors in virtualenv's activate + source "$VENV/bin/activate" + set -u -which pip + which pip -pip install --upgrade pip setuptools - -# install -pip install -vvv . + pip install --upgrade pip setuptools +fi +pip install . pip install -r tests/requirement_tests.txt + CURRENT=$(pwd) cd .. diff --git a/setup.py b/setup.py index 92bd495dc..de3db94e8 100644 --- a/setup.py +++ b/setup.py @@ -71,9 +71,8 @@ def build_extension(self, ext, cmake): cmake_args += ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{}={}'.format( cfg.upper(), extdir)] - if sys.maxsize > 2**32: - cmake_args += ['-A', 'x64'] - build_args += ['--', '/m'] + cmake_args += ['-G', os.getenv('MORPHIO_CMAKE_GENERATOR', + "Visual Studio 15 2017 Win64")] else: cmake_args += ['-DCMAKE_BUILD_TYPE={}'.format(cfg), '-DMorphIO_CXX_WARNINGS=OFF', diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 618088465..905e944bb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -70,16 +70,19 @@ set_target_properties(morphio_obj CXX_EXTENSIONS NO ) -target_compile_options(morphio_obj - PRIVATE - -Wall - -Wextra - -Wnon-virtual-dtor - -pedantic - ) +if (NOT WIN32) + target_compile_options(morphio_obj + PRIVATE + -Wall + -Wextra + -Wnon-virtual-dtor + -pedantic + ) +endif() add_library(morphio_static STATIC $) add_library(morphio_shared SHARED $) + set_target_properties(morphio_shared PROPERTIES OUTPUT_NAME "morphio" EXPORT_NAME "morphio") diff --git a/src/morphology.cpp b/src/morphology.cpp index cb559eab7..58b4f780f 100644 --- a/src/morphology.cpp +++ b/src/morphology.cpp @@ -102,7 +102,7 @@ std::vector
Morphology::sections() const { std::vector
sections_; auto count = _properties->get().size(); sections_.reserve(count); - for (uint i = 0; i < count; ++i) { + for (unsigned int i = 0; i < count; ++i) { sections_.emplace_back(section(i)); } return sections_; diff --git a/src/vasc/vasculature.cpp b/src/vasc/vasculature.cpp index f834f1b33..213e0f52b 100644 --- a/src/vasc/vasculature.cpp +++ b/src/vasc/vasculature.cpp @@ -1,5 +1,10 @@ #include // uint32_t +#if defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) || defined(__MINGW32__) +#define F_OK 0 +#include +#else #include // access / F_OK +#endif #include #include diff --git a/src/vector_utils.cpp b/src/vector_utils.cpp index b57ae5baa..6b8a55e6b 100644 --- a/src/vector_utils.cpp +++ b/src/vector_utils.cpp @@ -3,6 +3,7 @@ #include // std::accumulate #include // std::stringstream #include // std::string +#include // std::tolower #include diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 954e77c5d..4498ab587 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -13,7 +13,7 @@ set_target_properties(unittests ) target_link_libraries(unittests - PRIVATE morphio_shared HighFive + PRIVATE morphio_static HighFive ) add_test(NAME unittests diff --git a/tests/test_1_swc.py b/tests/test_1_swc.py index 291a2f5c9..15396cb1a 100644 --- a/tests/test_1_swc.py +++ b/tests/test_1_swc.py @@ -21,7 +21,6 @@ def test_read_single_neurite(): 3 3 0 0 3 0.5 2 4 3 0 0 4 0.5 3 5 3 0 0 5 0.5 4''') as tmp_file: - n = Morphology(tmp_file.name) assert_array_equal(n.soma.points, [[0, 4, 0]]) @@ -320,10 +319,10 @@ def test_disconnected_neurite(): with ostream_redirect(stdout=True, stderr=True): n = Morphology(os.path.join(_path, 'disconnected_neurite.swc')) assert_equal( - _path + '''/disconnected_neurite.swc:10:warning + '''{}:10:warning Warning: found a disconnected neurite. Neurites are not supposed to have parentId: -1 -(although this is normal if this neuron has no soma)''', +(although this is normal if this neuron has no soma)'''.format(os.path.join(_path, 'disconnected_neurite.swc')), strip_color_codes(err.getvalue().strip())) def test_neurite_wrong_root_point(): @@ -338,12 +337,13 @@ def test_neurite_wrong_root_point(): with captured_output() as (_, err): with ostream_redirect(stdout=True, stderr=True): - n = Morphology(os.path.join(_path, 'neurite_wrong_root_point.swc')) + path = os.path.join(_path, 'neurite_wrong_root_point.swc') + n = Morphology(path) assert_string_equal( '''Warning: with a 3 points soma, neurites must be connected to the first soma point: -{}/neurite_wrong_root_point.swc:4:warning +{}:4:warning -{}/neurite_wrong_root_point.swc:6:warning'''.format(_path, _path), +{}:6:warning'''.format(path, path), err.getvalue()) assert_equal(len(n.root_sections), 2) assert_array_equal(n.root_sections[0].points, diff --git a/tests/utils.py b/tests/utils.py index 7eaae4534..72cbe425b 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -35,9 +35,11 @@ def ignored_warning(warning): @contextmanager def _tmp_file(content, extension): - with tempfile.NamedTemporaryFile(suffix='.' + extension, mode='w') as tmp_file: + with tempfile.NamedTemporaryFile(suffix='.' + extension, mode='w', delete=False) as tmp_file: tmp_file.write(content) tmp_file.seek(0) + tmp_file.close() + yield tmp_file