News for hackers. Stuff that matters.
Re:What the Heck Is Pyproject.toml? by chc on Wednesday April 01, 2020 @09:30PM (#22755398)
Poetry is...a little quirky. I've seen it go into infinite loops trying to resolve projects with, like, 10 dependencies. I'm not really sold on it being better than just making a virtualenv and pip installing.
Re:What the Heck Is Pyproject.toml? by jshen on Wednesday April 01, 2020 @09:40PM (#22755462)
How do other people replicate your venv? How does production replicate your venv?
Re:What the Heck Is Pyproject.toml? by kelnos on Thursday April 02, 2020 @01:25AM (#22756464)
You pin all your direct dependencies in requirements.txt, run "pip freeze >requirements-frozen.txt" to get a list of the versions of all dependencies (direct and transitive), and then you ship that.

Replicating is just "virtualenv --python=python3 venv && . ./venv/bin/activate && pip install -r requirements-frozen.txt". Am I missing something here? Yes, to be absolutely sure, you need to have the same versions of python, pip, setuptools, gcc (for C extensions), C library dependencies, etc. on both systems that do the build, but that's the case for pretty much any build system out there if you want repeatable builds.

And if you you just don't feel like dealing with that, you can just use Docker (aka "put my machine in a tarball and ship it").

Re:What the Heck Is Pyproject.toml? by globular-toast on Thursday April 02, 2020 @05:22AM (#22757387)
> You pin all your direct dependencies in requirements.txt, run "pip freeze >requirements-frozen.txt" to get a list of the versions of all dependencies (direct and transitive), and then you ship that.

What?! Seriously? That is not how it's supposed to work. Requirements.txt is already meant to be the frozen dependencies (like the output of pip freeze). Why change that? I much prefer how pip-tools does it with a new file, requirements.in that contains the unpinned direct dependencies. I thought poetry did the same thing but with pyproject.toml?

Re:What the Heck Is Pyproject.toml? by jshen on Thursday April 02, 2020 @02:06AM (#22756629)
This is worse than how it’s done on most modern languages.
Re:What the Heck Is Pyproject.toml? by viraptor on Thursday April 02, 2020 @05:26AM (#22757406)
Different commands, but it's pretty much the same in similar languages: Ruby uses bundler configuration instead of virtualenv and gemfiles lock instead of requirements.txt. JS uses npm/yarn and lockfie. Go uses go.mod and does a lot of assumptions instead of virtualenv. (these days, it was worse)

Modern languages do pretty much the same, just have a nicer wrapper for it.

Re:What the Heck Is Pyproject.toml? by jshen on Thursday April 02, 2020 @04:57PM (#22763736)
It's not "pretty much the same". Have a separation between Gemfile and Gemfile.lock is a huge improvement over just having requirements.txt. Having good, easy to use commands, that manages this stuff for your in a way that works well for the vast majority of use cases (i.e. bundler), is far better than the ill-defined, ad-hoc, mess that is requirements.txt management.
Re:What the Heck Is Pyproject.toml? by viraptor on Thursday April 02, 2020 @05:02PM (#22763796)
Gemfile-gemfile.lock is setup.py-requirements.txt.

And yes, as I said, a nice wrapper for management of it is missing in python. The main ideas/approach is the same though.

Re:What the Heck Is Pyproject.toml? by jshen on Thursday April 02, 2020 @05:56PM (#22764321)
It’s really not the same. Gemfile lists the direct dependencies of your project with variable specificity of explicit versions. Gemfile.lock lists all dependencies after resolving your direct dependencies and locks them to specific versions. requirements.txt is some bastardization of both of these combined, and setup.py is neither of these it’s for distribution of modules/packages which Ruby has as well, but it’s not your gemfile.

edit: also, how do you manage dev dependencies with requirements.txt and setup.py?

Re:What the Heck Is Pyproject.toml? by viraptor on Thursday April 02, 2020 @06:07PM (#22764397)
You can put dev deps in extras in their own "dev" block. Similar to how gemfile uses groups. Use requirements-dev.txt for them. Requirements for is a full list of dependencies after resolution and their exact versions. (as produced by freeze) The main difference is that requirements is "as installed in current configuration", while gemfile.lock is "for any groups configuration".

Again, not as polished experience, but the model matches.

Re:What the Heck Is Pyproject.toml? by jshen on Thursday April 02, 2020 @10:08PM (#22765775)
But it’s all ad hoc which is problematic. You’re solving it yourself, the tool isn’t solving it. It’s like saying that C is the same as python, you can just write your own garbage collector in C!
Re:What the Heck Is Pyproject.toml? by j88439h84 on Thursday April 02, 2020 @02:27AM (#22756715)
That's why we use Poetry.
Re:What the Heck Is Pyproject.toml? by jshen on Thursday April 02, 2020 @04:05PM (#22763127)
yeah, that's what i tried to use for a while too. The problem is that so much of the ecosystem doesn't use it, and the python community fails to converge on a solution here the way other language communities do.
Re:What the Heck Is Pyproject.toml? by chc on Thursday April 02, 2020 @01:13PM (#22761223)
Sorry, I was a little terse — obviously you're right that you're not going to ship the virtualenv itself. As other people have said, the intent was that you create a requirements file (and/or maybe a setup.py if you need that functionality). What I meant is that between fiddliness and sluggishness of Poetry, and the marginal hassle of maintaining a requirements file and creating your own virtualenvs, I'm not sure Poetry is the clear winner at the moment.
Re:What the Heck Is Pyproject.toml? by jshen on Thursday April 02, 2020 @04:31PM (#22763376)
Thanks. My main point is that bundler, maven (less so), and npm are all better than either venv/pip/reqruirements.txt or poetry. Additionally, it's also better that those language communities have mostly converged on those solutions.
Re:What the Heck Is Pyproject.toml? by takeda on Thursday April 02, 2020 @01:14AM (#22756406)
Create setup.cfg (it is better than setup.py, since it is declarative) listing immediate dependencies, use requires.txt as a lock file (I prefer to use pip-compile from pip-tools).
Re:What the Heck Is Pyproject.toml? by judge2020 on Wednesday April 01, 2020 @10:59PM (#22755866)
Pipenv still works for me with everything version pinned.
Re:What the Heck Is Pyproject.toml? by j88439h84 on Thursday April 02, 2020 @12:32AM (#22756218)
That will probably be solved by the new pip resolver within the next few months.
Re:What the Heck Is Pyproject.toml? by web007 on Thursday April 02, 2020 @02:00AM (#22756595)
Did that new resolver finally happen?

The pip SAT-based solver was supposed to land in 2017 or 2018 after a GSoC, and nothing came of it. Is it finally going to use a different heuristic than "#yolo" for picking which version of dependencies to install?

Re:What the Heck Is Pyproject.toml? by j88439h84 on Thursday April 02, 2020 @02:26AM (#22756712)