Skip to content

Commit

Permalink
Merge pull request #49 from reyoung/LazyInstallPaddleWheels
Browse files Browse the repository at this point in the history
Lazy install Paddle wheels
  • Loading branch information
emailweixu authored Sep 9, 2016
2 parents 1c5514f + 62da4ad commit 674d69c
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 11 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ before_install:
script:
- paddle/scripts/travis/build.sh
- paddle/scripts/travis/unittest.sh
- paddle/scripts/travis/make_install.sh
notifications:
email:
on_success: change
Expand Down
35 changes: 35 additions & 0 deletions paddle/scripts/submit_local.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,41 @@ fi

export PYTHONPATH=${PWD}:${PYTHONPATH}


# Check python lib installed or not.
pip --help > /dev/null
if [ $? -ne 0 ]; then
echo "pip should be installed to run paddle."
exit 1
fi

INSTALLED_VERSION=`pip freeze 2>/dev/null | grep '^paddle' | sed 's/.*==//g'`

if [ -z ${INSTALLED_VERSION} ]; then
INSTALLED_VERSION="0.0.0" # not installed
fi
cat <<EOF | python -
from distutils.version import LooseVersion
import sys
if LooseVersion("${INSTALLED_VERSION}") < LooseVersion("@PADDLE_VERSION@"):
sys.exit(1)
else:
sys.exit(0)
EOF

if [ $? -eq 1 ]; then # Older version installed, or not installed at all
echo "First time run paddle, need to install some python dependencies."
BASEDIR=$(dirname "$0")
pip install ${BASEDIR}/../opt/paddle/share/wheels/*.whl
if [ $? -ne 0 ]; then
echo "pip install wheels failed. "
echo "Please use 'sudo paddle' at the first time you use PaddlePaddle"
echo "PaddlePaddle will install some python dependencies automatically."
exit 1
fi
echo "Python dependencies are installed."
fi

case "$1" in
"train")
${DEBUGGER} $MYDIR/../opt/paddle/bin/paddle_trainer ${@:2}
Expand Down
6 changes: 1 addition & 5 deletions paddle/scripts/travis/build.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#!/bin/bash

cd `dirname $0`
cd ../../../
set -e
mkdir build
cd build
source ./common.sh
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWITH_GPU=OFF -DWITH_DOC=OFF -DWITH_TESTING=ON -DON_TRAVIS=ON
make -j `nproc`
5 changes: 5 additions & 0 deletions paddle/scripts/travis/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
set -e
mkdir -p ../../../build
cd ../../../build

5 changes: 5 additions & 0 deletions paddle/scripts/travis/make_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
cd `dirname $0`
source ./common.sh
sudo make install
sudo paddle version
3 changes: 1 addition & 2 deletions paddle/scripts/travis/unittest.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/bin/bash
set -e
cd `dirname $0`
cd ../../../build
source ./common.sh
env CTEST_OUTPUT_ON_FAILURE=1 make test ARGS="-j `nproc`"

4 changes: 0 additions & 4 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ find_python_module(pip REQUIRED)
find_python_module(wheel REQUIRED)
find_python_module(google.protobuf REQUIRED)

install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} setup.py install -f
WORKING_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR})")

install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/dist/
DESTINATION opt/paddle/share/wheels
)

0 comments on commit 674d69c

Please sign in to comment.