Skip to content

pytoml is deprecated. Repalce with toml #255

@sscherfke

Description

@sscherfke

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 👍

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions