Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python build fix #363

Merged
merged 2 commits into from
Jan 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ install:
script:
- if [ "$TEST" = "WASM" ]; then yarn lint; fi
- if [ "$TEST" = "WASM" ]; then PSP_DOCKER=1 yarn build; fi
- if [ "$TEST" = "WASM" ]; then yarn test --docker --quiet; fi
- if [ "$TEST" = "CPP" ]; then docker build -f docker/cpp/Dockerfile .; fi
- if [ "$TEST" = "PYTHON" ]; then docker build -f docker/python/Dockerfile .; fi
- if [ "$TEST" = "WASM" ]; then PSP_DOCKER=1 yarn test --quiet; fi
- if [ "$TEST" = "CPP" ]; then PSP_DOCKER=1 yarn build_cpp; fi
- if [ "$TEST" = "CPP" ]; then PSP_DOCKER=1 yarn test_cpp; fi
- if [ "$TEST" = "PYTHON" ]; then PSP_DOCKER=1 yarn build_python; fi
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ else()
endif()

if (PSP_CPP_BUILD_TESTS)
message(WARNING "${Cyan}Building CPP tests${ColorReset}")
message(WARNING "${Cyan}Building C++ tests${ColorReset}")
else()
message(WARNING "${Cyan}Skipping CPP tests${ColorReset}")
message(WARNING "${Cyan}Skipping C++ tests${ColorReset}")
endif()

if (NOT PSP_CPP_BUILD_STRICT)
message(WARNING "${Cyan}Building CPP without strict warnings${ColorReset}")
message(WARNING "${Cyan}Building C++ without strict warnings${ColorReset}")
endif()

#######################
Expand Down
5 changes: 1 addition & 4 deletions docker/cpp/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,4 @@ WORKDIR /usr/src/app
ADD . /usr/src/app

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

RUN yarn
RUN yarn build_cpp
RUN apt-get -y install apt-transport-https libtbb-dev cmake libboost-all-dev
4 changes: 1 addition & 3 deletions docker/python/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,4 @@ 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 python3 -m pip install codecov nose2 mock flake8
RUN python3 -m pip install -r python/requirements.txt

RUN DOCKER=true cd python && make build && make test
RUN python3 -m pip install 'numpy>=1.13.1' 'pandas>=0.22.0'
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@
"build,test,bench": "npm run --silent build && npm run --silent test && npm run --silent bench",
"build,bench": "npm run --silent build && npm run --silent bench",
"build": "node scripts/build.js",
"build_cpp": "lerna run build:cpp ${PACKAGE:+--scope=@jpmorganchase/perspective} --stream",
"build_python": "cd python && python3 setup.py build",
"build_cpp": "node scripts/build_cpp.js",
"build_python": "node scripts/build_python.js",
"install_python": "cd python && python3 setup.py install",
"bench": "node scripts/bench.js",
"docs": "lerna run docs --silent --stream",
"test": "node scripts/test.js",
"test_cpp": "lerna run test:cpp ${PACKAGE:+--scope=@jpmorganchase/perspective} --stream",
"test_cpp": "node scripts/test_cpp.js",
"clean": "find obj -mindepth 1 -delete && lerna run clean ${PACKAGE:+--scope=@jpmorganchase/${PACKAGE}} --stream",
"preclean:screenshots": "lerna exec -- mkdir -p screenshots",
"clean:screenshots": "lerna run clean:screenshots ${PACKAGE:+--scope=@jpmorganchase/${PACKAGE}}",
Expand Down
3 changes: 0 additions & 3 deletions packages/perspective/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,12 @@
"scripts": {
"bench": "node ../../scripts/bench.js",
"prebuild": "mkdir -p build && mkdir -p obj",
"compile:cpp": "mkdir -p ../../cppbuild && cd ../../cppbuild && cmake ../ -DPSP_WASM_BUILD=0 -DPSP_CPP_BUILD=1 -DPSP_CPP_BUILD_TESTS=1 && make -j${PSP_CPU_COUNT-8}",
"cpp": "npm-run-all build:cpp test:cpp",
"build": "npm-run-all build:webpack",
"build:cpp": "npm-run-all compile:cpp",
"build:webpack": "npm-run-all -p build:webpack:*",
"build:webpack:umd": "webpack --color --config src/config/perspective.config.js",
"build:webpack:node": "webpack --color --config src/config/perspective.node.config.js",
"docs": "documentation build src/js/perspective.js -f md --shallow > README.md && cp README.md ../../docs/perspective.md",
"test:cpp": "npm-run-all build:cpp && ../../cppbuild/test/psp_test",
"test:build": "cp test/html/* build",
"test:run": "jest --color --ci",
"test": "npm-run-all test:build test:run",
Expand Down
10 changes: 5 additions & 5 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function compileRuntime({inputFile, inputWasmFile, format, packageName}) {

if (inputWasmFile) {
console.log("-- Copying WASM file %s", inputWasmFile);
fs.copyFileSync(path.join(BUILD_DIRECTORY, inputWasmFile), path.join(path.join(OUTPUT_DIRECTORY, "build"), inputWasmFile));
fs.copyFileSync(path.join(BUILD_DIRECTORY, inputWasmFile), path.join(OUTPUT_DIRECTORY, "build", inputWasmFile));
}

console.debug("-- Creating wrapped js runtime");
Expand All @@ -101,23 +101,23 @@ function compileRuntime({inputFile, inputWasmFile, format, packageName}) {
});
}

fs.writeFileSync(path.join(path.join(OUTPUT_DIRECTORY, "obj"), inputFile), source);
fs.writeFileSync(path.join(OUTPUT_DIRECTORY, "obj", inputFile), source);
}

function emsdk() {
function docker(image = "emsdk") {
console.log("-- Creating emsdk docker image");
let cmd = "docker run --rm -it";
if (process.env.PSP_CPU_COUNT) {
cmd += ` --cpus="${parseInt(process.env.PSP_CPU_COUNT)}.0"`;
}
cmd += " -v $(pwd):/src -e PACKAGE=${PACKAGE} perspective/emsdk";
cmd += ` -v $(pwd):/src -e PACKAGE=${process.env.PACKAGE} perspective/${image}`;
return cmd;
}

function compileCPP() {
let cmd = `emcmake cmake ../ && emmake make -j${process.env.PSP_CPU_COUNT || os.cpus().length}`;
if (process.env.PSP_DOCKER) {
cmd = `${emsdk()} bash -c 'cd obj && ${cmd}'`;
cmd = `${docker()} bash -c 'cd obj && ${cmd}'`;
} else {
cmd = `cd ${BASE_DIRECTORY} && ${cmd}`;
}
Expand Down
35 changes: 35 additions & 0 deletions scripts/build_cpp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/******************************************************************************
*
* Copyright (c) 2017, the Perspective Authors.
*
* This file is part of the Perspective library, distributed under the terms of
* the Apache License 2.0. The full license can be found in the LICENSE file.
*
*/

const execSync = require("child_process").execSync;

const execute = cmd => execSync(cmd, {stdio: "inherit"});

function docker(image = "emsdk") {
console.log(`-- Creating ${image} docker image`);
let cmd = "docker run --rm -it";
if (process.env.PSP_CPU_COUNT) {
cmd += ` --cpus="${parseInt(process.env.PSP_CPU_COUNT)}.0"`;
}
cmd += ` -v $(pwd):/usr/src/app/cpp -w /usr/src/app/cpp/cppbuild perspective/${image}`;
return cmd;
}

try {
execute("mkdir -p cppbuild");
if (process.env.PSP_DOCKER) {
execute(docker("cpp") + " cmake ../ -DPSP_WASM_BUILD=0 -DPSP_CPP_BUILD=1 -DPSP_CPP_BUILD_TESTS=1");
execute(docker("cpp") + " make -j${PSP_CPU_COUNT-8}");
} else {
execute("cmake ../ -DPSP_WASM_BUILD=0 -DPSP_CPP_BUILD=1 -DPSP_CPP_BUILD_TESTS=1");
execute("make -j${PSP_CPU_COUNT-8}");
}
} catch (e) {
process.exit(1);
}
33 changes: 33 additions & 0 deletions scripts/build_python.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/******************************************************************************
*
* Copyright (c) 2017, the Perspective Authors.
*
* This file is part of the Perspective library, distributed under the terms of
* the Apache License 2.0. The full license can be found in the LICENSE file.
*
*/

const execSync = require("child_process").execSync;

const execute = cmd => execSync(cmd, {stdio: "inherit"});

function docker(image = "emsdk") {
console.log(`-- Creating ${image} docker image`);
let cmd = "docker run --rm -it";
if (process.env.PSP_CPU_COUNT) {
cmd += ` --cpus="${parseInt(process.env.PSP_CPU_COUNT)}.0"`;
}
cmd += ` -v $(pwd):/usr/src/app/python -w /usr/src/app/python perspective/${image}`;
return cmd;
}

try {
let cmd = "python3 setup.py build";
if (process.env.PSP_DOCKER) {
execute(docker("python") + " " + cmd);
} else {
execute(cmd);
}
} catch (e) {
process.exit(1);
}
33 changes: 33 additions & 0 deletions scripts/test_cpp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/******************************************************************************
*
* Copyright (c) 2017, the Perspective Authors.
*
* This file is part of the Perspective library, distributed under the terms of
* the Apache License 2.0. The full license can be found in the LICENSE file.
*
*/

const execSync = require("child_process").execSync;

const execute = cmd => execSync(cmd, {stdio: "inherit"});

function docker(image = "emsdk") {
console.log(`-- Creating ${image} docker image`);
let cmd = "docker run --rm -it";
if (process.env.PSP_CPU_COUNT) {
cmd += ` --cpus="${parseInt(process.env.PSP_CPU_COUNT)}.0"`;
}
cmd += ` -v $(pwd):/usr/src/app/cpp -w /usr/src/app/cpp/cppbuild perspective/${image}`;
return cmd;
}

try {
execute("mkdir -p cppbuild");
if (process.env.PSP_DOCKER) {
execute(docker("cpp") + " ./test/psp_test");
} else {
execute("./test/psp_test");
}
} catch (e) {
process.exit(1);
}