User avatar
pathetic piss kitten @kitten@elizabeth.cat
1y
I hate python
:blobcathearttrans@fedi.xerz.one:1❤️1
1
0
4
2

User avatar
pathetic piss kitten @kitten@elizabeth.cat
1y
what the hell is a virtualenv
❤️1
5
1
3
1
User avatar
theking killed the radio star @theking@mskey.nekomimi.party
1y
@kitten iirc that's to fix the problem created by pip/modules/whatever they're called
1
0
0
0
User avatar
pathetic piss kitten @kitten@elizabeth.cat
1y
@theking they have a very interesting way of "solving" problems
❤️1👍1
0
0
0
2
User avatar
Xerz 💗 @xerz@fedi.xerz.one
1y
@kitten a miserable pile of neocat_gun

(really, it’s just like they tried to invent containers before they actually could, so they just did path/envvar trickery for Python-only stuff and called it a day)
:blobwtfnotlikethis:1
0
0
0
1
User avatar
Alba 🌸 v_pat @mildsunrise@tech.lgbt
1y
@kitten a virtualenv is a folder that contains a bin/python, bin/pip, lib/site-packages...

using the bin/python of a virtualenv, your imports will look at lib/site-packages of that virtualenv

using the bin/pip of a virtualenv operates on the lib/site-packages of the virtualenv instead of the system's one

that way you can install the dependencies a project needs without interfering with the global python installation
2
0
1
0
User avatar
Alba 🌸 v_pat @mildsunrise@tech.lgbt
1y
@kitten for convenience, virtualenvs also come with a bin/activate script. sourcing that into your shell places the virtualenv's bin folder into your path, so you can do

pip install thing
python main.py

instead of

virtualenv/bin/pip install thing
virtualenv/bin/python main.py
1
0
2
0
User avatar
Alba 🌸 v_pat @mildsunrise@tech.lgbt
1y
@kitten also 'virtualenv' is how the original tool to create and manage these directories was called, but since then it has become deprecated in favor of the venv tool (invoked with 'python -m venv'). still the name 'virtualenv' has sticked as a way to refer to the general concept, regardless of which tool was used to create it
1
0
1
0
@mildsunrise @kitten the problem that virtualenvs are meant to solve is package and Python version management

Python dependencies were traditionally managed by a system-wide package manager (
pip), but that was annoying because then different programs that needed a different version of the same package exploded, so packages are installed inside the virtualenv directories now (each project has its own copy of the dependencies it needs)

If you've used Rust or Node.js, they have the same concept (
node_modules and i forgor what the cargo folder is called)
1
0
0
0
User avatar
pathetic piss kitten @kitten@elizabeth.cat
1y
@jessew @mildsunrise except npm already manages that for me, I don't need to create my own virtualenv, deciding where to place it, or putting it in my path
1
0
0
0
@kitten @mildsunrise yeah it's just an extra step because python didn't do it like this from the get-go
1
0
0
0
@mildsunrise @kitten virtualenv essentially sets some shell environment variables to tell python "yo, look for packages in this directory instead of the default /usr/bin/whatever"
0
0
1
0
User avatar
pathetic piss kitten @kitten@elizabeth.cat
1y
@mildsunrise so I should just use devcontainers, got it
1
0
1
0
User avatar
Alba 🌸 v_pat @mildsunrise@tech.lgbt
1y
@kitten ...no, it makes little sense to use virtualenvs if your global installation is already unique to your project. if you're using a devcontainer you can skip the virtualenv entirely
0
0
1
0
User avatar
ity [unit X-69] - VIOLENT FUCK @ity@estradiol.city
1y
@kitten prefix/container for libraries
0
0
1
0
User avatar
Klaus Frank @agowa338@chaos.social
1y
@kitten the thing you want to use. Python in a folder, so that all of the dependencies related to that project are basically vendored.
However for some reason they still don't statically link the binaries so it will still randomly stop working.

That way for python the best approach to vendoring to this day is a docker container, sadly.

also all of the alternatives like pyenv and such have similar issues, especially if it should work cross platform as well...
0
0
1
0