how do virtualenvs actually work (advanced) anthony explains
Вставка
- Опубліковано 7 вер 2024
- today I go over the technical details of how virtualenvs actually function, including the absurdity of needing to start 3 processes for every executable on windows
- virtualenv vs venv: • virtualenv vs. venv (b...
- windows exe shims: • pure python windows .e...
playlist: • anthony explains
==========
twitch: / anthonywritescode
dicsord: / discord
twitter: / codewithanthony
github: github.com/aso...
stream github: github.com/ant...
I won't ask for subscriptions / likes / comments in videos but it really helps the channel. If you have any suggestions or things you'd like to see please comment below!
This video should've been titled: Shimlinks and shebangs
(windows suuuucks)
Most of the first differences you mentioned between POSIX and Windows venvs make sense. The capital Lib directory without the python3.10 subdirectory and Scripts instead of bin are how the equivalent directories are at the system level (C:\Python310) too (no need for python3.10 directory inside Lib when it is already inside a Python310 directory, unlike POSIX). The only thing about this that really annoys me is that they do include an activate bash script on Windows (in addition to activate.bat) in case you're using bash on Windows (like Git bash), but it is source venv/Scripts/activate instead of source venv/bin/activate. I'm so close to getting the POSIX-like workflow I like on Windows (natively, without WSL or Cygwin nonsense), but they couldn't just give me another copy of activate in a bin directory?
yeah I know why they're different -- I just wish they weren't
Great video!
About symlinks, windows supports them, as well as longer paths, but this needs to be fixed using registry ;)
yes and I say that in the video -- but even with them enabled they don't work the same / nicely
Yeah, unfortunately windows in this case is lacking some things, as well as it lacks quick stat(), but have their own sort-of copycat method of quick check of file properties etc. It's a looong debate, with proper drinks and stuff associated ;)
Thanks for this!
Does WSL work as other POSIX venvs?
WSL is an actual posix environment
would have been interesting to have also dived into the activate script(s) but I guess it's just for modifying the path to use the specific executables?
yep -- those get covered in the video in the description -- it's basically just PATH and PS1 manipulation
Useful, thank you!
maybe a difficult one to demonstrate, but can you make a tutorial about when given a huge project, pytest for instance, how do we start from ?
for me it's really just ua-cam.com/video/2MCtRv1ZIFQ/v-deo.html and ua-cam.com/video/0LPuG825eAk/v-deo.html
How do you autocomplete in Windows CMD? Do you use Ctrl+D Ctrl+F (cmd /f), or is there another method?
just pressed tab!
do you know if there's a pep that defines the sys.base_prefix behaviour that you mentioned at the start?
looks like 405 goes over the behaviour
Sometimes we need access to `python3-config`. Using virtual environments on Linux, how i get the symlink to `python-config` ?
ime you shouldn't use python-config and should instead retreive the values you want from `sysconfig`
Can you also do a deep dive into pyenv.
I think pyenv is bad so probably not
Something that bothers me in python is dependency management.
Why can't we have 2 versions of numpy in one venv.
For example let's say numba needs numpy 1.22 and pandas needs 1.21
What would python need to do to support that?
you would need full module isolation (modules are all shared) and full c symbol isolation (afaict not really possible)