Adding a toml module to the standard lib?
Hi, I'd like to discuss the idea to add a module to parse TOML [toml-lang] to Python's standard library. PEP-0518 -- Specifying Minimum Build System Requirements for Python Projects [pep] suggests to store build system dependencies in `pyproject.toml`, yet Python itself does not support this format. Various packaging related projects like pip and pipenv already support PEP-0518 and vendored one of the existing TOML libraries in order to read `pyproject.toml` files. Besides that, TOML seems a better alternative to .cfg/.ini, .json -- both of which are already supported by Python's standard lib and parsing/dumping TOML properly is tricky enough to solve it properly [requirements]. There are a couple of TOML implementations out there [toml, pytoml, tomlkit] and one would have to find out which one to prefer and migrate into the stdlib. If the result of this discussion is leaning towards adding TOML, I'd volunteer to do it. This includes: coordinating with the maintainer of the chosen library, writing the PEP (hopefully with some help) and maintain the module for at least two years. Cheers, Bastian [toml-lang]: https://github.com/toml-lang/toml [pep]: https://www.python.org/dev/peps/pep-0518 [pip]: https://github.com/pypa/pip [pipenv]: https://github.com/pypa/pipenv [toml]: https://github.com/uiri/toml [pytoml]: https://github.com/avakar/pytoml [tomlkit]: https://github.com/sdispater/tomlkit [requirements]: https://devguide.python.org/stdlibchanges/#requirements -- Dr. Bastian Venthur http://venthur.de Debian Developer venthur at debian org
On Wed, 15 May 2019 10:44:35 +0200 Bastian Venthur <venthur@debian.org> wrote:
Hi,
I'd like to discuss the idea to add a module to parse TOML [toml-lang] to Python's standard library.
How stable is the TOML format? Is it bound to change significantly in the coming years? If the format is stable enough, then I think it's a good idea. Regards Antoine.
On 15.05.19 11:33, Antoine Pitrou wrote:
How stable is the TOML format? Is it bound to change significantly in the coming years?
If the format is stable enough, then I think it's a good idea.
The last update to the spec [1] was 10 months ago and added a few features. The version before that was stable for more than 3 years. It is also worth noting that he writes about the current version [2]: "As of version 0.5.0, TOML should be considered extremely stable. The goal is for version 1.0.0 to be backwards compatible (as much as humanly possible) with version 0.5.0. All implementations are strongly encouraged to become 0.5.0 compatible so that the transition to 1.0.0 will be simple when that happens." That is of course no guarantee, but maybe the best we can hope for. Cheers, Bastian [1]: https://github.com/toml-lang/toml/releases [2]: https://github.com/toml-lang/toml -- Dr. Bastian Venthur http://venthur.de Debian Developer venthur at debian org
On Wed, 15 May 2019 at 11:49, Bastian Venthur <venthur@debian.org> wrote:
On 15.05.19 11:33, Antoine Pitrou wrote:
How stable is the TOML format? Is it bound to change significantly in the coming years?
If the format is stable enough, then I think it's a good idea.
The last update to the spec [1] was 10 months ago and added a few features. The version before that was stable for more than 3 years. It is also worth noting that he writes about the current version [2]:
I think it's a good idea too - the analysis in PEP 518 concluded that TOML was, while maybe not perfect, certainly a good general purpose config file format, and I think that analysis is applicable in other contexts as well. While "easy to install/vendor" was a point in the analysis, I think having TOML support in the stdlib would be useful for simple scripts/applications looking for a good "out of the box" config solution. Paul
On Wed, May 15, 2019 at 10:44:35AM +0200, Bastian Venthur wrote:
Hi,
I'd like to discuss the idea to add a module to parse TOML [toml-lang] to Python's standard library.
You ought to read this thread here: https://mail.python.org/pipermail/python-ideas/2018-October/054101.html It isn't very long (only about a dozen or so quite short posts) but you probably ought to be at least familiar with it, and if possibly respond to any opposing comments. Thanks, -- Steven
On Wed, May 15, 2019 at 09:35:16PM +1000, Steven D'Aprano wrote:
It isn't very long (only about a dozen or so quite short posts) but you probably ought to be at least familiar with it, and if possibly respond to any opposing comments.
Sorry, to clarify, I don't mean respond on the Python-Ideas thread. I think it is sufficient to keep the current discussion here. -- Steven
H Bastian, IMHO we should wait until the format reach version 1.0, since the stdlib has a slow release cycle (one release every 18 months). Too slow for a "fast moving" standard. In the meanwhile, I'm sure setuptools and pip will manage to install a toml parser/generator for their needs, as they already do :-) Victor Le mer. 15 mai 2019 à 12:50, Bastian Venthur <venthur@debian.org> a écrit :
On 15.05.19 11:33, Antoine Pitrou wrote:
How stable is the TOML format? Is it bound to change significantly in the coming years?
If the format is stable enough, then I think it's a good idea.
The last update to the spec [1] was 10 months ago and added a few features. The version before that was stable for more than 3 years. It is also worth noting that he writes about the current version [2]:
"As of version 0.5.0, TOML should be considered extremely stable. The goal is for version 1.0.0 to be backwards compatible (as much as humanly possible) with version 0.5.0. All implementations are strongly encouraged to become 0.5.0 compatible so that the transition to 1.0.0 will be simple when that happens."
That is of course no guarantee, but maybe the best we can hope for.
Cheers,
Bastian
[1]: https://github.com/toml-lang/toml/releases [2]: https://github.com/toml-lang/toml
-- Dr. Bastian Venthur http://venthur.de Debian Developer venthur at debian org
_______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/vstinner%40redhat.com
-- Night gathers, and now my watch begins. It shall not end until my death.
As someone involved in the packaging side of this, I think while we'd eventually /appreciate/ a TOML parser in the standard library, I agree with Victor that there's no rush, for two reasons: 1. setuptools and pip have a decent number of dependencies that we vendor /anyway/, so vendoring one more is not a big deal. 2. We will be supporting older versions of Python for some time to come, so we'd need to vendor a TOML-parser backport for several years before we could actually use the one in the standard library. I think /if/ a 1.0 version of the spec is going to be forthcoming (not clear from the issue requesting it: https://github.com/toml-lang/toml/issues/515 ), then it's worth waiting at least a bit longer for it. I also think it's probably worth asking the current maintainers of TOML-parsing libraries if /they/ think it's time to adopt/adapt one of their libraries for use in the standard library. They probably have a better perspective on the stability and maturity of their codebases. Best, Paul On 5/15/19 8:39 AM, Victor Stinner wrote:
H Bastian,
IMHO we should wait until the format reach version 1.0, since the stdlib has a slow release cycle (one release every 18 months). Too slow for a "fast moving" standard.
In the meanwhile, I'm sure setuptools and pip will manage to install a toml parser/generator for their needs, as they already do :-)
Victor
Le mer. 15 mai 2019 à 12:50, Bastian Venthur <venthur@debian.org> a écrit :
On 15.05.19 11:33, Antoine Pitrou wrote:
How stable is the TOML format? Is it bound to change significantly in the coming years?
If the format is stable enough, then I think it's a good idea.
The last update to the spec [1] was 10 months ago and added a few features. The version before that was stable for more than 3 years. It is also worth noting that he writes about the current version [2]:
"As of version 0.5.0, TOML should be considered extremely stable. The goal is for version 1.0.0 to be backwards compatible (as much as humanly possible) with version 0.5.0. All implementations are strongly encouraged to become 0.5.0 compatible so that the transition to 1.0.0 will be simple when that happens."
That is of course no guarantee, but maybe the best we can hope for.
Cheers,
Bastian
[1]: https://github.com/toml-lang/toml/releases [2]: https://github.com/toml-lang/toml
-- Dr. Bastian Venthur http://venthur.de Debian Developer venthur at debian org
_______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/vstinner%40redhat.com
It appears that Julia has decided that the TOML spec is stable enough to include a parser in the standard library: https://github.com/JuliaLang/Pkg.jl/issues/1011 I've had good experiences with the `toml` Package for Python: https://github.com/uiri/toml.git It has an MIT license. The TOML specification site includes tests: https://github.com/toml-lang/toml/tree/master/tests fwiw, Alan Isaac
Specifically the work to reach 1.0 is tracked in https://github.com/toml-lang/toml/projects/1 and I too think we should wait until 1.0 comes out for the exact reasons Victor laid out. I will also mention that https://github.com/pradyunsg who is a core dev of pip and very active PyPA member is one of the maintainers of TOML. So I'm sure he will let us know when things reach 1.0 and also wouldn't mind some help reaching 1.0 as well. :)
participants (8)
-
Alan Isaac
-
Antoine Pitrou
-
Bastian Venthur
-
Brett Cannon
-
Paul Ganssle
-
Paul Moore
-
Steven D'Aprano
-
Victor Stinner