Create venv and activate it and install packages:
python3 -m venv venv
source venv/bin/activate
python3 -m pip install --upgrade pip
python3 -m pip install wheel
pip install -r requirements.txt
I wanted a similar one-liner that I could use on a fresh Ubuntu machine so I can try out PyPy easily in the same way. After a bit of fiddling, I came up with this monstrosity which should work with both bash and zsh (though I only tested it on zsh):Create venv and activate it and install packages using pyenv/pypy/pip:
if [ -d "$HOME/.pyenv" ]; then rm -Rf $HOME/.pyenv; fi && \
curl https://pyenv.run | bash && \
DEFAULT_SHELL=$(basename "$SHELL") && \
if [ "$DEFAULT_SHELL" = "zsh" ]; then RC_FILE=~/.zshrc; else RC_FILE=~/.bashrc; fi && \
if ! grep -q 'export PATH="$HOME/.pyenv/bin:$PATH"' $RC_FILE; then echo -e '\nexport PATH="$HOME/.pyenv/bin:$PATH"' >> $RC_FILE; fi && \
if ! grep -q 'eval "$(pyenv init -)"' $RC_FILE; then echo 'eval "$(pyenv init -)"' >> $RC_FILE; fi && \
if ! grep -q 'eval "$(pyenv virtualenv-init -)"' $RC_FILE; then echo 'eval "$(pyenv virtualenv-init -)"' >> $RC_FILE; fi && \
source $RC_FILE && \
LATEST_PYPY=$(pyenv install --list | grep -P '^ pypy[0-9\.]*-\d+\.\d+' | grep -v -- '-src' | tail -1) && \
LATEST_PYPY=$(echo $LATEST_PYPY | tr -d '[:space:]') && \
echo "Installing PyPy version: $LATEST_PYPY" && \
pyenv install $LATEST_PYPY && \
pyenv local $LATEST_PYPY && \
pypy -m venv venv && \
source venv/bin/activate && \
pip install --upgrade pip && \
pip install wheel && \
pip install -r requirements.txt
Maybe others will find it useful.