-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinitialize.sh
More file actions
executable file
·51 lines (47 loc) · 1.56 KB
/
initialize.sh
File metadata and controls
executable file
·51 lines (47 loc) · 1.56 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
#!/bin/bash
set -x
# Setup barebones python project
## Usage
### init $project_name [$python_version=3.10.0]
### init my_python_project 3.8.1
PROJECT_NAME=${1}
PYTHON_VERSION=${2:-"3.9.0"}
## Install pyenv
### assumes you have Linux based OS and permissions to run apt-get
### check if pyenv is already installed
if command -v pyenv &> /dev/null
then
echo "pyenv installation found, updating it!"
pyenv update
else
## Install dependencies
sudo apt-get update -y
sudo apt-get -y install make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
### as per https://github.com/pyenv/pyenv-installer
curl https://pyenv.run | bash
exec $SHELL
fi
pyenv install -v $PYTHON_VERSION --skip-existing
pyenv local $PYTHON_VERSION
## Install pipx
python -m pip install --user pipx
python -m pipx ensurepath
## Poetry to manage dependencies
pipx install poetry
## Initialize new project
poetry new $PROJECT_NAME
cp .pre-commit-config.yaml $PROJECT_NAME/.pre-commit-config.yaml
cd $PROJECT_NAME
pyenv local $PYTHON_VERSION
## Git specific setup
sudo apt-get -y install git-all
git init
## .gitignore for python (standard github version from https://github.com/github/gitignore/blob/main/Python.gitignore)
curl -o .gitignore https://raw.githubusercontent.com/github/gitignore/main/Python.gitignore
## Specify some dev libraries
poetry add --dev black flake8 pytest
## Specify pre-commit library
poetry add pre-commit
pre-commit install