News for hackers. Stuff that matters.
Re:What the Heck Is Pyproject.toml? by j88439h84 on Wednesday April 01, 2020 @06:55PM (#22754365)
Poetry is a modern packaging system for Python. It's really good. I hope everyone converges on it.

http://python-poetry.org/

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)
Re:What the Heck Is Pyproject.toml? by BiteCode_dev on Thursday April 02, 2020 @03:54AM (#22757042)
Unfortunately, you need to:

- discover it

- install it properly

- run it properly

- make it create a venv with the proper python version

- potentially import data from existing setup.py/cfg

- make sure you are always in the right dir when you use it

- not be on windows (poetry shell doesn't work there)

- IDE integration is not great

- people have to chose between this, pip, pip-tools, flit, pipenv, dephell, conda...

And you cannot use it if you are not "in a project". But not all venv are project related.

Re:What the Heck Is Pyproject.toml? by j88439h84 on Thursday April 02, 2020 @05:56AM (#22757515)
> - not be on windows (poetry shell doesn't work there)

Ok that's a bug, probably fixed soon. Otherwise, most of these are true of many popular packaging tools in other languages.

Re:What the Heck Is Pyproject.toml? by BiteCode_dev on Thursday April 02, 2020 @06:00AM (#22757527)
Well, not pip and venv. It's provided on windows and mac automatically. venv forces you to chose the version of python. venv doesn't care if you are in project mode or not. IDE integration is great.
Re:What the Heck Is Pyproject.toml? by kitanata on Wednesday April 01, 2020 @11:46PM (#22756031)
We've recently standardized on using Poetry at JP Morgan Chase for projects in our Organization. We're betting on it becoming a standardized tool everywhere.
Re:What the Heck Is Pyproject.toml? by xzel on Wednesday April 01, 2020 @07:16PM (#22754575)
I just started up a project using this. It’s pretty good so far. The documentation on common tasks is a little bit lacking. VS Code integration is sort of broken in a few random ways (for example if I try and do a find all function definition it just hangs). I also wish there was a npm style script section in the definitions. I do think it really just works though and I think it’s a great solution compared to requirements.txt.
Re:What the Heck Is Pyproject.toml? by skrtskrt on Wednesday April 01, 2020 @08:16PM (#22754969)
I echo the sentiments about documentation. It works great but they really need to verbosely document every command option and usage. They seem like they’re trying so hard to keep the website clean and minimal, but docs are not the place for that.
Re:What the Heck Is Pyproject.toml? by j88439h84 on Wednesday April 01, 2020 @07:28PM (#22754642)
> I also wish there was a npm style script section in the definitions.

Is that like [tool.poetry.scripts] ?

Re:What the Heck Is Pyproject.toml? by xzel on Thursday April 02, 2020 @02:38AM (#22756756)
I don't think so. From their docs: > This section describe the scripts or executable that will be installed when installing the package

I want something such that I can run `poetry run script_name` and it will run that command line in the poetry context. Right now I either rely on my bash history or use a bash script to mimic the behavior of npm / yarn scripts. I want to turn this `poetry run python project_name/main.py` into an alias like `poetry run main` or `poetry run dev`.

Re:What the Heck Is Pyproject.toml? by j88439h84 on Friday April 03, 2020 @07:56PM (#22775053)
That's what tool.poetry.scripts does.
Re:What the Heck Is Pyproject.toml? by xzel on Saturday April 04, 2020 @02:48PM (#22780496)
O thats great. So just weirdly worded on the docs / I didn't understand. Thanks!
Re:What the Heck Is Pyproject.toml? by altoidaltoid on Wednesday April 01, 2020 @07:58PM (#22754857)
Where is that XKCD about new standards...

Ah yes: https://xkcd.com/927/

Re:What the Heck Is Pyproject.toml? by judge2020 on Wednesday April 01, 2020 @11:00PM (#22755869)
Re:What the Heck Is Pyproject.toml? by jacobush on Thursday April 02, 2020 @06:14AM (#22757582)
Anything with Easy or Simple in its name, isn’t.

SNMP