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!

КОМЕНТАРІ • 26

  • @mrswats
    @mrswats Рік тому +21

    This video should've been titled: Shimlinks and shebangs

    • @mrswats
      @mrswats Рік тому +4

      (windows suuuucks)

  • @sparkyb6
    @sparkyb6 Рік тому +6

    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?

    • @anthonywritescode
      @anthonywritescode  Рік тому +3

      yeah I know why they're different -- I just wish they weren't

  • @d3stinYwOw
    @d3stinYwOw Рік тому +3

    Great video!
    About symlinks, windows supports them, as well as longer paths, but this needs to be fixed using registry ;)

    • @anthonywritescode
      @anthonywritescode  Рік тому +2

      yes and I say that in the video -- but even with them enabled they don't work the same / nicely

    • @d3stinYwOw
      @d3stinYwOw Рік тому +1

      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 ;)

  • @OrCarmi
    @OrCarmi Рік тому +2

    Thanks for this!
    Does WSL work as other POSIX venvs?

  • @levblit3721
    @levblit3721 Рік тому +1

    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?

    • @anthonywritescode
      @anthonywritescode  Рік тому +2

      yep -- those get covered in the video in the description -- it's basically just PATH and PS1 manipulation

  • @evadeflow
    @evadeflow Рік тому

    Useful, thank you!

  • @Cookie-mv2hg
    @Cookie-mv2hg Рік тому +2

    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 ?

    • @anthonywritescode
      @anthonywritescode  Рік тому

      for me it's really just ua-cam.com/video/2MCtRv1ZIFQ/v-deo.html and ua-cam.com/video/0LPuG825eAk/v-deo.html

  • @MogensHertz
    @MogensHertz 3 місяці тому

    How do you autocomplete in Windows CMD? Do you use Ctrl+D Ctrl+F (cmd /f), or is there another method?

  • @sadhlife
    @sadhlife Рік тому

    do you know if there's a pep that defines the sys.base_prefix behaviour that you mentioned at the start?

  • @oleksisfraga
    @oleksisfraga Рік тому

    Sometimes we need access to `python3-config`. Using virtual environments on Linux, how i get the symlink to `python-config` ?

    • @anthonywritescode
      @anthonywritescode  Рік тому

      ime you shouldn't use python-config and should instead retreive the values you want from `sysconfig`

  • @user-wr4yl7tx3w
    @user-wr4yl7tx3w Рік тому

    Can you also do a deep dive into pyenv.

  • @JohnZakaria
    @JohnZakaria Рік тому

    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?

    • @anthonywritescode
      @anthonywritescode  Рік тому +3

      you would need full module isolation (modules are all shared) and full c symbol isolation (afaict not really possible)