I’ve recently discovered pipenv, and it has been a massive QoL improvement. No need to figure out bazillion of commands just to create or start an environment, or deal with what params should you use for it like you do with venv. You just pipenv install -r requirements.txt, and everything is handled for you. And when you need to run it, just pipenv run python script.py and you are good to go.
The best thing however are the .pipfiles, that can be distributed instead of requirements.txt, and I don’t get why it’s not more common. It’s basically requirements, but directly for pipenv, so you don’t need to install anything and just pipenv run from the same folder.
I actually wrote a script to make a folder an instant pipenv environment for me. Add it to your ./.zshrc. Has saved me a ton of time, I just removed some spaghetti lines that would reinstall pip and shit because it’s when I was still early days into Py dev, now I work more with Py than I do C# and I’m a senior C# engineer, I just enjoy the masochism of py.
Also added a check for Arch/Ubu.
#######################################
VENV(){
if ! [ -x "$(command -v pipenv)" ]; then
echo "pipenv not installed... installing it now!"
sudo pip install pipenv
OS="$( ( lsb_release -ds || cat /etc/*release || uname -om ) 2>/dev/null | head -n1 )"
if [[ "$OS" == *"buntu"* ]]; then
sudo apt install pipenv -y
elif [[ "$OS" == *"rch"* ]]; then
sudo pacman -S pipenv
fi
pip install pipenv --upgrade
echo "Installation complete!"
fi
if [ -n "$1" ]; then
echo -e "Args detected, specifically using version $1 of python in this project!"
version="$1"
else
version=$(python -V)
version=$(echo "$version" | sed -e 's/Python //')
if [ -z "$version" ]; then
version=$(python3 -V)
if [ -z "$version" ]; then
echo "No python version installed... exiting."
return
fi
fi
fi
echo -e "\n===========\nCreate a Python $version virtual environment in $PWD/.venv [y/n]?\n==========="
read -r answer
case $answer in
[yY][eE][sS]|[yY])
export PIPENV_VENV_IN_PROJECT=1
pipenv --python "$version"
pipenv install -r ./requirements.txt
echo -e "\n\n\nVirtual python environment successfully created @ $PWD/.venv!\n"
echo -e "To run commands from this dir use 'pipenv run python ./main.py'"
echo -e "To enter a shell in this venv use 'pipenv shell'."
echo -e "To install from a requirements text file use 'pipenv install -r requirements.txt'"
echo -e "To update pip + all pip modules use 'pipenv update'!\n"
echo -e "Additional information can be found @ https://pipenv-fork.readthedocs.io/en/latest/basics.html"
;;
[nN][oO]|[nN])
echo "Fine then weirdo why did you run the command then, jeez.Exiting"
;;
*)
echo "Invalid input..."
;;
esac
}
I could redraw this whole chart using only references to pipenv based on my experiences with managing it alongside other tools (especially homebrew). It’s good at many things but is no magic bullet.
I’ve been burned by pipenv before on a large project where it was taking upwards of 20 minutes to lock dependencies. I think these days they use poetry instead, but I’ve heard the performance is still not very scalable
With that said, I think it can be a nice addition, but I think it comes down to Python packages not really taking dependency management as a top priority instead of favoring flexibility. This forces a package manager to download and execute the packages to get all the dependency information. Naturally, this is a time-consuming process if the number of packages is large.
On multiple instances I’ve seen projects abandon it for pip and a requirements.txt because it became unmanageable. It’s left a bad taste in my mouth. I don’t like solutions that claim to solve problems but introduce new ones.
I’ve recently discovered pipenv, and it has been a massive QoL improvement. No need to figure out bazillion of commands just to create or start an environment, or deal with what params should you use for it like you do with venv. You just pipenv install -r requirements.txt, and everything is handled for you. And when you need to run it, just pipenv run python script.py and you are good to go.
The best thing however are the .pipfiles, that can be distributed instead of requirements.txt, and I don’t get why it’s not more common. It’s basically requirements, but directly for pipenv, so you don’t need to install anything and just pipenv run from the same folder.
Yessssss
I actually wrote a script to make a folder an instant pipenv environment for me. Add it to your ./.zshrc. Has saved me a ton of time, I just removed some spaghetti lines that would reinstall pip and shit because it’s when I was still early days into Py dev, now I work more with Py than I do C# and I’m a senior C# engineer, I just enjoy the masochism of py.
Also added a check for Arch/Ubu.
I could redraw this whole chart using only references to pipenv based on my experiences with managing it alongside other tools (especially homebrew). It’s good at many things but is no magic bullet.
I’ve been burned by
pipenv
before on a large project where it was taking upwards of 20 minutes to lock dependencies. I think these days they usepoetry
instead, but I’ve heard the performance is still not very scalableWith that said, I think it can be a nice addition, but I think it comes down to Python packages not really taking dependency management as a top priority instead of favoring flexibility. This forces a package manager to download and execute the packages to get all the dependency information. Naturally, this is a time-consuming process if the number of packages is large.
On multiple instances I’ve seen projects abandon it for
pip
and arequirements.txt
because it became unmanageable. It’s left a bad taste in my mouth. I don’t like solutions that claim to solve problems but introduce new ones.