From ff4cfa98c07dc24381515adc9292ce5ab5dbf86e Mon Sep 17 00:00:00 2001 From: Kale Kundert Date: Sun, 2 Feb 2020 19:22:34 -0500 Subject: [PATCH] Replace 'pytoml' with 'toml'. The pytoml package is deprecated, and doesn't support the most recent TOML standard (e.g. dotted keys). --- doc/development.rst | 2 +- doc/pyproject_toml.rst | 2 +- flit/init.py | 2 +- flit/tomlify.py | 8 ++++---- flit_core/flit_core/build_thyself.py | 2 +- flit_core/flit_core/inifile.py | 2 +- flit_core/flit_core/sdist.py | 2 +- flit_core/flit_core/wheel.py | 2 +- pyproject.toml | 2 +- tests/test_init.py | 10 +++++----- tests/test_tomlify.py | 4 ++-- tox.ini | 2 +- 12 files changed, 20 insertions(+), 20 deletions(-) diff --git a/doc/development.rst b/doc/development.rst index 9b8dc5e7..f714999e 100644 --- a/doc/development.rst +++ b/doc/development.rst @@ -5,7 +5,7 @@ To get a development installation of Flit itself:: 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 bootstrap_dev.py This links Flit into the current Python environment, so you can make changes diff --git a/doc/pyproject_toml.rst b/doc/pyproject_toml.rst index 8da117c4..2646de81 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/init.py b/flit/init.py index f7483c14..eacff8cc 100644 --- a/flit/init.py +++ b/flit/init.py @@ -5,7 +5,7 @@ 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 2bfe9426..717ecfb9 100644 --- a/flit/tomlify.py +++ b/flit/tomlify.py @@ -5,7 +5,7 @@ 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/flit_core/flit_core/build_thyself.py b/flit_core/flit_core/build_thyself.py index 9724dd50..a235714d 100644 --- a/flit_core/flit_core/build_thyself.py +++ b/flit_core/flit_core/build_thyself.py @@ -24,7 +24,7 @@ 'summary': ('Distribution-building parts of Flit. ' 'See flit package for more information'), 'requires_dist': [ - 'pytoml', + 'toml', ], 'requires_python': '>=2.7, !=3.0, !=3.1, !=3.2, != 3.3', 'classifiers': [ diff --git a/flit_core/flit_core/inifile.py b/flit_core/flit_core/inifile.py index d2ed5ea6..f969104f 100644 --- a/flit_core/flit_core/inifile.py +++ b/flit_core/flit_core/inifile.py @@ -4,7 +4,7 @@ import logging import os import os.path as osp -import pytoml as toml +import toml import re import sys diff --git a/flit_core/flit_core/sdist.py b/flit_core/flit_core/sdist.py index d51774b3..389b1ffe 100644 --- a/flit_core/flit_core/sdist.py +++ b/flit_core/flit_core/sdist.py @@ -94,7 +94,7 @@ def __init__(self, module, metadata, cfgdir, reqs_by_extra, entrypoints, @classmethod def from_ini_path(cls, ini_path): - # Local import so bootstrapping doesn't try to load pytoml + # Local import so bootstrapping doesn't try to load toml from . import inifile ini_info = inifile.read_flit_config(ini_path) srcdir = osp.dirname(ini_path) diff --git a/flit_core/flit_core/wheel.py b/flit_core/flit_core/wheel.py index ff6f3a0e..c703655c 100644 --- a/flit_core/flit_core/wheel.py +++ b/flit_core/flit_core/wheel.py @@ -78,7 +78,7 @@ def __init__(self, directory, module, metadata, entrypoints, target_fp): @classmethod def from_ini_path(cls, ini_path, target_fp): - # Local import so bootstrapping doesn't try to load pytoml + # Local import so bootstrapping doesn't try to load toml from . import inifile directory = osp.dirname(ini_path) ini_info = inifile.read_flit_config(ini_path) diff --git a/pyproject.toml b/pyproject.toml index e3936728..6a902246 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,7 +11,7 @@ requires=[ "flit_core>=2.2.0", "requests", "docutils", - "pytoml", + "toml", "zipfile36; python_version in '3.3 3.4 3.5'", ] requires-python=">=3.5" diff --git a/tests/test_init.py b/tests/test_init.py index 75f7b614..4da4db73 100644 --- a/tests/test_init.py +++ b/tests/test_init.py @@ -5,7 +5,7 @@ from testpath import assert_isfile from unittest.mock import patch -import pytoml +import toml from flit import init @@ -106,7 +106,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' @@ -130,7 +130,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 == { @@ -153,7 +153,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', @@ -175,7 +175,7 @@ def test_author_email_field_is_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 == { diff --git a/tests/test_tomlify.py b/tests/test_tomlify.py index 2bb0bce5..6c5095f5 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 @@ -18,7 +18,7 @@ def test_tomlify(copy_sample, monkeypatch): 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 diff --git a/tox.ini b/tox.ini index 83c8f11a..c7fcc551 100644 --- a/tox.ini +++ b/tox.ini @@ -9,7 +9,7 @@ deps = testpath responses docutils - pytoml + toml pytest>=2.7.3 pytest-cov