feat: include bin/
This commit is contained in:
parent
cce6c7103b
commit
6a5500797d
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,4 +3,3 @@ __pycache__/
|
||||
data/
|
||||
r.http
|
||||
*.bak
|
||||
!bin/configure
|
||||
|
79
bin/configure
vendored
Executable file
79
bin/configure
vendored
Executable file
@ -0,0 +1,79 @@
|
||||
#!/bin/sh
|
||||
set -euC
|
||||
|
||||
_venv() {
|
||||
_py_version=${1:-3.12.0}
|
||||
|
||||
if command -v pyenv >/dev/null 2>&1; then
|
||||
pyenv install $_py_version
|
||||
pyenv shell $_py_version
|
||||
if [ -d .venv ]; then
|
||||
rm -rf .venv
|
||||
fi
|
||||
python -m venv ".venv"
|
||||
else
|
||||
echo "Please install pyenv"
|
||||
fi
|
||||
}
|
||||
VENV_match=venv
|
||||
|
||||
_init() {
|
||||
if [ -d .venv ]; then
|
||||
source .venv/bin/activate
|
||||
pip install --upgrade pip
|
||||
pip install -r requirements.txt
|
||||
else
|
||||
echo "Please run 'bin/configure venv' first"
|
||||
fi
|
||||
}
|
||||
INIT_match=init
|
||||
|
||||
_freeze() {
|
||||
if [ -d .venv ]; then
|
||||
source .venv/bin/activate
|
||||
mv requirements.txt requirements.txt.bak
|
||||
pip freeze >requirements.txt
|
||||
else
|
||||
echo "Please run 'bin/configure init' first"
|
||||
fi
|
||||
}
|
||||
FREEZE_match=freeze
|
||||
|
||||
_help() {
|
||||
echo -e "Usage: $0 [help, -h | init {python_version} | venv {python_version} | freeze]\n"
|
||||
echo " help, -h: Show this help message"
|
||||
echo " init: Initialize virtual environment with {python_version} and install dependencies"
|
||||
echo " venv: Create virtual environment with {python_version}"
|
||||
echo " freeze: Freeze dependencies"
|
||||
}
|
||||
|
||||
_check_cmds() {
|
||||
if ! command -v pyenv >/dev/null 2>&1; then
|
||||
echo "Please install pyenv"
|
||||
_fail=true
|
||||
fi
|
||||
}
|
||||
|
||||
_main() {
|
||||
_fail=false
|
||||
_check_cmds
|
||||
|
||||
if $_fail; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
_cmd="${1:-help}"
|
||||
|
||||
case "$_cmd" in
|
||||
--*) ;;
|
||||
help | -h) _help ;;
|
||||
"$VENV_match") _venv "${2:-}" ;;
|
||||
"$INIT_match")
|
||||
_venv "${2:-}"
|
||||
_init
|
||||
;;
|
||||
"$FREEZE_match") _freeze ;;
|
||||
esac
|
||||
}
|
||||
|
||||
_main "$@"
|
Loading…
x
Reference in New Issue
Block a user