Skip to content

Commit

Permalink
Trying a better python setup
Browse files Browse the repository at this point in the history
  • Loading branch information
marchdf committed Feb 20, 2024
1 parent f4bcc03 commit 4a2cfef
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 29 deletions.
42 changes: 42 additions & 0 deletions bin/executable_pyenv_python_install.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash

if [[ ! -x "$(command -v pyenv)" ]]; then
echo "Please install pyenv"
exit 1
fi

{{- if eq .nrel_cluster "eagle" }}
module load gcc
module load binutils
module load git
module load gnutls
module load libtool
module load bzip2
module load libffi
module load openssl
module load sqlite
export LDFLAGS="-L${OPENSSL_ROOT_DIR}/lib -L${LIBFFI_ROOT_DIR}/lib64 -L${BZIP2_ROOT_DIR}/lib -L${SQLITE_ROOT_DIR}/lib"
export CPPFLAGS="-I${OPENSSL_ROOT_DIR}/include -I${LIBFFI_ROOT_DIR}/include -I${BZIP2_ROOT_DIR}/include -I${SQLITE_ROOT_DIR}/include"
{{- else if eq .nrel_cluster "ellis" }}
module load gcc
module load binutils
module load git
module load gnutls
module load libtool
module load bzip2
module load libffi
module load sqlite
export LDFLAGS="-L${LIBFFI_ROOT_DIR}/lib64 -L${BZIP2_ROOT_DIR}/lib -L${SQLITE_ROOT_DIR}/lib"
export CPPFLAGS="-I${LIBFFI_ROOT_DIR}/include -I${BZIP2_ROOT_DIR}/include -I${SQLITE_ROOT_DIR}/include"
{{- end }}
export PYTHON_CONFIGURE_OPTS="--enable-optimizations --with-lto"
export PYTHON_CFLAGS="-mtune=native"


PYTHON_VERSION="${1}"
if [ ! -z "$python_version" ]
then
pyenv install
else
pyenv install -s ${PYTHON_VERSION}
fi
29 changes: 0 additions & 29 deletions dot_local/share/zinit/plugins/hpc/hpc.plugin.zsh.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -88,35 +88,6 @@ function pvtunnel() {
ssh -L 11111:$1:11111 mhenryde@$1
}

function pyenv_python_install() {
{{- if eq .nrel_cluster "eagle" }}
module load gcc
module load binutils
module load git
module load gnutls
module load libtool
module load bzip2
module load libffi
module load openssl
module load sqlite
export LDFLAGS="-L${OPENSSL_ROOT_DIR}/lib -L${LIBFFI_ROOT_DIR}/lib64 -L${BZIP2_ROOT_DIR}/lib -L${SQLITE_ROOT_DIR}/lib"
export CPPFLAGS="-I${OPENSSL_ROOT_DIR}/include -I${LIBFFI_ROOT_DIR}/include -I${BZIP2_ROOT_DIR}/include -I${SQLITE_ROOT_DIR}/include"
{{- else if eq .nrel_cluster "ellis" }}
module load gcc
module load binutils
module load git
module load gnutls
module load libtool
module load bzip2
module load libffi
module load sqlite
export LDFLAGS="-L${LIBFFI_ROOT_DIR}/lib64 -L${BZIP2_ROOT_DIR}/lib -L${SQLITE_ROOT_DIR}/lib"
export CPPFLAGS="-I${LIBFFI_ROOT_DIR}/include -I${BZIP2_ROOT_DIR}/include -I${SQLITE_ROOT_DIR}/include"
{{- end }}
export PYTHON_CONFIGURE_OPTS="--enable-optimizations --with-lto"
export PYTHON_CFLAGS="-mtune=native"
pyenv install
}
{{ end }}

{{- if .ornl_hpc }}
Expand Down
64 changes: 64 additions & 0 deletions run_once_after_install-python-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/usr/bin/env bash

# start clean
# rm -rf $(pyenv root)
# curl -sSL https://install.python-poetry.org | POETRY_VERSION=1.7.0 POETRY_HOME=${HOME}/.poetry python3 - --uninstall


# Make sure python3 installation worked
if ! command -v python3 >/dev/null 2>&1; then
echo "Please install python3"
exit 1
fi

# Install pyenv and a sane python
if [[ ! -x "$(command -v pyenv)" ]]; then
curl https://pyenv.run | bash
fi

export PYENV_ROOT="${HOME}/.pyenv"
if [ -d "${PYENV_ROOT}" ]; then
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
fi

PYTHON_VERSION="3.11.1"
${HOME}/bin/pyenv_python_install ${PYTHON_VERSION}

# Install poetry with the pyenv python
if [[ ! -x "$(command -v poetry)" ]]; then
curl -sSL https://install.python-poetry.org | PYENV_VERSION=${PYTHON_VERSION} POETRY_VERSION=1.7.0 POETRY_HOME=${HOME}/.poetry python3 -
fi

# Create a sane dotfiles venv
export PYENV_VERSION=${PYTHON_VERSION}
export WORKON_HOME=${HOME}/.virtualenvs
venv_name="dotfiles"
venv_location="${WORKON_HOME}/${venv_name}"

echo "Installing dotfiles venv at ${venv_location} with $(python --version)"

python -m venv "${venv_location}"
source ${venv_location}/bin/activate
python -m pip install --upgrade pip
pip install --requirement=/dev/stdin <<EOF
autopep8
black
flake8
jedi
matplotlib
numpy
pandas
pycodestyle
pydocstyle
pyflakes
python-lsp-black
python-lsp-server
pyls-flake8
pylint
scikit-learn
scipy
seaborn
rope
yapf
EOF

0 comments on commit 4a2cfef

Please sign in to comment.