This repository was archived by the owner on Jan 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Bob Stouffer
committed
Dec 6, 2018
1 parent
3384137
commit 44b47e3
Showing
3 changed files
with
61 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1 @@ | ||
if [[ -z "`which pip3 2> /dev/null`" ]]; then | ||
echo "pip3 must be installed" | ||
echo "Aborting..." | ||
return | ||
fi | ||
|
||
# Set up a virtualenv if it doesn't already exist | ||
if [[ ! -d $PWD/.venv ]]; then | ||
curl --silent --retry 3 --retry-delay 1 --head http://google.com > /dev/null | ||
if [[ "$?" -ne 0 ]]; then | ||
echo "No internet connection available" | ||
echo "Aborting..." | ||
return | ||
fi | ||
if [[ -z "`which virtualenv 2> /dev/null`" ]]; then | ||
while true; do | ||
read -p "You do not have virtualenv installed. Should I install it using pip? " yn | ||
case $yn in | ||
[Yy]* ) | ||
if [[ -z "`which sudo 2> /dev/null`" ]]; then | ||
pip3 install virtualenv; | ||
else | ||
sudo pip3 install virtualenv; | ||
fi | ||
if [[ -z "`which virtualenv 2> /dev/null`" ]]; then | ||
echo 'Failed to install virtualenv' | ||
return | ||
fi | ||
break;; | ||
[Nn]* ) echo "Please install virtualenv"; return;; | ||
* ) echo "Answer yes or no";; | ||
esac | ||
done | ||
fi | ||
|
||
virtualenv -p python3 --no-site-packages $PWD/.venv | ||
$PWD/.venv/bin/pip install -U pip | ||
$PWD/.venv/bin/pip install -r $PWD/requirements.txt | ||
|
||
if [[ ! -d $PWD/tests ]]; then | ||
$PWD/.venv/bin/python $PWD/robot.py add-tests 2> /dev/null | ||
fi | ||
|
||
ln -s $PWD/hooks/* $PWD/.git/hooks/ | ||
fi | ||
|
||
export PATH=$PWD/.venv/bin:$PATH | ||
|
||
# Upgrade any out-of-date pip packages | ||
# HACK: It would be better to include the logic for updating pip packages right | ||
# here, but direnv waits for all subshells and functions to finish before it | ||
# initializes the environment, which causes a noticeable hang when cd-ing into | ||
# the repository. Running a script in the background does not cause a delay. | ||
(bash $PWD/hooks/post-merge envrc &) | ||
source sandbox.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
if [[ -z "`which pip3 2> /dev/null`" ]]; then | ||
echo "pip3 must be installed" | ||
echo "Aborting..." | ||
return | ||
fi | ||
|
||
# Set up a virtualenv if it doesn't already exist | ||
if [[ ! -d $PWD/.venv ]]; then | ||
curl --silent --retry 3 --retry-delay 1 --head http://google.com > /dev/null | ||
if [[ "$?" -ne 0 ]]; then | ||
echo "No internet connection available" | ||
echo "Aborting..." | ||
return | ||
fi | ||
if [[ -z "`which virtualenv 2> /dev/null`" ]]; then | ||
while true; do | ||
read -p "You do not have virtualenv installed. Should I install it using pip? [Y/N]" yn | ||
case $yn in | ||
[Yy]* ) | ||
if [[ -z "`which sudo 2> /dev/null`" ]]; then | ||
pip3 install virtualenv; | ||
else | ||
sudo pip3 install virtualenv; | ||
fi | ||
if [[ -z "`which virtualenv 2> /dev/null`" ]]; then | ||
echo 'Failed to install virtualenv' | ||
return | ||
fi | ||
break;; | ||
[Nn]* ) echo "Please install virtualenv"; return;; | ||
* ) echo "Answer yes or no";; | ||
esac | ||
done | ||
fi | ||
|
||
virtualenv -p python3 --no-site-packages $PWD/.venv | ||
$PWD/.venv/bin/pip install -U pip | ||
$PWD/.venv/bin/pip install -r $PWD/requirements.txt | ||
|
||
if [[ ! -d $PWD/tests ]]; then | ||
$PWD/.venv/bin/python $PWD/robot.py add-tests 2> /dev/null | ||
fi | ||
|
||
ln -sf $PWD/hooks/* $PWD/.git/hooks/ | ||
fi | ||
|
||
export PATH=$PWD/.venv/bin:$PATH | ||
|
||
# Upgrade any out-of-date pip packages | ||
# HACK: It would be better to include the logic for updating pip packages right | ||
# here, but direnv waits for all subshells and functions to finish before it | ||
# initializes the environment, which causes a noticeable hang when cd-ing into | ||
# the repository. Running a script in the background does not cause a delay. | ||
(bash $PWD/hooks/post-merge envrc &) |