Skip to content

Commit

Permalink
better handling of installation when virtualenv not present
Browse files Browse the repository at this point in the history
  • Loading branch information
mkupferman committed Jun 8, 2020
1 parent 5f3686d commit 6431d4b
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
all: build

build:
bash build.sh

clean:
rm -rf ./*.egg-info ./__pycache__/ ./*/__pycache__/ ./venv/
37 changes: 34 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,40 @@ elif which python >/dev/null; then
fi
else
echo "Could not find python >= 3 in PATH"
exit 1
fi

# try to set up virtualenv
$pyexec -m virtualenv venv
[[ -f ./venv/bin/pip ]] \
&& ./venv/bin/pip install --editable . \
|| ./venv/Scripts/pip install --editable .

# venv not created
if [ ! -d ./venv ]; then
$pyexec -m pip install --user virtualenv
$pyexec -m virtualenv venv

if [ ! -d ./venv ]; then
echo "ERROR: Unable to create python virtualenv"
exit 1
fi
fi

if [ -f ./venv/bin/pip ]; then
pipexec=./venv/bin/pip
activateexec=./venv/bin/activate
elif [ -f ./venv/Scripts/pip ]; then
pipexec=./venv/Scripts/pip
activateexec=./venv/Scripts/activate
else
echo "ERROR: Unable to find python pip in virtualenv"
exit 1
fi

$pipexec install --editable .

echo
if [ -f $activateexec ]; then
echo "Installed. Activate environment with: source $activateexec"
else
echo "ERROR: Unable to find virtualenv activate script"
exit 1
fi

0 comments on commit 6431d4b

Please sign in to comment.