Sponsored by us! Support our work through:

Brian #1: Do you really need a virtualenv?

  • Frost Ming doesn’t think so, based on the article You don’t really need a virtualenv
  • The link slug is “introducing-pdm”, which I think would be a better title, but the first did work to get people to talk about it. Also, “Try PEP 582 today” may have been appropriate.
  • Teaching new people is a problem:
  • Telling them to first type python -m venv venv
  • Then type source venv/bin/activate or . venv/bin/activate
  • Unless you’re on windows, then type venv\scripts\activate.bat
  • Then type pip install -r requirements.txt
  • Yeah. It’s not pretty, not fun, and good luck not having anyone ask questions about why this is necessary.
  • Also the Python version is specified in the venv. So if you upgrade Python versions, what happens to existing venvs?
  • The article also discusses levels of venvs, and global tools that maybe you want not tied to each venv. But we have pipx for that, so I don’t think that’s a real issue.
  • Enter PEP 582, still in draft mode.
  • Instead of a venv directory, your project has a __pypackage__ directory. If you python -m pip install in your project directory, stuff just goes there instead of to the global Python.
  • So it kinda acts like a venv for local packages, it just doesn’t include local copies of the Python executables, and such.
  • This is probably a horrible description of 582, but oh well. Something like that.
  • pdm supports 582 today
  • PDM stands for Python Development Master
  • “It installs and manages packages in a similar way to npm that doesn’t need to create a virtualenv at all!”
  • Has a workflow that reminds me of Poetry, but doesn’t use a venv, uses a package directory instead.
  • Conclusion:
  • Huge props to Frost for this. It’s cool to see a tool that supports 582 and glimpse a possible Python future.
  • However, this doesn’t solve the “teaching Python” problem. The setup is more complex than venv.
  • I’m personally sticking with venv, well virtualenv, until (and if) 582 is supported by Python and pip.

#html #javascript

HTMX: Dynamic and live HTML without JavaScript
1.75 GEEK