From 83b968d66aba0d0c88784e5033fc48002cc7d1ec Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Fri, 2 Jul 2021 23:21:36 +0100 Subject: [PATCH 01/13] swap toml with tomli --- setup.py | 2 +- src/towncrier/_settings.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 91e839f2..5d52ec95 100644 --- a/setup.py +++ b/setup.py @@ -41,7 +41,7 @@ "Programming Language :: Python :: Implementation :: PyPy", ], use_incremental=True, - install_requires=["click", "click-default-group", "incremental", "jinja2", "setuptools", "toml"], + install_requires=["click", "click-default-group", "incremental", "jinja2", "setuptools", "tomli"], extras_require={"dev": ["packaging"]}, package_dir={"": "src"}, packages=find_packages("src"), diff --git a/src/towncrier/_settings.py b/src/towncrier/_settings.py index e1bdb2f5..8efd7072 100644 --- a/src/towncrier/_settings.py +++ b/src/towncrier/_settings.py @@ -3,7 +3,7 @@ import os import pkg_resources -import toml +import tomli from collections import OrderedDict @@ -69,8 +69,8 @@ def load_config(directory): def load_config_from_file(directory, config_file): - with open(config_file, "r") as conffile: - config = toml.load(conffile) + with open(config_file, "r", encoding="utf8") as conffile: + config = tomli.load(conffile) return parse_toml(directory, config) From 71060f3aa19cdefbf61b694c247b9da230847d4f Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Fri, 2 Jul 2021 23:30:21 +0100 Subject: [PATCH 02/13] drop py2.7 --- .github/workflows/ci.yml | 6 ------ setup.py | 4 ++-- tox.ini | 2 +- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8a2e89b2..419a5eea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,9 +67,6 @@ jobs: - name: Windows runs-on: windows-latest python: - - name: CPython 2.7 - tox: py27 - action: 2.7 - name: CPython 3.5 tox: py35 action: 3.5 @@ -85,9 +82,6 @@ jobs: - name: CPython 3.9 tox: py39 action: 3.9 - - name: PyPy 2.7 - tox: pypy27 - action: pypy-2.7 - name: PyPy 3.6 tox: pypy36 action: pypy-3.6 diff --git a/setup.py b/setup.py index 5d52ec95..347cb8e7 100644 --- a/setup.py +++ b/setup.py @@ -29,8 +29,7 @@ "Operating System :: POSIX :: Linux", "Operating System :: MacOS :: MacOS X", "Operating System :: Microsoft :: Windows", - "Programming Language :: Python :: 2", - "Programming Language :: Python :: 2.7", + "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", @@ -43,6 +42,7 @@ use_incremental=True, install_requires=["click", "click-default-group", "incremental", "jinja2", "setuptools", "tomli"], extras_require={"dev": ["packaging"]}, + requires_python=">=3.5", package_dir={"": "src"}, packages=find_packages("src"), license="MIT", diff --git a/tox.ini b/tox.ini index 073a8a45..fc1ac4b0 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = cov-erase, flake8, {pypy27,pypy36,pypy37,py27,py35,py36,py37,py38,py39}-{tests,flake8,check-manifest,check-newsfragment}, cov-report +envlist = cov-erase, flake8, {pypy36,pypy37,py35,py36,py37,py38,py39}-{tests,flake8,check-manifest,check-newsfragment}, cov-report isolated_build=true skip_missing_envs = true From 43ccc05bbeaaf5c094175da792c32f28796a2b81 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Wed, 7 Jul 2021 17:36:34 +0100 Subject: [PATCH 03/13] Update setup.py Co-authored-by: Taneli Hukkinen <3275109+hukkin@users.noreply.github.com> --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 347cb8e7..ec10a606 100644 --- a/setup.py +++ b/setup.py @@ -42,7 +42,7 @@ use_incremental=True, install_requires=["click", "click-default-group", "incremental", "jinja2", "setuptools", "tomli"], extras_require={"dev": ["packaging"]}, - requires_python=">=3.5", + python_requires=">=3.6", package_dir={"": "src"}, packages=find_packages("src"), license="MIT", From b06c863484ae7afc90b045e1a8ea0e4e1a17706c Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Wed, 7 Jul 2021 20:19:10 +0100 Subject: [PATCH 04/13] remove 3.5 ci build --- .github/workflows/ci.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 419a5eea..ccae3424 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,9 +67,6 @@ jobs: - name: Windows runs-on: windows-latest python: - - name: CPython 3.5 - tox: py35 - action: 3.5 - name: CPython 3.6 tox: py36 action: 3.6 From b611ed251ef438395579c8585c88b868765e7097 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Wed, 7 Jul 2021 20:20:22 +0100 Subject: [PATCH 05/13] Revert "remove 3.5 ci build" This reverts commit b06c863484ae7afc90b045e1a8ea0e4e1a17706c. --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ccae3424..419a5eea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,6 +67,9 @@ jobs: - name: Windows runs-on: windows-latest python: + - name: CPython 3.5 + tox: py35 + action: 3.5 - name: CPython 3.6 tox: py36 action: 3.6 From 462a20b3494565d21d07c58f2fb03236d3d3d4e7 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Wed, 7 Jul 2021 20:20:33 +0100 Subject: [PATCH 06/13] Revert "Update setup.py" This reverts commit 43ccc05bbeaaf5c094175da792c32f28796a2b81. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index ec10a606..347cb8e7 100644 --- a/setup.py +++ b/setup.py @@ -42,7 +42,7 @@ use_incremental=True, install_requires=["click", "click-default-group", "incremental", "jinja2", "setuptools", "tomli"], extras_require={"dev": ["packaging"]}, - python_requires=">=3.6", + requires_python=">=3.5", package_dir={"": "src"}, packages=find_packages("src"), license="MIT", From dbfb33ecf1cf1fea86ea6d413ae9c4036acd1b43 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Wed, 7 Jul 2021 20:20:43 +0100 Subject: [PATCH 07/13] Revert "drop py2.7" This reverts commit 71060f3aa19cdefbf61b694c247b9da230847d4f. --- .github/workflows/ci.yml | 6 ++++++ setup.py | 4 ++-- tox.ini | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 419a5eea..8a2e89b2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,6 +67,9 @@ jobs: - name: Windows runs-on: windows-latest python: + - name: CPython 2.7 + tox: py27 + action: 2.7 - name: CPython 3.5 tox: py35 action: 3.5 @@ -82,6 +85,9 @@ jobs: - name: CPython 3.9 tox: py39 action: 3.9 + - name: PyPy 2.7 + tox: pypy27 + action: pypy-2.7 - name: PyPy 3.6 tox: pypy36 action: pypy-3.6 diff --git a/setup.py b/setup.py index 347cb8e7..5d52ec95 100644 --- a/setup.py +++ b/setup.py @@ -29,7 +29,8 @@ "Operating System :: POSIX :: Linux", "Operating System :: MacOS :: MacOS X", "Operating System :: Microsoft :: Windows", - "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 2", + "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", @@ -42,7 +43,6 @@ use_incremental=True, install_requires=["click", "click-default-group", "incremental", "jinja2", "setuptools", "tomli"], extras_require={"dev": ["packaging"]}, - requires_python=">=3.5", package_dir={"": "src"}, packages=find_packages("src"), license="MIT", diff --git a/tox.ini b/tox.ini index fc1ac4b0..073a8a45 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = cov-erase, flake8, {pypy36,pypy37,py35,py36,py37,py38,py39}-{tests,flake8,check-manifest,check-newsfragment}, cov-report +envlist = cov-erase, flake8, {pypy27,pypy36,pypy37,py27,py35,py36,py37,py38,py39}-{tests,flake8,check-manifest,check-newsfragment}, cov-report isolated_build=true skip_missing_envs = true From 2e8986683e2cbf9f84f4691ad892823d5d8c6831 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Wed, 7 Jul 2021 20:25:06 +0100 Subject: [PATCH 08/13] use toml on py3.5- and tomli on py3.6+ --- setup.py | 10 +++++++++- src/towncrier/_settings.py | 10 ++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 5d52ec95..107ad145 100644 --- a/setup.py +++ b/setup.py @@ -41,7 +41,15 @@ "Programming Language :: Python :: Implementation :: PyPy", ], use_incremental=True, - install_requires=["click", "click-default-group", "incremental", "jinja2", "setuptools", "tomli"], + install_requires=[ + "click", + "click-default-group", + "incremental", + "jinja2", + "setuptools", + "toml; python_version < '3.6'", + "tomli; python_version > '3.5'", + ], extras_require={"dev": ["packaging"]}, package_dir={"": "src"}, packages=find_packages("src"), diff --git a/src/towncrier/_settings.py b/src/towncrier/_settings.py index 8efd7072..39f00c6e 100644 --- a/src/towncrier/_settings.py +++ b/src/towncrier/_settings.py @@ -1,9 +1,15 @@ # Copyright (c) Amber Brown, 2015 # See LICENSE for details. +import io import os +import sys import pkg_resources -import tomli + +if sys.version_info > (3, 5): + from tomli import load as _toml_load +else: + from toml import load as _toml_load from collections import OrderedDict @@ -70,7 +76,7 @@ def load_config(directory): def load_config_from_file(directory, config_file): with open(config_file, "r", encoding="utf8") as conffile: - config = tomli.load(conffile) + config = _toml_load(conffile) return parse_toml(directory, config) From 8a661adc18dc4f8ea11333ea2eeca9990afb8711 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Wed, 7 Jul 2021 20:25:47 +0100 Subject: [PATCH 09/13] Update setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 107ad145..da03c7b5 100644 --- a/setup.py +++ b/setup.py @@ -48,7 +48,7 @@ "jinja2", "setuptools", "toml; python_version < '3.6'", - "tomli; python_version > '3.5'", + "tomli; python_version > '3.6'", ], extras_require={"dev": ["packaging"]}, package_dir={"": "src"}, From f72c7a72adb68998424a0813e3e6efa547d433aa Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Wed, 7 Jul 2021 20:26:33 +0100 Subject: [PATCH 10/13] Update setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index da03c7b5..f5171e62 100644 --- a/setup.py +++ b/setup.py @@ -48,7 +48,7 @@ "jinja2", "setuptools", "toml; python_version < '3.6'", - "tomli; python_version > '3.6'", + "tomli; python_version >= '3.6'", ], extras_require={"dev": ["packaging"]}, package_dir={"": "src"}, From 4e2a76d6bfc24a9e8293bbd80cbb5281f405a530 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Wed, 7 Jul 2021 20:28:44 +0100 Subject: [PATCH 11/13] Update src/towncrier/_settings.py --- src/towncrier/_settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/towncrier/_settings.py b/src/towncrier/_settings.py index 39f00c6e..631bfedf 100644 --- a/src/towncrier/_settings.py +++ b/src/towncrier/_settings.py @@ -6,7 +6,7 @@ import sys import pkg_resources -if sys.version_info > (3, 5): +if sys.version_info >= (3, 6): from tomli import load as _toml_load else: from toml import load as _toml_load From 25178180e0dfca3454ac3c1de35e110c2b5c6c6e Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Wed, 7 Jul 2021 20:29:48 +0100 Subject: [PATCH 12/13] Update src/towncrier/_settings.py --- src/towncrier/_settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/towncrier/_settings.py b/src/towncrier/_settings.py index 631bfedf..07327c39 100644 --- a/src/towncrier/_settings.py +++ b/src/towncrier/_settings.py @@ -75,7 +75,7 @@ def load_config(directory): def load_config_from_file(directory, config_file): - with open(config_file, "r", encoding="utf8") as conffile: + with io.open(config_file, "r", encoding="utf8") as conffile: config = _toml_load(conffile) return parse_toml(directory, config) From 322d3eb80f76761e50d6c734ac82f4b70320a1e2 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Wed, 7 Jul 2021 21:47:52 +0100 Subject: [PATCH 13/13] Create 354.feature.rst --- src/towncrier/newsfragments/354.feature.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/towncrier/newsfragments/354.feature.rst diff --git a/src/towncrier/newsfragments/354.feature.rst b/src/towncrier/newsfragments/354.feature.rst new file mode 100644 index 00000000..c8831bef --- /dev/null +++ b/src/towncrier/newsfragments/354.feature.rst @@ -0,0 +1 @@ +Support Toml v1 syntax with tomli on Python 3.6+