Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run pipenv shell as part of a bash script

I created a bash script to scaffold boilerplates for several apps (React, Next.js, django, etc).

In part of my django_install() function, I run the following (reduced here):

mkdir "$app_name"
cd ./"$app_name" || exit 0
gh repo clone <my-repo-boilerplate> .
rm -rf .git
pipenv install
pipenv install --dev
exit 0

I would also like to execute pipenv shell and some commands that need to run inside that virtual environment, as my boilerplate has some custom scripts that I'd like to run to automatise the script completely.

I understand I cannot just run pipenv shell or python manage.py [etc...] in my bash script.

How could I achieve it?

like image 482
Guillermo Brachetta Avatar asked Sep 05 '25 03:09

Guillermo Brachetta


1 Answers

I think you can use pipenv run for that. E.g.:

pipenv run python manage.py [etc...]

Which will run python manage.py within the virtual environment created by pipenv.

https://pipenv.pypa.io/en/latest/cli.html#run

like image 131
mihi Avatar answered Sep 07 '25 21:09

mihi