Patrick Collins
Patrick Collins

Reputation: 10574

Start a virtualenv inside a shell script

I'm working on a Python project that's wrapped in a virtualenv. I'd like to have a script that does all the "footwork" of getting set up as soon as I clone my git repo -- namely make the virtualenv, download my requirements, and stay in the virtualenv after exiting. However, once the shell script finishes, I'm no longer in my virtualenv, since the changes it makes to its shell don't propagate to mine.

How can I have the virtualenv "stick" to the parent shell that ran the script?

Upvotes: 0

Views: 328

Answers (1)

tripleee
tripleee

Reputation: 189387

Use a function instead of a separate script. A function executes in the context of your current shell.

Upvotes: 1

Related Questions