Skip to content

Commit

Permalink
adding docker ignore, fix docker, move to pybind
Browse files Browse the repository at this point in the history
  • Loading branch information
timkpaine committed May 26, 2019
1 parent dae5f70 commit df62b10
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 33 deletions.
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.ipynb_checkpoints
notebooks
Dockerfile
.DS_Store
keys
*.csv
*.sh
logs
19 changes: 7 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,14 @@ set(CMAKE_CXX_FLAGS " \
")


find_package(Boost)
if(NOT Boost_FOUND)
message("${Red}Boost could not be located${ColorReset}")
find_package(pybind11)
if(NOT pybind11_FOUND)
message("${Red}PyBind11 could not be located${ColorReset}")
build_dep("pybind11", "cmake/Pybind.txt.in")
else()
message("${Cyan}Found boost in ${Boost_INCLUDE_DIRS} ${Boost_LIBRARY_DIRS} ${ColorReset}")
message("${Cyan}Found PyBind11 in ${pybind11_INCLUDE_DIRS}${ColorReset}")
endif()
include_directories( ${Boost_INCLUDE_DIRS} )
include_directories( ${pybind11_INCLUDE_DIRS} )

if(WIN32)
foreach(warning 4244 4251 4267 4275 4290 4786 4305 4996)
Expand All @@ -137,16 +138,10 @@ endif()
# PYTHON BINDINGS BUILD #
#########################
include_directories("/usr/local/include/python3.7m") # FIXME
link_directories("/usr/local/lib") # FIXME
find_package( PythonInterp 3.7 REQUIRED )
find_package( PythonLibs 3.7 REQUIRED )
include_directories( ${PYTHON_INCLUDE_DIRS} )
find_package(NumPy)

find_package( Boost COMPONENTS python REQUIRED )
find_library( BOOST_PYTHON boost_python)
find_library( BOOST_NUMPY boost_numpy)
include_directories( ${Boost_INCLUDE_DIR} )

include_directories( ${PYTHON_NUMPY_INCLUDE_DIR})
#####################

Expand Down
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
FROM timkpaine/aat:latest
FROM timkpaine/aat-deps:latest

WORKDIR /usr/src/app
ADD . /usr/src/app

RUN python3 -m pip install -U codecov coverage pytest pytest-cov mock flake8 pylint
RUN python3 -m pip install -r requirements.txt

RUN make build
RUN make test
RUN codecov --token caa422e7-7543-4adb-8ee1-e4a7ea24b988
4 changes: 4 additions & 0 deletions aat/trading.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
from .ui.server import ServerApplication
from .utils import ex_type_to_ex
from .logging import LOG as log, SLIP as sllog, TXNS as tlog
from .test import say_hello
from .exchanges._cpp_helpers import test
test()
say_hello("test")


class TradingEngine(object):
Expand Down
16 changes: 16 additions & 0 deletions cmake/Pybind.txt.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
cmake_minimum_required(VERSION 2.8.2)

project(pybind11-download NONE)

include(ExternalProject)
ExternalProject_Add(pybind11
GIT_REPOSITORY https://github.com/pybind/pybind11.git
GIT_TAG master
SOURCE_DIR "${CMAKE_BINARY_DIR}/pybind11-src"
BINARY_DIR "${CMAKE_BINARY_DIR}/pybind11-build"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
CMAKE_ARGS "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}"
)
9 changes: 5 additions & 4 deletions cpp/include/aat/exchanges/_cpp_helpers.hpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#include <iostream>
#include <boost/python/module.hpp>
#include <boost/python/def.hpp>
#include <pybind11/pybind11.h>
namespace py = pybind11;

#ifndef __AAT_CPP_HELPERS_HPP__
#define __AAT_CPP_HELPERS_HPP__
void test();

BOOST_PYTHON_MODULE(_cpp_helpers)
PYBIND11_MODULE(_cpp_helpers, m)
{
boost::python::def("test", test);
m.doc() = "A Test";
m.def("test", &test, "A test function");
}
#endif
9 changes: 5 additions & 4 deletions cpp/include/aat/test.hpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#include <iostream>
#include <boost/python/module.hpp>
#include <boost/python/def.hpp>
#include <pybind11/pybind11.h>
namespace py = pybind11;

#ifndef __AAT_TEST_HPP__
#define __AAT_TEST_HPP__
void say_hello(const char* name);


BOOST_PYTHON_MODULE(test)
PYBIND11_MODULE(test, m)
{
boost::python::def("say_hello", say_hello);
m.doc() = "A Test";
m.def("say_hello", &say_hello, "A test function");
}
#endif
17 changes: 6 additions & 11 deletions scripts/Dockerfile.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,14 @@ FROM python:3.7

RUN apt-get update
RUN apt-get -y install apt-transport-https libtbb-dev cmake

RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
RUN apt-get install -y nodejs
RUN npm install -g yarn
RUN apt-get -y remove python3

RUN python3.7 -m pip install numpy

RUN ls -al /usr/local/lib/python3.7/site-packages/numpy

RUN wget https://dl.bintray.com/boostorg/release/1.67.0/source/boost_1_67_0.tar.gz >/dev/null 2>&1 || echo "wget failed"
RUN tar xfz boost_1_67_0.tar.gz
RUN cd boost_1_67_0 && CPLUS_INCLUDE_PATH="$CPLUS_INCLUDE_PATH:/usr/local/include/python3.7m" C_INCLUDE_PATH="$C_INCLUDE_PATH:/usr/local/include/python3.7m" ./bootstrap.sh --with-python=/usr/local/bin/python3.7 || echo "boostrap failed"
RUN cd boost_1_67_0 && CPLUS_INCLUDE_PATH="$CPLUS_INCLUDE_PATH:/usr/local/include/python3.7m" C_INCLUDE_PATH="$C_INCLUDE_PATH:/usr/local/include/python3.7m" ./b2 -j4 install || echo "build boost failed"
RUN apt-get -y remove python3
RUN python3.7 -m pip install numpy pytest

RUN ln -s /usr/local/lib/libboost_python37.so /usr/local/lib/libboost_python.so
RUN ln -s /usr/local/lib/libboost_numpy37.so /usr/local/lib/libboost_numpy.so
RUN wget https://github.com/pybind/pybind11/archive/v2.2.4.tar.gz >/dev/null 2>&1 || echo "wget failed"
RUN tar xfz v2.2.4.tar.gz
RUN cd pybind11-2.2.4/ && mkdir build && cd build && cmake .. && make -j 4 && make install

0 comments on commit df62b10

Please sign in to comment.