generated from AnswerDotAI/nbdev-template
-
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.
Feat: Poetry install script (incomplete draft)
- Loading branch information
1 parent
9a8614d
commit 1d7b3c7
Showing
1 changed file
with
51 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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/bin/bash | ||
|
||
# Function to check if a command is available | ||
command_exists() { | ||
command -v "$1" &> /dev/null | ||
} | ||
|
||
# Check if Poetry is installed | ||
if command_exists poetry && poetry --version &> /dev/null; then | ||
echo "Poetry is already installed. Version: $(poetry --version)" | ||
else | ||
echo "Poetry is not installed. Installing now..." | ||
|
||
# Install Poetry | ||
curl -sSL https://install.python-poetry.org | python3 - | ||
|
||
# Add poetry to PATH | ||
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc | ||
source ~/.bashrc | ||
|
||
echo "Poetry has been installed." | ||
fi | ||
|
||
echo "Configuring Poetry to use virtual environment in project directory..." | ||
|
||
# Configure Poetry to use a virtual environment in the project | ||
poetry config virtualenvs.in-project true | ||
|
||
echo "Poetry is now configured to use a virtual environment in the project directory." | ||
|
||
# Navigate to the project directory | ||
project_dir=$(pwd) | ||
|
||
# Check if the virtual environment exists in the project directory | ||
if [ -d ".venv" ]; then | ||
echo "Virtual environment in project directory exists." | ||
fi | ||
|
||
# Analyze project content and create pyproject.toml file if not exists | ||
if [ ! -f pyproject.toml ]; then | ||
echo "Creating pyproject.toml file..." | ||
poetry init --no-interaction | ||
else | ||
echo "pyproject.toml file already exists. Skipping initialization." | ||
fi | ||
|
||
# Install project dependencies | ||
echo "Installing project dependencies..." | ||
poetry install | ||
|
||
echo "Script execution complete." |