TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Python Project-Local Virtualenv Management Redux

46 点作者 nalgeon大约 1 年前

8 条评论

zokier大约 1 年前
People complain lot about python packaging, have complicated setups to work with it, and invent new tools all the time. In the meanwhile, I just use vanilla pip and venv with Debian Stable provided python like a caveman, and I&#x27;m... mostly content? For smaller stuff, I tend to use just Debian provided python packages, for the rest just (project-local) venv. Sure, there is occasionally some hitches, it&#x27;s not perfect, but I haven&#x27;t yet felt the need to reach for anything else.<p>I bring this up because this is such a common topic to complain about, and there is this sentiment that Python packaging is completely broken and unusable. But for me, and I suspect a large quiet userbase, stuff just works fine, and I don&#x27;t think this side gets brought up nearly enough. And for people not actively using Python, it&#x27;s important to note that you don&#x27;t need a rube-goldberg setup like in TFA.
评论 #39915503 未加载
评论 #39916790 未加载
评论 #39917872 未加载
评论 #39917212 未加载
评论 #39915810 未加载
评论 #39916637 未加载
评论 #39921753 未加载
评论 #39917419 未加载
gorkaerana大约 1 年前
My Python virtual environment and dependency management journey has been the following:<p>1. Just `pip` and `venv`; specifying dependencies via &quot;requirements.txt&quot; and &quot;dev_requirements.txt&quot;, and tool configuration options in bespoke files. Too involved and with too many parts, yet it made do for my use cases.<p>2. `poetry` together with &quot;pyproject.toml&quot;. Big quality of life improvement: commands like `poetry add`, `poetry build` make the process much less involved so one can just focus on actual development. Having all of the tooling configuration in a single place (that being &quot;pyproject.toml&quot;) also helped with context switching.<p>3. `uv` for quick and dirty Python projects, `rye` (with the `uv` backend) for anything above that. In short, I think of `uv` and `rye` as faster siblings of `pip` and `poetry`, respectively. Once you get used to creating virtual and environments and installing dependencies in milliseconds or a few seconds it&#x27;s difficult to go back to it always taking many seconds.<p>In hindsight, I would have been content just using `poetry`, but `uv` and `rye` do make for a faster and hence better developer experience.<p>P.S.: how messed up is it that only now we are agreeing on a convention for putting a project’s virtual environment into an in-project directory called `.venv`?
评论 #39921730 未加载
评论 #39918640 未加载
stuaxo大约 1 年前
It&#x27;s funny how people seem to love this node style of a virtualenv in the project.<p>I much, much prefer virtualenvwrapper with it&#x27;s style of keeping the environment outside the project.<p>This way, I don&#x27;t end up with lots of huge directories hidden in the many many projects I check out.<p>The other thing that can&#x27;t happen is accidentally adding the folder to version control.<p>I can have various versions of my project checkout out, and use the same venv between them.<p>I can quickly fire up a venv for the project with a different version of python.<p>I can quickly list all my venvs, and prune them as needed.<p>While people may say &quot;we have infinite storage&quot; my laptop only has 2tb and I fill it up.<p>But each to their own, a lot of people seem to like it.<p>I also use direnv, and the the virtualenvwrapper plugin for zsh, and have defaults - in this case it automatically defaults to the virtualenv with the same name as the directory I enter, but I didn&#x27;t have to do any config for that to happen.
评论 #39915926 未加载
评论 #39916004 未加载
globular-toast大约 1 年前
Nice! I&#x27;ve recently discovered direnv too and can&#x27;t believe I&#x27;ve coped this long without it. I currently use virtualenvwrapper and direnv to activate those (I much prefer having the venv root outside of the project dirs; not everything respects gitignore files by default).<p>I didn&#x27;t know about uv and PDM. I use pip-tools and there has been some work to adapt it to support multiple Python interpreters. My main gripe is it can&#x27;t be installed once with pipx, for example, and just work. But it seems difficult. Perhaps uv suffers from the same problem. Interested to see how PDM deals with it.<p>&gt; While direnv has built-in support for the standard library’s venv module, it’s glacial. virtualenv is much faster, but uv is faster, still.<p>I&#x27;ve never been bothered by the speed of venv. It does what it needs to do in milliseconds and it&#x27;s not like I&#x27;m calling it that often. Why is the speed of it important?
marban大约 1 年前
I&#x27;m a simple man: pyenv virtualenv + poetry.
评论 #39917511 未加载
lagt_t大约 1 年前
I can&#x27;t believe people aren&#x27;t using devcontainers
评论 #39916567 未加载
评论 #39917786 未加载
评论 #39917312 未加载
Hackbraten大约 1 年前
&gt; I use different mechanisms to manage the virtual environments depending on whether I’m developing a *package* <i>without</i> strict pinning or an *application* <i>with</i> strict pinning.<p>I assume that by “package,” the author means library?
评论 #39916524 未加载
评论 #39916572 未加载
kingkongjaffa大约 1 年前
I tried poetry for the first time last night and it was honestly a breeze to get set up and felt much more full featured than pipping about with a requirements.txt