Replace deprecated pytoml with toml

epel9
Miro Hrončok 4 years ago
parent 468cb7f9d0
commit 2acc40875d

@ -0,0 +1,254 @@
From b81b1da55ef0f2768413669725d2874fcb0c29fb Mon Sep 17 00:00:00 2001
From: Kale Kundert <kale@thekunderts.net>
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/config.py | 2 +-
flit_core/flit_core/sdist.py | 2 +-
flit_core/flit_core/wheel.py | 2 +-
pyproject.toml | 2 +-
tests/test_init.py | 12 ++++++------
tests/test_tomlify.py | 4 ++--
tox.ini | 2 +-
12 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/doc/development.rst b/doc/development.rst
index 9b8dc5e..f714999 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 f9ddc7f..8d38bf9 100644
--- a/doc/pyproject_toml.rst
+++ b/doc/pyproject_toml.rst
@@ -120,7 +120,7 @@ Here's the full metadata section from flit itself:
"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/flit/init.py b/flit/init.py
index f7ea93a..b0c77c6 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 0c8db69..a9c9c60 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 .config 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 7daf67f..f3aaf7c 100644
--- a/flit_core/flit_core/build_thyself.py
+++ b/flit_core/flit_core/build_thyself.py
@@ -25,7 +25,7 @@
'summary': ('Distribution-building parts of Flit. '
'See flit package for more information'),
'requires_dist': [
- 'pytoml',
+ 'toml',
],
'requires_python': '>=3.4',
'classifiers': [
diff --git a/flit_core/flit_core/config.py b/flit_core/flit_core/config.py
index 0af9c00..6ed20d3 100644
--- a/flit_core/flit_core/config.py
+++ b/flit_core/flit_core/config.py
@@ -3,7 +3,7 @@
import logging
import os
import os.path as osp
-import pytoml as toml
+import toml
import re
log = logging.getLogger(__name__)
diff --git a/flit_core/flit_core/sdist.py b/flit_core/flit_core/sdist.py
index 1fe5bb4..963b4e5 100644
--- a/flit_core/flit_core/sdist.py
+++ b/flit_core/flit_core/sdist.py
@@ -95,7 +95,7 @@ def __init__(self, module, metadata, cfgdir, reqs_by_extra, entrypoints,
@classmethod
def from_ini_path(cls, ini_path: Path):
- # Local import so bootstrapping doesn't try to load pytoml
+ # Local import so bootstrapping doesn't try to load toml
from .config import read_flit_config
ini_info = read_flit_config(ini_path)
srcdir = ini_path.parent
diff --git a/flit_core/flit_core/wheel.py b/flit_core/flit_core/wheel.py
index 1550846..2bc55e1 100644
--- a/flit_core/flit_core/wheel.py
+++ b/flit_core/flit_core/wheel.py
@@ -83,7 +83,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 .config import read_flit_config
directory = ini_path.parent
ini_info = read_flit_config(ini_path)
diff --git a/pyproject.toml b/pyproject.toml
index ac8d001..0af74b2 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -11,7 +11,7 @@ requires=[
"flit_core>=3.0.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 fb8ad4d..7330ff5 100644
--- a/tests/test_init.py
+++ b/tests/test_init.py
@@ -6,7 +6,7 @@
from unittest.mock import patch
import pytest
-import pytoml
+import toml
from flit import init
@@ -107,7 +107,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'
@@ -131,7 +131,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 == {
@@ -154,7 +154,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',
@@ -176,7 +176,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 == {
@@ -216,7 +216,7 @@ def test_init_readme_found_yes_choosen():
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 == {
diff --git a/tests/test_tomlify.py b/tests/test_tomlify.py
index 2bd75dc..a7b7978 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 08ce1bf..d1025e1 100644
--- a/tox.ini
+++ b/tox.ini
@@ -18,7 +18,7 @@ deps =
testpath
responses
docutils
- pytoml
+ toml
pytest>=2.7.3
pytest-cov

@ -5,7 +5,7 @@
Name: python-%{srcname}
Version: 3.0.0
Release: 1%{?dist}
Release: 2%{?dist}
Summary: Simplified packaging of Python modules
# ./flit/logo.py under ASL 2.0 license
@ -18,6 +18,9 @@ Source0: https://github.com/takluyver/flit/archive/%{version}/%{srcname}-%{versi
# For the tests
Source1: https://pypi.org/pypi?%3Aaction=list_classifiers#/classifiers.lst
# Replace deprecated pytoml with toml, backported from upstream
Patch1: https://github.com/takluyver/flit/commit/b81b1da55e.patch
BuildArch: noarch
BuildRequires: python3-devel
BuildRequires: pyproject-rpm-macros
@ -25,7 +28,7 @@ BuildRequires: python3-pip
BuildRequires: python3-requests
BuildRequires: python3-docutils
BuildRequires: python3-pygments
BuildRequires: python3-pytoml
BuildRequires: python3-toml
%if %{with tests}
BuildRequires: /usr/bin/python
@ -81,7 +84,7 @@ at flit_core.buildapi.
%prep
%autosetup -n %{srcname}-%{version}
%autosetup -p1 -n %{srcname}-%{version}
%build
export FLIT_NO_NETWORK=1
@ -128,6 +131,9 @@ pytest-3
%changelog
* Thu Nov 19 2020 Miro Hrončok <mhroncok@redhat.com> - 3.0.0-2
- Replace deprecated pytoml with toml
* Mon Sep 21 2020 Tomas Hrnciar <thrnciar@redhat.com> - 3.0.0-1
- Update to 3.0.0

Loading…
Cancel
Save