-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ on: | |
- '**.gif' | ||
- '**.yml' | ||
- 'const.py' | ||
- 'tools/' | ||
|
||
jobs: | ||
build: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,9 @@ log | |
.coverage* | ||
htmlcov/ | ||
|
||
# venv | ||
.pigit_venv | ||
|
||
# useless file temp | ||
useless/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/usr/bin/env sh | ||
# run scirpit with `source`. | ||
|
||
# 检查Python版本 | ||
version=$(python3 -c 'import sys; sys.exit(sys.version_info < (3, 7))') | ||
echo $version | ||
if [[ "$version" ]]; then | ||
echo "Python版本必须为3.8或更高版本" | ||
exit 1 | ||
fi | ||
|
||
op=$1 | ||
name=".pigit_venv" | ||
|
||
create_venv() { | ||
if [ -d "$name" ]; then | ||
echo "Virtual env'$name' existed." | ||
exit 1 | ||
fi | ||
|
||
python3 -m venv "$name" | ||
|
||
source "$name/bin/activate" | ||
|
||
pip install -r requirements.txt | ||
|
||
echo "Virtual env has created. activate with running::" | ||
echo "source $name/bin/activate" | ||
} | ||
|
||
activate_venv() { | ||
if [ ! -d "$name" ]; then | ||
echo "Not found env '$name'." | ||
exit 1 | ||
fi | ||
|
||
source "$name/bin/activate" | ||
echo "The virtual env has actived." | ||
} | ||
|
||
deactivate_venv() { | ||
if [ -z "$VIRTUAL_ENV" ]; then | ||
echo "Current not activate virtula env." | ||
exit 1 | ||
fi | ||
|
||
# exit command | ||
deactivate | ||
echo "The virtual env exited." | ||
} | ||
|
||
|
||
if [[ "$op" == "start" ]]; then | ||
activate_venv | ||
elif [[ "$op" == "stop" ]]; then | ||
deactivate_venv | ||
else | ||
create_venv | ||
fi | ||
|