mirror of
https://github.com/buchtioof/venv-setup.git
synced 2026-05-02 17:43:30 +02:00
rollback
This commit is contained in:
parent
1a52ef7f9f
commit
940a765851
23
venvsetup.sh
23
venvsetup.sh
@ -20,7 +20,7 @@ fi
|
|||||||
create_venv() {
|
create_venv() {
|
||||||
if [ -z "$venv_path" ]; then
|
if [ -z "$venv_path" ]; then
|
||||||
echo "No virtual environment found."
|
echo "No virtual environment found."
|
||||||
read -p "Type the name of your venv: " name < /dev/tty
|
read -p "Type the name of your venv: " name
|
||||||
echo "Creating virtual environment: $name"
|
echo "Creating virtual environment: $name"
|
||||||
python3 -m venv "$name"
|
python3 -m venv "$name"
|
||||||
venv_path="./$name"
|
venv_path="./$name"
|
||||||
@ -30,12 +30,14 @@ create_venv() {
|
|||||||
|
|
||||||
# --- Add venv to .gitignore
|
# --- Add venv to .gitignore
|
||||||
gitignore() {
|
gitignore() {
|
||||||
if [ -f .gitignore ] && grep -qx "$venv_path" .gitignore; then
|
if [ -f .gitignore ]; then
|
||||||
return
|
if grep -qx "$venv_path" .gitignore; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Do you want to add the venv to .gitignore? (recommended)"
|
echo "Do you want to add the venv to .gitignore? (recommended)"
|
||||||
read -p " y / n " choice < /dev/tty
|
read -p " y / n " choice
|
||||||
if [ "$choice" = "y" ]; then
|
if [ "$choice" = "y" ]; then
|
||||||
echo "$venv_path" >> .gitignore
|
echo "$venv_path" >> .gitignore
|
||||||
echo "Added $venv_path to .gitignore"
|
echo "Added $venv_path to .gitignore"
|
||||||
@ -59,7 +61,7 @@ activate_venv() {
|
|||||||
requirements() {
|
requirements() {
|
||||||
if [ -n "$existing_req" ]; then
|
if [ -n "$existing_req" ]; then
|
||||||
echo "requirements.txt detected. Install dependencies?"
|
echo "requirements.txt detected. Install dependencies?"
|
||||||
read -p " y / n " choice < /dev/tty
|
read -p " y / n " choice
|
||||||
if [ "$choice" = "y" ]; then
|
if [ "$choice" = "y" ]; then
|
||||||
pip install -r "$existing_req"
|
pip install -r "$existing_req"
|
||||||
echo "Dependencies installed"
|
echo "Dependencies installed"
|
||||||
@ -67,15 +69,14 @@ requirements() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# --- Install one package
|
# --- Install packages interactively
|
||||||
installer() {
|
installer() {
|
||||||
read -p "Type the package you need to install: " package < /dev/tty
|
read -p "Type the package you need to install: " package
|
||||||
pip install "$package"
|
pip install "$package"
|
||||||
}
|
}
|
||||||
|
|
||||||
# --- Alfred logic (first question + follow-ups)
|
|
||||||
alfred() {
|
alfred() {
|
||||||
read -p "Do you want to install a package? (y / n) " choice < /dev/tty
|
read -p "Do you want to install a package? (y / n) " choice
|
||||||
if [ "$choice" != "y" ]; then
|
if [ "$choice" != "y" ]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
@ -83,7 +84,7 @@ alfred() {
|
|||||||
installer
|
installer
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
read -p "Do you want to install another package? (y / n) " choice < /dev/tty
|
read -p "Do you want to install another package? (y / n) " choice
|
||||||
if [ "$choice" = "y" ]; then
|
if [ "$choice" = "y" ]; then
|
||||||
installer
|
installer
|
||||||
else
|
else
|
||||||
@ -92,6 +93,7 @@ alfred() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# ------------------ MAIN ------------------
|
# ------------------ MAIN ------------------
|
||||||
|
|
||||||
create_venv
|
create_venv
|
||||||
@ -104,3 +106,4 @@ echo ""
|
|||||||
echo "Your venv is ready!"
|
echo "Your venv is ready!"
|
||||||
echo "To activate it later, run:"
|
echo "To activate it later, run:"
|
||||||
echo "source \"$venv_path/bin/activate\""
|
echo "source \"$venv_path/bin/activate\""
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user