diff --git a/install.sh b/install.sh index bf34d7cf..77074b05 100755 --- a/install.sh +++ b/install.sh @@ -9,28 +9,43 @@ then exit 0 fi +no_python=true + cd autoload/leaderf/fuzzyMatch_C -echo "Begin to compile C extension of Python2 ..." -python setup.py build -if [ $? -eq 0 ] -then - cp build/lib*2.?/fuzzyMatchC*.so ../python - if [ $? -eq 0 ] - then - echo - echo C extension of Python2 installed sucessfully! - fi + +if command -v python2 > /dev/null 2>&1; then + no_python=false + echo "Begin to compile C extension of Python2 ..." + python2 setup.py build + if [ $? -eq 0 ] + then + cp build/lib*2.?/fuzzyMatchC*.so ../python + if [ $? -eq 0 ] + then + echo + echo C extension of Python2 installed sucessfully! + fi + fi fi -echo -echo "Begin to compile C extension of Python3 ..." -python3 setup.py build -if [ $? -eq 0 ] -then - cp build/lib*3.?/fuzzyMatchC*.so ../python - if [ $? -eq 0 ] - then - echo - echo C extension of Python3 installed sucessfully! - fi +if command -v python3 > /dev/null 2>&1; then + $no_python || echo + no_python=false + + echo "Begin to compile C extension of Python3 ..." + python3 setup.py build + if [ $? -eq 0 ] + then + cp build/lib*3.?/fuzzyMatchC*.so ../python + if [ $? -eq 0 ] + then + echo + echo C extension of Python3 installed sucessfully! + fi + fi +fi + +if $no_python; then + echo "Can't compile C extension, please install Python2 or Python3" >&2 + exit 1 fi