-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_after_install-python-setup.sh.tmpl
More file actions
65 lines (53 loc) · 1.6 KB
/
run_after_install-python-setup.sh.tmpl
File metadata and controls
65 lines (53 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env bash
set -e
PYTHON_VERSION="3.12.9"
export PYENV_ROOT="{{ .large_install_dir }}/.local/pyenv"
export WORKON_HOME="{{ .large_install_dir }}/.local/virtualenvs"
# Install pyenv if not present
if [[ ! -x "$(command -v pyenv)" ]] && [[ ! -d "${PYENV_ROOT}" ]]; then
curl https://pyenv.run | bash
fi
# Initialize pyenv
if [[ -d "${PYENV_ROOT}" ]]; then
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
fi
# Install Python version and set as global
${HOME}/bin/pyenv_python_install ${PYTHON_VERSION}
# Install uv if not present
if [[ ! -x "$(command -v uv)" ]]; then
curl -LsSf https://astral.sh/uv/install.sh | sh
fi
# Ensure uv is in PATH
export PATH="${HOME}/.local/bin:${PATH}"
# Install poetry via uv tool
if [[ ! -x "$(command -v poetry)" ]]; then
uv tool install poetry
fi
# Create a dotfiles venv with common tools using uv
VENV_NAME="dotfiles"
VENV_LOCATION="${WORKON_HOME}/${VENV_NAME}"
if [[ ! -d "${VENV_LOCATION}" ]]; then
echo "Creating dotfiles venv at ${VENV_LOCATION}"
mkdir -p "${WORKON_HOME}"
uv venv "${VENV_LOCATION}" --python "$(pyenv which python3)"
# Install common Python tools and data science packages in the dotfiles venv
uv pip install --python "${VENV_LOCATION}/bin/python" \
black \
flake8 \
jedi \
matplotlib \
numpy \
pandas \
pycodestyle \
pydocstyle \
pyflakes \
pylint \
python-lsp-black \
python-lsp-server \
pyls-flake8 \
rope \
scikit-learn \
scipy \
seaborn
fi