Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated setup for newhome #28

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 27 additions & 23 deletions setup.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#!/bin/bash

VPOETRY_HOME=""
VPYENV_ROOT=""
USER_NAME=$(echo $USER)
VPOETRY_HOME="/nfs-share/$USER_NAME/.poetry"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not reasonable as a default given the public nature of the template.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add back the user-imputed version.

VPYENV_ROOT="/nfs-share/$USER_NAME/.pyenv"
VPYTHON_VERSION="3.11.6"


if ! [ -x "$(command -v pyenv)" ]; then
if [ -z "$VPYENV_ROOT" ]; then
echo "PYENV_ROOT is empty, please add it to the script or input a home now."
Expand All @@ -13,15 +12,17 @@ if ! [ -x "$(command -v pyenv)" ]; then
echo "PYENV_ROOT is not empty"
fi


curl https://pyenv.run | bash
eval "$(PYENV_ROOT=$VPYENV_ROOT pyenv init -)"
echo "export PYENV_ROOT=\"$VPYENV_ROOT\"" >> ~/.bashrc
echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
echo "export PYENV_ROOT=\"$VPYENV_ROOT\"" >> ~/.profile
echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.profile
echo 'eval "$(pyenv init -)"' >> ~/.profile
PYENV_ROOT=$VPYENV_ROOT
PYENV_BIN=$PYENV_ROOT/bin/pyenv

eval "$($PYENV_BIN init -)"
echo "export PYENV_ROOT=\"$VPYENV_ROOT\"" >> /home/$USER_NAME/.bashrc
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reasonable change, if anyone ever complains, we can change it back to $HOME.

echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> /home/$USER_NAME/.bashrc
echo 'eval "$(pyenv init -)"' >> /home/$USER_NAME/.bashrc
echo "export PYENV_ROOT=\"$VPYENV_ROOT\"" >> /home/$USER_NAME/.profile
echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> /home/$USER_NAME/.profile
echo 'eval "$(pyenv init -)"' >> /home/$USER_NAME/.profile
else
echo "Pyenv is already installed"
fi
Expand All @@ -37,33 +38,36 @@ if [ -z "$(command -v poetry)" ]; then

mkdir -p $VPOETRY_HOME
curl -sSL https://install.python-poetry.org | POETRY_HOME=$VPOETRY_HOME python3 -

POETRY_BIN="$VPOETRY_HOME/bin/poetry"

echo 'command -v poetry >/dev/null || export PATH="'$VPOETRY_HOME'/bin:$PATH"' >> /home/$USER_NAME/.bashrc
echo 'command -v poetry >/dev/null || export PATH="'$VPOETRY_HOME'/bin:$PATH"' >> /home/$USER_NAME/.profile

else
echo "Poetry is already installed"
fi



if pyenv versions | grep -q $VPYTHON_VERSION; then
if $PYENV_BIN versions | grep -q $VPYTHON_VERSION; then
echo "Python $VPYTHON_VERSION is already installed"
else
pyenv install $VPYTHON_VERSION
$PYENV_BIN install $VPYTHON_VERSION
fi


current_version=$(pyenv local)
current_version=$($PYENV_BIN local)

if [ "$current_version" = "$VPYTHON_VERSION" ]; then
echo "The local Python version is already set to $VPYTHON_VERSION"
else
pyenv local $VPYTHON_VERSION
$PYENV_BIN local $VPYTHON_VERSION
fi
poetry env use $VPYTHON_VERSION
$POETRY_BIN env use $VPYTHON_VERSION

poetry install
$POETRY_BIN install

# Install pre-commit hooks
poetry run pre-commit install

$POETRY_BIN run pre-commit install

# Command to run all pre-commit hooks
poetry run pre-commit run --all-files --hook-stage push
$POETRY_BIN run pre-commit run --all-files --hook-stage push