Skip to content

Commit

Permalink
Add if python is present in system (#218)
Browse files Browse the repository at this point in the history
* Use python2 to build a python2 extension.

Reasoning: some environments use python3 by default

* Add checks for various environments

Env1: Python2 isn't installed
Env2: Python3 isn't installed
Env3: no python is installed
  • Loading branch information
eirnym authored and Yggdroot committed Sep 13, 2018
1 parent 1ba0021 commit 0223b66
Showing 1 changed file with 36 additions and 21 deletions.
57 changes: 36 additions & 21 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 0223b66

Please sign in to comment.