6 ms·
I recommend virtualenv and virtualenvwrapper. I usually set up a new venv like this: $ mkvirtualenv -a $(pwd) new_venv $ pip install -r requirements.txt When
by mkl95 6y ago
I recommend virtualenv and virtualenvwrapper. I usually set up a new venv like this:
$ mkvirtualenv -a $(pwd) new_venv
$ pip install -r requirements.txt
When you want to activate this env and cd to the directory where you created it, you can simply do:
$ workon new_venv
That's all you need to know. It just works.
- orf 6y agoHonestly just use poetry.
- sethammons 6y agoThis comment would be vastly more valuable (to me at least) if you said why. The parent’s workflow mirrors my own and doesn’t feel onerous. Being completely unfamiliar, their site says: > Poetry either uses your configured virtualenvs or creates its own to always be isolated from your system. So it is just a pretty wrapper? I’m missing the value add.
- curryst 6y agoOne value add is a reduced cognitive overhead. I don't have to remember where my virtualenv is; Poetry remembers for me. The "poetry run" command is extremely nice. You can do something like "poetry run pytest" and put that in a Makefile and be done. You don't have to worry about making sure you're in the virtualenv. I basically don't drop into a full shell anymore (although "poetry shell" lets you do that) because I don't like having to juggle whether I'm in a virtualenv or not. "poetry build" will build your project into tarballs that pip can install. It's not earth-shattering, but it's nice to have it one tool. The value add is a large number of QoL improvements. I don't think there are any features that other solutions can't compete on; Poetry just makes it easier to do the same things. I would highly suggest it for anything where other people are going to work on it, because of the QoL, but for personal projects I don't think it really matters.
- guitarbill 6y agothe venv management is a small aspect. pyproject.toml is nicer and saner than setup.py/requirements. easy example: dev dependencies in poetry. poetry's dependency resolver is great. can upload packages with poetry, twine not required (good for CI). works in fish shell, which virtualenvwrapper doesn't. lock files for deploying exactly the same dependency versions. those are the ones off the top of my head. use poetry, it's great.
- orf 6y agoSometimes you don’t realise how onerous things are until you find a better way. Poetry is that way. Handles dev dependencies, scripts, virtualenv management, upgrading single dependencies, has a lockfile, is super fast, is built on pyproject.toml, etc etc. Honestly, just use Poetry. At the very least it’s better than ad-hoc personal scripts built around manually managed virtualenvs.
- drcongo 6y agoDependency resolution is the biggest win with Poetry for me - everything everyone else has already said too, but the guarantee that it's only going to install versions of packages that are compatible with each other is fantastic for peace of mind. I can't imagine every using a requirements.txt again.
- mmcnl 6y agoDocumented workflow. Deterministic execution. pyproject.toml is part of the PEP spec, requirements.txt is just a convention. Explicit vs implicit.
- BiteCode_dev 6y agoPoetry shell doesn't work on windows, and it doesn't have named venv which matters for some users. Also it's very slow, require to be installed and use proprietary fields in pyproject.toml. It's a great tool but there are reasons you might want something else. Alternative like raw pip, pip tools, or dephell all have various pros and cons.
- 22c 6y ago>Poetry shell doesn't work on windows What do you mean it doesn't work? It works fine on Windows here, unless I am missing something.
- BiteCode_dev 6y agoI'm being overly critical. Let's say it has problems: - poetry shell didn't start the same shell that you were in: https://github.com/sarugaku/shellingham/issues/42 https://github.com/sarugaku/shellingham/issues/42. Looks like they fixed it 3 days ago though. - It doesn't set the name of the project in the prompt, so you actually don't know you are in the shell. Very annoying if you have many windows.
- 22c 6y ago>doesn't set the name of the project in the prompt I agree with you there, it's very annoying and I've fallen for it a few times. Having not used Poetry on other platforms yet (still using Pipenv in a few projects), I wasn't even aware that this was a feature.
- mmcnl 6y agoNot a solution, more a workaround, but on Windows I highly recommend developing using WSL, especially for Python. WSL + pyenv + poetry + VS Code with Remote WSL works amazingly well.