-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path20-poetry.sh
44 lines (32 loc) · 1.05 KB
/
20-poetry.sh
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
# Check if Poetry is installed
if ! command -v poetry &> /dev/null
then
echo "Poetry is not installed. Please install Poetry and try again."
exit 1
fi
# Check if the POETRY_PROJECT_NAME environment variable is set
if [[ -z "$POETRY_PROJECT_NAME" ]]; then
echo "POETRY_PROJECT_NAME environment variable is not set. Using the current directory name as the project name."
POETRY_PROJECT_NAME=$(basename "$PWD" | tr '.' '-')
export POETRY_PROJECT_NAME
fi
# Initialize a new Poetry project with the project name
poetry init --name "$POETRY_PROJECT_NAME" --no-interaction
# Switch to non-package-mode
cat <<EOF >> pyproject.toml
[tool.poetry]
package-mode = false
EOF
# add python stuff to gitignore
echo "__pycache__/" >> .gitignore
# describe in the README
cat <<EOF >> "README.md"
# $POETRY_PROJECT_NAME
## Python deps
This project uses Poetry for dependency management. To install the dependencies, run:
poetry install
To activate the virtual environment, run:
poetry shell
EOF
git add --all
git commit -m "Initialize Poetry environment"