Skip to content

Commit

Permalink
Merge pull request #95 from gift-surg/81-run-with-python37-on-windows…
Browse files Browse the repository at this point in the history
…-for-91

Run with Python 3.7 on Windows for #91
  • Loading branch information
dzhoshkun authored Apr 16, 2019
2 parents 9cb4cb8 + d741f09 commit bd6ec39
Show file tree
Hide file tree
Showing 14 changed files with 91 additions and 20 deletions.
8 changes: 7 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -554,14 +554,20 @@ windows:
variables:
EpiphanSDK_DIR: C:/Program Files/Epiphan/epiphan_sdk-3.30.3.0007
zlib_root: C:/Program Files/zlib/zlib-1.2.3-lib
boost_includedir: C:/Boost/boost_1_69_0
boost_librarydir: C:/Boost/boost_1_69_0/stage/lib
python_include_dirs: C:/Python/Python3.7.1/include
python_library: C:/Python/Python3.7.1/libs/python37.lib
before_script:
- echo "This is the Windows script's before_script to be able to skip global before_script, which is Linux-specific"
script:
- mkdir build
- cd build
- cmake -D CMAKE_BUILD_TYPE=Release -D ZLIB_ROOT="%zlib_root%" -D USE_EPIPHAN_DVI2PCIE_DUO=ON -D ENABLE_NONFREE=ON -D USE_EPIPHANSDK=ON -D USE_BGRA=OFF ../src
- cmake -A x64 -D CMAKE_BUILD_TYPE=Release -D PYTHON_INCLUDE_DIRS="%python_include_dirs%" -D PYTHON_LIBRARY="%python_library%" -D BOOST_INCLUDEDIR="%boost_includedir%" -D BOOST_LIBRARYDIR="%boost_librarydir%" -D ZLIB_ROOT="%zlib_root%" -D BUILD_PYTHON=ON -D USE_NUMPY=ON -D USE_EPIPHAN_DVI2PCIE_DUO=ON -D ENABLE_NONFREE=ON -D USE_EPIPHANSDK=ON -D USE_BGRA=OFF ../src
- cmake --build . --config Release
- ls
- cd Release
- python -c "from pygiftgrab import VideoSourceFactory"
tags:
- gift-hopper
- windows
18 changes: 17 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ endif(USE_NUMPY AND NOT BUILD_PYTHON)
# Library name
SET(NAME giftgrab)

# For generating import lib in Windows
if(WIN32)
INCLUDE_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}")
endif()

# Library include dirs
INCLUDE_DIRECTORIES(api)
INCLUDE_DIRECTORIES(utils)
Expand All @@ -187,6 +192,7 @@ SET(HEADERS
api/videosourcefactory.h
api/videotargetfactory.h
api/except.h
api/exports.h
)
SET(SOURCES
api/iobservable.cpp
Expand Down Expand Up @@ -338,13 +344,23 @@ endif(BUILD_TESTS)
# Python wrappers
if(BUILD_PYTHON)
SET(NAME_PYTHON py${NAME})
ADD_LIBRARY(${NAME_PYTHON} SHARED python/gil.h python/wrapper.cpp)
PYTHON_ADD_MODULE(${NAME_PYTHON} python/gil.h python/wrapper.cpp)
TARGET_LINK_LIBRARIES(${NAME_PYTHON} ${Boost_LIBRARIES} ${NAME})
# no lib prefix
SET_TARGET_PROPERTIES(${NAME_PYTHON} PROPERTIES PREFIX "")
LIST(APPEND INSTALLABLES ${NAME_PYTHON})
endif(BUILD_PYTHON)

# For generating import lib in Windows
if(WIN32)
INCLUDE(GenerateExportHeader)

GENERATE_EXPORT_HEADER(${NAME}
EXPORT_MACRO_NAME GG_EXPORTS
EXPORT_FILE_NAME gg_exports_win.h
STATIC_DEFINE GG_EXPORTS_BUILT_AS_STATIC
)
endif()

# Install
INSTALL(
Expand Down
17 changes: 9 additions & 8 deletions src/api/except.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include "exports.h"
#include <stdexcept>
#include <string>

Expand All @@ -13,7 +14,7 @@ namespace gg {
//! \attention <b>In Python:</b> This exception
//! maps to \c RuntimeError
//!
class BasicException : public std::exception {
class GG_EXPORTS BasicException : public std::exception {
protected:
//!
//! \brief Exception details
Expand Down Expand Up @@ -47,7 +48,7 @@ class BasicException : public std::exception {
//! \attention <b>In Python:</b> This exception
//! maps to \c IOError
//!
class DeviceAlreadyConnected : public BasicException
class GG_EXPORTS DeviceAlreadyConnected : public BasicException
{
public:
//!
Expand All @@ -71,7 +72,7 @@ class DeviceAlreadyConnected : public BasicException
//! \attention <b>In Python:</b> This exception
//! maps to \c IOError
//!
class DeviceNotFound : public BasicException {
class GG_EXPORTS DeviceNotFound : public BasicException {
public:
//!
//! \brief
Expand All @@ -94,7 +95,7 @@ class DeviceNotFound : public BasicException {
//! \attention <b>In Python:</b> This exception
//! maps to \c IOError
//!
class DeviceOffline : public BasicException {
class GG_EXPORTS DeviceOffline : public BasicException {
public:
//!
//! \brief
Expand All @@ -117,7 +118,7 @@ class DeviceOffline : public BasicException {
//! \attention <b>In Python:</b> This exception
//! maps to \c RuntimeError
//!
class VideoTargetError : public BasicException
class GG_EXPORTS VideoTargetError : public BasicException
{
public:
//!
Expand All @@ -141,7 +142,7 @@ class VideoTargetError : public BasicException
//! \attention <b>In Python:</b> This exception
//! maps to \c RuntimeError
//!
class VideoSourceError : public BasicException
class GG_EXPORTS VideoSourceError : public BasicException
{
public:
//!
Expand All @@ -164,7 +165,7 @@ class VideoSourceError : public BasicException
//! \attention <b>In Python:</b> This exception
//! maps to \c RuntimeError
//!
class ObserverError : public BasicException
class GG_EXPORTS ObserverError : public BasicException
{
public:
//!
Expand All @@ -187,7 +188,7 @@ class ObserverError : public BasicException
//! \attention <b>In Python:</b> This exception
//! maps to \c IOError
//!
class NetworkSourceUnavailable : public BasicException
class GG_EXPORTS NetworkSourceUnavailable : public BasicException
{
public:
//!
Expand Down
7 changes: 7 additions & 0 deletions src/api/exports.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once

#ifdef WIN32
#include "gg_exports_win.h"
#else
#define GG_EXPORTS
#endif
3 changes: 2 additions & 1 deletion src/api/iobservable.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include "exports.h"
#include "iobserver.h"
#include <vector>
#include <mutex>
Expand Down Expand Up @@ -39,7 +40,7 @@ namespace gg
//! ensuring data is promptly copied to their own
//! data buffer.
//!
class IObservable
class GG_EXPORTS IObservable
{
protected:
//!
Expand Down
3 changes: 2 additions & 1 deletion src/api/iobserver.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include "exports.h"
#include "videoframe.h"

namespace gg
Expand Down Expand Up @@ -32,7 +33,7 @@ namespace gg
//! pass
//! \endcode
//!
class IObserver
class GG_EXPORTS IObserver
{
public:
//!
Expand Down
3 changes: 2 additions & 1 deletion src/api/ivideosource.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include "exports.h"
#include "videoframe.h"
#include "except.h"
#include "iobservable.h"
Expand All @@ -12,7 +13,7 @@
//! This enables the underlying algorithms to be agnostic of
//! the data sources.
//!
class IVideoSource : public gg::IObservable
class GG_EXPORTS IVideoSource : public gg::IObservable
{
public:
//!
Expand Down
3 changes: 2 additions & 1 deletion src/api/ivideotarget.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include "exports.h"
#include "videoframe.h"
#include "except.h"
#include "iobserver.h"
Expand All @@ -14,7 +15,7 @@ namespace gg
//! functionality to save streamed video e.g.
//! to files
//!
class IVideoTarget : public IObserver
class GG_EXPORTS IVideoTarget : public IObserver
{
protected:
//!
Expand Down
3 changes: 2 additions & 1 deletion src/api/videoframe.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace cv
#endif
#endif // USE_OPENCV

#include "exports.h"
#include <memory>
#include "maskframe.h"
#include "except.h"
Expand Down Expand Up @@ -44,7 +45,7 @@ enum ColourSpace
//! within a single frame object, so as to preserve temporal
//! relations and to facilitate potential stereo encoding.
//!
class VideoFrame
class GG_EXPORTS VideoFrame
{
protected:
//!
Expand Down
3 changes: 2 additions & 1 deletion src/api/videosourcefactory.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include "exports.h"
#include "ivideosource.h"
#include "device.h"
#include "codec.h"
Expand All @@ -22,7 +23,7 @@ namespace gg
//! \sa IVideoSource
//! \sa Device
//!
class VideoSourceFactory
class GG_EXPORTS VideoSourceFactory
{
protected:
//!
Expand Down
3 changes: 2 additions & 1 deletion src/api/videotargetfactory.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include "exports.h"
#include "macros.h"
#include "codec.h"
#include "ivideotarget.h"
Expand All @@ -19,7 +20,7 @@ namespace gg
//!
//! \sa IVideoTarget
//!
class VideoTargetFactory
class GG_EXPORTS VideoTargetFactory
{
protected:
//!
Expand Down
34 changes: 32 additions & 2 deletions src/cmake/boost.python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,38 @@
CMAKE_MINIMUM_REQUIRED(VERSION 3.2.0)

SET(GG_BOOST_COMPONENTS python)
if(NOT PYTHONLIBS_VERSION_STRING)
# Needed in case PythonLibs discovery script not run, see
# https://github.com/gift-surg/GIFT-Grab/issues/83
# TODO handle this more elegantly
ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/../../cmake/pythonlibs ${CMAKE_CURRENT_BINARY_DIR}/cmake/pythonlibs-redundant-run)
if(NOT PYTHONLIBS_VERSION_STRING)
MESSAGE(FATAL_ERROR "Could not determine Python version")
endif()
endif()
if(PYTHONLIBS_VERSION_STRING MATCHES ^3\.*)
if(UNIX)
SET(GG_BOOST_PYTHON_SUFFIX 3)
elseif(WIN32)
if(PYTHONLIBS_VERSION_STRING MATCHES ^3\.7\.*)
SET(GG_BOOST_PYTHON_SUFFIX 37)
else()
MESSAGE(FATAL_ERROR
"Found Python version ${PYTHONLIBS_VERSION_STRING} (on Windows only 3.7 is experimentally supported)")
endif()
endif()
elseif(PYTHONLIBS_VERSION_STRING MATCHES ^2\.7\.*)
if(UNIX)
SET(GG_BOOST_PYTHON_SUFFIX "")
elseif(WIN32)
SET(GG_BOOST_PYTHON_SUFFIX 27)
endif()
else()
MESSAGE(FATAL_ERROR "Found unsupported Python version ${PYTHONLIBS_VERSION_STRING}")
endif()

SET(GG_BOOST_COMPONENTS python${GG_BOOST_PYTHON_SUFFIX})
if(USE_NUMPY)
LIST(APPEND GG_BOOST_COMPONENTS numpy)
LIST(APPEND GG_BOOST_COMPONENTS numpy${GG_BOOST_PYTHON_SUFFIX})
endif(USE_NUMPY)
FIND_PACKAGE(Boost COMPONENTS ${GG_BOOST_COMPONENTS} REQUIRED)
SET(Boost_INCLUDE_DIR ${Boost_INCLUDE_DIR}
Expand Down
3 changes: 3 additions & 0 deletions src/cmake/pythonlibs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ SET(PYTHON_INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS}
SET(PYTHON_LIBRARIES ${PYTHON_LIBRARIES}
CACHE INTERNAL "PythonLibs libraries"
)
SET(PYTHONLIBS_VERSION_STRING ${PYTHONLIBS_VERSION_STRING}
CACHE INTERNAL "PythonLibs version string"
)
3 changes: 2 additions & 1 deletion src/epiphansdk/epiphansdk_video_source.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once
#include "exports.h"
#include "frmgrab.h"
#include "ivideosource.h"
#include "macros.h"
Expand All @@ -7,7 +8,7 @@
namespace gg
{

class VideoSourceEpiphanSDK : public IVideoSource
class GG_EXPORTS VideoSourceEpiphanSDK : public IVideoSource
{
protected:
//!
Expand Down

0 comments on commit bd6ec39

Please sign in to comment.