Skip to content

Commit 674d69c

Browse files
authored
Merge pull request #49 from reyoung/LazyInstallPaddleWheels
Lazy install Paddle wheels
2 parents 1c5514f + 62da4ad commit 674d69c

7 files changed

Lines changed: 48 additions & 11 deletions

File tree

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ before_install:
2929
script:
3030
- paddle/scripts/travis/build.sh
3131
- paddle/scripts/travis/unittest.sh
32+
- paddle/scripts/travis/make_install.sh
3233
notifications:
3334
email:
3435
on_success: change

paddle/scripts/submit_local.sh.in

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,41 @@ fi
4343

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

46+
47+
# Check python lib installed or not.
48+
pip --help > /dev/null
49+
if [ $? -ne 0 ]; then
50+
echo "pip should be installed to run paddle."
51+
exit 1
52+
fi
53+
54+
INSTALLED_VERSION=`pip freeze 2>/dev/null | grep '^paddle' | sed 's/.*==//g'`
55+
56+
if [ -z ${INSTALLED_VERSION} ]; then
57+
INSTALLED_VERSION="0.0.0" # not installed
58+
fi
59+
cat <<EOF | python -
60+
from distutils.version import LooseVersion
61+
import sys
62+
if LooseVersion("${INSTALLED_VERSION}") < LooseVersion("@PADDLE_VERSION@"):
63+
sys.exit(1)
64+
else:
65+
sys.exit(0)
66+
EOF
67+
68+
if [ $? -eq 1 ]; then # Older version installed, or not installed at all
69+
echo "First time run paddle, need to install some python dependencies."
70+
BASEDIR=$(dirname "$0")
71+
pip install ${BASEDIR}/../opt/paddle/share/wheels/*.whl
72+
if [ $? -ne 0 ]; then
73+
echo "pip install wheels failed. "
74+
echo "Please use 'sudo paddle' at the first time you use PaddlePaddle"
75+
echo "PaddlePaddle will install some python dependencies automatically."
76+
exit 1
77+
fi
78+
echo "Python dependencies are installed."
79+
fi
80+
4681
case "$1" in
4782
"train")
4883
${DEBUGGER} $MYDIR/../opt/paddle/bin/paddle_trainer ${@:2}

paddle/scripts/travis/build.sh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
#!/bin/bash
2-
32
cd `dirname $0`
4-
cd ../../../
5-
set -e
6-
mkdir build
7-
cd build
3+
source ./common.sh
84
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWITH_GPU=OFF -DWITH_DOC=OFF -DWITH_TESTING=ON -DON_TRAVIS=ON
95
make -j `nproc`

paddle/scripts/travis/common.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
set -e
3+
mkdir -p ../../../build
4+
cd ../../../build
5+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
cd `dirname $0`
3+
source ./common.sh
4+
sudo make install
5+
sudo paddle version

paddle/scripts/travis/unittest.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/bin/bash
2-
set -e
32
cd `dirname $0`
4-
cd ../../../build
3+
source ./common.sh
54
env CTEST_OUTPUT_ON_FAILURE=1 make test ARGS="-j `nproc`"
65

python/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ find_python_module(pip REQUIRED)
2222
find_python_module(wheel REQUIRED)
2323
find_python_module(google.protobuf REQUIRED)
2424

25-
install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} setup.py install -f
26-
WORKING_DIRECTORY
27-
${CMAKE_CURRENT_BINARY_DIR})")
28-
2925
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/dist/
3026
DESTINATION opt/paddle/share/wheels
3127
)

0 commit comments

Comments
 (0)