Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pytoml is deprecated. Repalce with toml #255

Closed
sscherfke opened this issue Mar 14, 2019 · 14 comments · Fixed by #378
Closed

pytoml is deprecated. Repalce with toml #255

sscherfke opened this issue Mar 14, 2019 · 14 comments · Fixed by #378
Milestone

Comments

@sscherfke
Copy link

sscherfke commented Mar 14, 2019

Pytoml is no longer being maintained: https://github.com/avakar/pytoml
The author suggest switching to toml.

This seems to be straight forward:

 diff --git a/README.rst b/README.rst
index ce4a096..a17c884 100644
--- a/README.rst
+++ b/README.rst
@@ -75,7 +75,7 @@ To install the development version of Flit from Github::
 
     git clone https://github.com/takluyver/flit.git
     cd flit
-    python3 -m pip install docutils requests pytoml
+    python3 -m pip install docutils requests toml
     python3 -m flit install
 
 You may want to use the ``--symlink`` or ``--pth-file`` options so you can test
diff --git a/doc/pyproject_toml.rst b/doc/pyproject_toml.rst
index 9f8d4cc..04829e0 100644
--- a/doc/pyproject_toml.rst
+++ b/doc/pyproject_toml.rst
@@ -121,7 +121,7 @@ Here's the full metadata section from flit itself:
         "requests",
         "docutils",
         "requests_download",
-        "pytoml",
+        "toml",
     ]
     requires-python="3"
     description-file="README.rst"
diff --git a/flit/inifile.py b/flit/inifile.py
index 2c5b66d..35dc7dc 100644
--- a/flit/inifile.py
+++ b/flit/inifile.py
@@ -4,7 +4,7 @@ import logging
 import os
 from pathlib import Path
 
-import pytoml as toml
+import toml
 
 from .validate import validate_config
 from .vendorized.readme.rst import render
diff --git a/flit/init.py b/flit/init.py
index 2fc52ac..c1a9c1f 100644
--- a/flit/init.py
+++ b/flit/init.py
@@ -5,7 +5,7 @@ import os
 from pathlib import Path
 import re
 import sys
-import pytoml as toml
+import toml
 
 def get_data_dir():
     """Get the directory path for flit user data files.
diff --git a/flit/tomlify.py b/flit/tomlify.py
index 2bfe942..717ecfb 100644
--- a/flit/tomlify.py
+++ b/flit/tomlify.py
@@ -5,7 +5,7 @@ from collections import OrderedDict
 import configparser
 import os
 from pathlib import Path
-import pytoml
+import toml
 
 from .inifile import metadata_list_fields
 from .init import TEMPLATE
@@ -40,11 +40,11 @@ def convert(path):
 
     written_entrypoints = False
     with Path('pyproject.toml').open('w', encoding='utf-8') as f:
-        f.write(TEMPLATE.format(metadata=pytoml.dumps(metadata)))
+        f.write(TEMPLATE.format(metadata=toml.dumps(metadata)))
 
         if scripts:
             f.write('\n[tool.flit.scripts]\n')
-            pytoml.dump(scripts, f)
+            toml.dump(scripts, f)
 
         for groupname, group in entrypoints.items():
             if not dict(group):
@@ -53,7 +53,7 @@ def convert(path):
             if '.' in groupname:
                 groupname = '"{}"'.format(groupname)
             f.write('\n[tool.flit.entrypoints.{}]\n'.format(groupname))
-            pytoml.dump(OrderedDict(group), f)
+            toml.dump(OrderedDict(group), f)
             written_entrypoints = True
 
     print("Written 'pyproject.toml'")
diff --git a/pyproject.toml b/pyproject.toml
index ace3d65..635743d 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,5 +1,5 @@
 [build-system]
-requires = ["intreehooks", "requests", "docutils", "pytoml",
+requires = ["intreehooks", "requests", "docutils", "toml",
             "zipfile36; python_version in '3.3 3.4 3.5'",]
 build-backend = "intreehooks:loader"
 
@@ -13,7 +13,7 @@ author-email="thomas@kluyver.me.uk"
 home-page="https://github.com/takluyver/flit"
 requires=["requests",
     "docutils",
-    "pytoml",
+    "toml",
     "zipfile36; python_version in '3.3 3.4 3.5'",
 ]
 requires-python=">=3"
diff --git a/requirements-test.txt b/requirements-test.txt
index faf15ad..93710ea 100644
--- a/requirements-test.txt
+++ b/requirements-test.txt
@@ -4,6 +4,6 @@ testpath
 responses
 docutils
 zipfile36
-pytoml
+toml
 pytest>=2.7.3
 pytest-cov
diff --git a/tests/test_init.py b/tests/test_init.py
index 6d6fbe9..7e3989b 100644
--- a/tests/test_init.py
+++ b/tests/test_init.py
@@ -5,7 +5,7 @@ from tempfile import TemporaryDirectory
 from testpath import assert_isfile
 from unittest.mock import patch
 
-import pytoml
+import toml
 
 from flit import init
 
@@ -93,7 +93,7 @@ def test_init():
         generated = Path(td) / 'pyproject.toml'
         assert_isfile(generated)
         with generated.open() as f:
-            data = pytoml.load(f)
+            data = toml.load(f)
         assert data['tool']['flit']['metadata'][
                    'author-email'] == "test@example.com"
         license = Path(td) / 'LICENSE'
@@ -117,7 +117,7 @@ def test_init_homepage_and_license_are_optional():
         ti = init.TerminalIniter(td)
         ti.initialise()
         with Path(td, 'pyproject.toml').open() as f:
-            data = pytoml.load(f)
+            data = toml.load(f)
         assert not Path(td, 'LICENSE').exists()
     metadata = data['tool']['flit']['metadata']
     assert metadata == {
@@ -140,7 +140,7 @@ def test_init_homepage_validator():
         ti = init.TerminalIniter(td)
         ti.initialise()
         with Path(td, 'pyproject.toml').open() as f:
-            data = pytoml.load(f)
+            data = toml.load(f)
     metadata = data['tool']['flit']['metadata']
     assert metadata == {
         'author': 'Test Author',
diff --git a/tests/test_tomlify.py b/tests/test_tomlify.py
index 9a88fb2..fe8843b 100644
--- a/tests/test_tomlify.py
+++ b/tests/test_tomlify.py
@@ -1,6 +1,6 @@
 import os
 from pathlib import Path
-import pytoml
+import toml
 from shutil import copy
 from testpath import assert_isfile
 from testpath.tempdir import TemporaryWorkingDirectory
@@ -20,7 +20,7 @@ def test_tomlify():
         assert_isfile(pyproject_toml)
 
         with pyproject_toml.open(encoding='utf-8') as f:
-            content = pytoml.load(f)
+            content = toml.load(f)
 
         assert 'build-system' in content
         assert 'tool' in content

tox says: py36: commands succeeded 👍

@takluyver
Copy link
Member

When I compared these some time ago, I thought pytoml seemed significantly better structured, though I've no idea if that's still true. Pip also uses pytoml at present, and is considering switching to another library called tomlkit (pypa/pip#6136 pypa/pip#6120).

pytoml being unmaintained doesn't stop it working, so I'm not going to jump for any change straight away.

@AndydeCleyre
Copy link

Hi, just adding another voice to support sticking with whatever pip depends on, changing when pip changes, which will probably be to tomlkit.

Thanks for maintaining flit, btw!

@pradyunsg
Copy link
Member

pradyunsg commented Apr 14, 2020

FYI -- pip has now switched to using toml (pypa/pip#8045) although even that package isn't exactly in great shape in terms of maintenance (uiri/toml#267).

@dholth
Copy link
Member

dholth commented Apr 15, 2020

Strangely pytoml has had more maintenance than toml even after putting up the 'not maintained' flag.

I feel like packaging should adopt a toml library.

@pradyunsg
Copy link
Member

pradyunsg commented Apr 15, 2020

I'm personally invested enough to pick up maintenance of whichever package we all end up depending on.

@dholth
Copy link
Member

dholth commented Apr 15, 2020

👍 for tomlkit. It is even made for packaging (same author as Poetry).

@AndydeCleyre
Copy link

I don't know what the best choice is for flit, but I depend on tomlkit for a project of my own (where I inject fields and need comment preservation), and would selfishly be grateful if it got more attention and maintenance, as it's got some longstanding little bugs.

@dholth
Copy link
Member

dholth commented Apr 15, 2020

I chose pytoml for the same reason as @takluyver . Small, easy to understand. PyPA should adopt -> take over maintenance for a toml package. It's not like it is a fast moving or complicated standard.

@sscherfke
Copy link
Author

Toml seems to be used more widely, e.g., by

  • black
  • coverage
  • tornado
  • hypothesis
  • pipenv
  • requests
  • trio
  • dynaconf
  • box

https://libraries.io/pypi/toml/usage vs. https://libraries.io/pypi/tomlkit/usage

@dholth
Copy link
Member

dholth commented Apr 15, 2020 via email

@kitterma
Copy link
Contributor

kitterma commented May 2, 2020

FYI, pip switched to toml in the latest release.

@takluyver
Copy link
Member

Popularity isn't a great argument in general, but flit's needs for a toml parser are pretty small & standard, so I'm inclined to go with both the most popular, and the one that pip uses. Although the toml package hasn't had a release in over a year, which is a bit disconcerting.

I agree with @dholth's idea that PyPA adopt a TOML parser. I've started a discussion about it on Discourse: https://discuss.python.org/t/adopting-recommending-a-toml-parser/4068

@hroncok
Copy link

hroncok commented Jun 25, 2020

Hello. Fedora maintainer here, just wanted to pitch in. We would like to drop pytoml from Fedora and apparently, flit is the only thing we have that depends on it. Looking forward to see the result of the decision here as well as the PyPA decision.

@hugovk
Copy link
Contributor

hugovk commented Jun 25, 2020

3rd May:

Although the toml package hasn't had a release in over a year, which is a bit disconcerting.

TOML 0.10.1 was released on 14th May:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants