Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] [RFC] Support for PEP517 build systems in python3-module
@ 2020-12-02 16:00 ahesford
  2020-12-02 17:45 ` [PR REVIEW] " ericonr
                   ` (21 more replies)
  0 siblings, 22 replies; 23+ messages in thread
From: ahesford @ 2020-12-02 16:00 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 2534 bytes --]

There is a new pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages packaging
https://github.com/void-linux/void-packages/pull/26883

[RFC] Support for PEP517 build systems in python3-module
I [have been told](https://github.com/pypa/packaging/issues/363) that PEP517 build systems are the way of the future for Python package building and installation, and `setuptools` will become (or is now) disfavored. `python3-packaging` is the first of our packages to drop `setuptools` and specifically require a PEP517 builder.

This is an attempt to support PEP517 builds in our `python3-module` build style. For now, the preferred (only?) way to do PEP517 builds is to rely on `pip` to do the work. Fortunately, because no PEP517 builder supports compiled extensions, we can avoid the pain of trying to force `pip` to behave with cross compilers (for now).

Use of the PEP517 build procedure in a template is enabled by setting `python_pep517=yes`. If this is adopted, we'll have to modify `xlint` as well.

`pip` can do a one-pass build and install, but I figured it was better to split into a build-wheel stage and an install-wheel stage so people can do `./xbps-src build` and investigate the artifacts.

I am not thrilled with the use of globs in `do_install` when setting a default `$python_pep517_wheel` but, according to [PEP 427](https://www.python.org/dev/peps/pep-0427/#file-name-convention) and its referenced [PEP 425](https://www.python.org/dev/peps/pep-0425), the filename components I'm trying to match with the globs are not easily predicted. In any case, if this produces undesirable behavior in specific templates, the author can manually set that variable. Any other ideas are welcome.

Finally, the build process produces `direct_url.json` in the Python `dist-info` directory to comply with [PEP 610](https://www.python.org/dev/peps/pep-0610), which replaces a simple version number in `pip freeze` output with a `file://` URL pointing to the location of the wheel used for installation. (In our case, this will be `/builddir/$wrksrc/$build_wrksrc/$python_pep517_wheel`.) For distribution packages, I do not believe this is desirable. We can manually remove the file, for example in `do_install`, assuming the `dist-info` directory is predictable. Comments about doing this are welcome.

cc: any @void-linux/pkg-committers with a stake in Python packages

A patch file from https://github.com/void-linux/void-packages/pull/26883.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-packaging-26883.patch --]
[-- Type: text/x-diff, Size: 16333 bytes --]

From 1d9efef93d8d8618a5e31674998b85d01b7d638e Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Wed, 2 Dec 2020 10:30:13 -0500
Subject: [PATCH 1/3] build-style/python3-module: add support for PEP517 build
 systems

---
 common/build-style/python3-module.sh          | 23 +++++++++++++++++--
 .../environment/build-style/python3-module.sh |  4 ++++
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/common/build-style/python3-module.sh b/common/build-style/python3-module.sh
index db56feb5e0e..14943d69356 100644
--- a/common/build-style/python3-module.sh
+++ b/common/build-style/python3-module.sh
@@ -3,7 +3,13 @@
 #
 
 do_build() {
-	if [ -n "$CROSS_BUILD" ]; then
+	if [ -n "$python_pep517" ]; then
+		# No PEP517 build tool currently supports compiled extensions
+		# Thus, there is no need to accommodate cross compilation here
+		mkdir -p build dist
+		TMPDIR=build python3 -m pip wheel --no-deps \
+			--no-build-isolation --no-clean ${make_build_args} .
+	elif [ -n "$CROSS_BUILD" ]; then
 		PYPREFIX="$XBPS_CROSS_BASE"
 		CFLAGS+=" -I${XBPS_CROSS_BASE}/${py3_inc} -I${XBPS_CROSS_BASE}/usr/include"
 		LDFLAGS+=" -L${XBPS_CROSS_BASE}/${py3_lib} -L${XBPS_CROSS_BASE}/usr/lib"
@@ -24,6 +30,11 @@ do_build() {
 }
 
 do_check() {
+	if [ -n "$python_pep517" ]; then
+		msg_warn "No standard test exists for PEP517 Python templates"
+		return 0
+	fi
+
 	if [ -z "$make_check_target" ]; then
 		if ! python3 setup.py --help test >/dev/null 2>&1; then
 			msg_warn "No command 'test' defined by setup.py.\n"
@@ -36,7 +47,15 @@ do_check() {
 }
 
 do_install() {
-	if [ -n "$CROSS_BUILD" ]; then
+	if [ -n "$python_pep517" ]; then
+		# No PEP517 build tool currently supports compiled extensions
+		# Thus, there is no need to accommodate cross compilation here
+		: ${python_pep517_wheel:=${pkgname#python3-}-${version}-*-*-*.whl}
+
+		TMPDIR=build python3 -m pip install --prefix /usr \
+			--root ${DESTDIR} --no-deps --no-build-isolation \
+			--no-clean ${make_install_args} ${python_pep517_wheel}
+	elif [ -n "$CROSS_BUILD" ]; then
 		PYPREFIX="$XBPS_CROSS_BASE"
 		CFLAGS+=" -I${XBPS_CROSS_BASE}/${py3_inc} -I${XBPS_CROSS_BASE}/usr/include"
 		LDFLAGS+=" -L${XBPS_CROSS_BASE}/${py3_lib} -L${XBPS_CROSS_BASE}/usr/lib"
diff --git a/common/environment/build-style/python3-module.sh b/common/environment/build-style/python3-module.sh
index 56471fe88bc..9bc04e6811e 100644
--- a/common/environment/build-style/python3-module.sh
+++ b/common/environment/build-style/python3-module.sh
@@ -1,2 +1,6 @@
 lib32disabled=yes
 makedepends+=" python3"
+
+if [ -n "$python_pep517" ]; then
+	hostmakedepends+=" python3-pip"
+fi

From af70857ed22213b1a51184a063c9af3246f8370c Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Wed, 2 Dec 2020 08:08:33 -0500
Subject: [PATCH 2/3] New package: python3-flit_core-3.0.0

---
 .../python3-flit_core/patches/use_toml.patch  | 254 ++++++++++++++++++
 srcpkgs/python3-flit_core/template            |  24 ++
 2 files changed, 278 insertions(+)
 create mode 100644 srcpkgs/python3-flit_core/patches/use_toml.patch
 create mode 100644 srcpkgs/python3-flit_core/template

diff --git a/srcpkgs/python3-flit_core/patches/use_toml.patch b/srcpkgs/python3-flit_core/patches/use_toml.patch
new file mode 100644
index 00000000000..8a0a668f616
--- /dev/null
+++ b/srcpkgs/python3-flit_core/patches/use_toml.patch
@@ -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 doc/development.rst doc/development.rst
+index 9b8dc5e..f714999 100644
+--- doc/development.rst
++++ 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 doc/pyproject_toml.rst doc/pyproject_toml.rst
+index f9ddc7f..8d38bf9 100644
+--- doc/pyproject_toml.rst
++++ 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 flit/init.py flit/init.py
+index f7ea93a..b0c77c6 100644
+--- flit/init.py
++++ 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 flit/tomlify.py flit/tomlify.py
+index 0c8db69..a9c9c60 100644
+--- flit/tomlify.py
++++ 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 flit_core/flit_core/build_thyself.py flit_core/flit_core/build_thyself.py
+index 7daf67f..f3aaf7c 100644
+--- flit_core/flit_core/build_thyself.py
++++ 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 flit_core/flit_core/config.py flit_core/flit_core/config.py
+index 0af9c00..6ed20d3 100644
+--- flit_core/flit_core/config.py
++++ 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 flit_core/flit_core/sdist.py flit_core/flit_core/sdist.py
+index 1fe5bb4..963b4e5 100644
+--- flit_core/flit_core/sdist.py
++++ 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 flit_core/flit_core/wheel.py flit_core/flit_core/wheel.py
+index 1550846..2bc55e1 100644
+--- flit_core/flit_core/wheel.py
++++ 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 pyproject.toml pyproject.toml
+index ac8d001..0af74b2 100644
+--- pyproject.toml
++++ 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 tests/test_init.py tests/test_init.py
+index fb8ad4d..7330ff5 100644
+--- tests/test_init.py
++++ 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 tests/test_tomlify.py tests/test_tomlify.py
+index 2bd75dc..a7b7978 100644
+--- tests/test_tomlify.py
++++ 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 tox.ini tox.ini
+index 08ce1bf..d1025e1 100644
+--- tox.ini
++++ tox.ini
+@@ -18,7 +18,7 @@ deps =
+     testpath
+     responses
+     docutils
+-    pytoml
++    toml
+     pytest>=2.7.3
+     pytest-cov
+ 
diff --git a/srcpkgs/python3-flit_core/template b/srcpkgs/python3-flit_core/template
new file mode 100644
index 00000000000..f08ceb41806
--- /dev/null
+++ b/srcpkgs/python3-flit_core/template
@@ -0,0 +1,24 @@
+# Template file for 'python3-flit_core'
+pkgname=python3-flit_core
+version=3.0.0
+revision=1
+wrksrc="flit-${version}"
+build_wrksrc="flit_core"
+build_style=python3-module
+python_pep517="yes"
+depends="python3-toml"
+short_desc="Simplified packaging of Python modules - PEP 517 build backend"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="BSD-3-Clause"
+homepage="https://flit.readthedocs.io"
+changelog="https://flit.readthedocs.io/en/latest/history.html"
+distfiles="${PYPI_SITE}/f/flit/flit-${version}.tar.gz"
+checksum=b4fe0f84a1ffbf125d003e253ec98c0b6e3e31290b31fba3ad22d28588c20893
+
+do_check() {
+	: provides no tests
+}
+
+post_install() {
+	vlicense ../LICENSE
+}

From d1322149fdbeff46a7ca0d911f684c9f75ba1ba2 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Wed, 2 Dec 2020 10:28:38 -0500
Subject: [PATCH 3/3] python-packaging: split package

New package: python3-packaging-20.7
---
 srcpkgs/python-packaging/template  | 20 +++++---------------
 srcpkgs/python-packaging/update    |  1 +
 srcpkgs/python3-packaging          |  1 -
 srcpkgs/python3-packaging/template | 25 +++++++++++++++++++++++++
 4 files changed, 31 insertions(+), 16 deletions(-)
 create mode 100644 srcpkgs/python-packaging/update
 delete mode 120000 srcpkgs/python3-packaging
 create mode 100644 srcpkgs/python3-packaging/template

diff --git a/srcpkgs/python-packaging/template b/srcpkgs/python-packaging/template
index e36a04a1540..aa1f64182d7 100644
--- a/srcpkgs/python-packaging/template
+++ b/srcpkgs/python-packaging/template
@@ -1,29 +1,19 @@
 # Template file for 'python-packaging'
 pkgname=python-packaging
 version=20.4
-revision=1
+revision=2
 wrksrc="packaging-${version}"
-build_style=python-module
-pycompile_module="packaging"
-hostmakedepends="python-setuptools python3-setuptools"
-depends="python-attrs python-parsing python-six"
+build_style=python2-module
+hostmakedepends="python-setuptools"
+depends="python-parsing python-six"
 short_desc="Core utilities for Python packages (Python2)"
 maintainer="Alessio Sergi <al3hex@gmail.com>"
 license="Apache-2.0, BSD-2-Clause"
 homepage="https://github.com/pypa/packaging"
+changelog="https://raw.githubusercontent.com/pypa/packaging/master/CHANGELOG.rst"
 distfiles="${PYPI_SITE}/p/packaging/packaging-${version}.tar.gz"
 checksum=4357f74f47b9c12db93624a82154e9b120fa8293699949152b22065d556079f8
 
 post_install() {
 	vlicense LICENSE
 }
-
-python3-packaging_package() {
-	pycompile_module="packaging"
-	depends="python3-attrs python3-parsing python3-six"
-	short_desc="${short_desc/Python2/Python3}"
-	pkg_install() {
-		vmove usr/lib/python3*
-		vlicense LICENSE
-	}
-}
diff --git a/srcpkgs/python-packaging/update b/srcpkgs/python-packaging/update
new file mode 100644
index 00000000000..f3300f258a6
--- /dev/null
+++ b/srcpkgs/python-packaging/update
@@ -0,0 +1 @@
+pattern="packaging-\K20\.4(\.[0-9.]+)?(?=.tar.gz)"
diff --git a/srcpkgs/python3-packaging b/srcpkgs/python3-packaging
deleted file mode 120000
index 98299fdb1d7..00000000000
--- a/srcpkgs/python3-packaging
+++ /dev/null
@@ -1 +0,0 @@
-python-packaging
\ No newline at end of file
diff --git a/srcpkgs/python3-packaging/template b/srcpkgs/python3-packaging/template
new file mode 100644
index 00000000000..7be1238d7a2
--- /dev/null
+++ b/srcpkgs/python3-packaging/template
@@ -0,0 +1,25 @@
+# Template file for 'python3-packaging'
+pkgname=python3-packaging
+version=20.7
+revision=1
+wrksrc="packaging-${version}"
+build_style=python3-module
+python_pep517=yes
+hostmakedepends="python3-flit_core"
+depends="python3-parsing"
+checkdepends="python3-pytest"
+short_desc="Core utilities for Python packages (Python3)"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="Apache-2.0, BSD-2-Clause"
+homepage="https://github.com/pypa/packaging"
+checksum=05af3bb85d320377db281cf254ab050e1a7ebcbf5410685a9a407e18a1f81236
+distfiles="${PYPI_SITE}/p/packaging/packaging-${version}.tar.gz"
+checksum=05af3bb85d320377db281cf254ab050e1a7ebcbf5410685a9a407e18a1f81236
+
+do_check() {
+	: provides no tests
+}
+
+post_install() {
+	vlicense LICENSE
+}

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PR REVIEW] [RFC] Support for PEP517 build systems in python3-module
  2020-12-02 16:00 [PR PATCH] [RFC] Support for PEP517 build systems in python3-module ahesford
@ 2020-12-02 17:45 ` ericonr
  2020-12-02 19:02 ` [PR PATCH] [Updated] " ahesford
                   ` (20 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: ericonr @ 2020-12-02 17:45 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 273 bytes --]

New review comment by ericonr on void-packages repository

https://github.com/void-linux/void-packages/pull/26883#discussion_r534361318

Comment:
We could try adding the `pytest` option to `do_check`, what do you think?

`if command -v pytest >/dev/null; then \n pytest`

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PR PATCH] [Updated] [RFC] Support for PEP517 build systems in python3-module
  2020-12-02 16:00 [PR PATCH] [RFC] Support for PEP517 build systems in python3-module ahesford
  2020-12-02 17:45 ` [PR REVIEW] " ericonr
@ 2020-12-02 19:02 ` ahesford
  2020-12-02 19:06 ` [PR REVIEW] " ahesford
                   ` (19 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: ahesford @ 2020-12-02 19:02 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 2539 bytes --]

There is an updated pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages packaging
https://github.com/void-linux/void-packages/pull/26883

[RFC] Support for PEP517 build systems in python3-module
I [have been told](https://github.com/pypa/packaging/issues/363) that PEP517 build systems are the way of the future for Python package building and installation, and `setuptools` will become (or is now) disfavored. `python3-packaging` is the first of our packages to drop `setuptools` and specifically require a PEP517 builder.

This is an attempt to support PEP517 builds in our `python3-module` build style. For now, the preferred (only?) way to do PEP517 builds is to rely on `pip` to do the work. Fortunately, because no PEP517 builder supports compiled extensions, we can avoid the pain of trying to force `pip` to behave with cross compilers (for now).

Use of the PEP517 build procedure in a template is enabled by setting `python_pep517=yes`. If this is adopted, we'll have to modify `xlint` as well.

`pip` can do a one-pass build and install, but I figured it was better to split into a build-wheel stage and an install-wheel stage so people can do `./xbps-src build` and investigate the artifacts.

I am not thrilled with the use of globs in `do_install` when setting a default `$python_pep517_wheel` but, according to [PEP 427](https://www.python.org/dev/peps/pep-0427/#file-name-convention) and its referenced [PEP 425](https://www.python.org/dev/peps/pep-0425), the filename components I'm trying to match with the globs are not easily predicted. In any case, if this produces undesirable behavior in specific templates, the author can manually set that variable. Any other ideas are welcome.

Finally, the build process produces `direct_url.json` in the Python `dist-info` directory to comply with [PEP 610](https://www.python.org/dev/peps/pep-0610), which replaces a simple version number in `pip freeze` output with a `file://` URL pointing to the location of the wheel used for installation. (In our case, this will be `/builddir/$wrksrc/$build_wrksrc/$python_pep517_wheel`.) For distribution packages, I do not believe this is desirable. We can manually remove the file, for example in `do_install`, assuming the `dist-info` directory is predictable. Comments about doing this are welcome.

cc: any @void-linux/pkg-committers with a stake in Python packages

A patch file from https://github.com/void-linux/void-packages/pull/26883.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-packaging-26883.patch --]
[-- Type: text/x-diff, Size: 20945 bytes --]

From 1d9efef93d8d8618a5e31674998b85d01b7d638e Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Wed, 2 Dec 2020 10:30:13 -0500
Subject: [PATCH 1/7] build-style/python3-module: add support for PEP517 build
 systems

---
 common/build-style/python3-module.sh          | 23 +++++++++++++++++--
 .../environment/build-style/python3-module.sh |  4 ++++
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/common/build-style/python3-module.sh b/common/build-style/python3-module.sh
index db56feb5e0e..14943d69356 100644
--- a/common/build-style/python3-module.sh
+++ b/common/build-style/python3-module.sh
@@ -3,7 +3,13 @@
 #
 
 do_build() {
-	if [ -n "$CROSS_BUILD" ]; then
+	if [ -n "$python_pep517" ]; then
+		# No PEP517 build tool currently supports compiled extensions
+		# Thus, there is no need to accommodate cross compilation here
+		mkdir -p build dist
+		TMPDIR=build python3 -m pip wheel --no-deps \
+			--no-build-isolation --no-clean ${make_build_args} .
+	elif [ -n "$CROSS_BUILD" ]; then
 		PYPREFIX="$XBPS_CROSS_BASE"
 		CFLAGS+=" -I${XBPS_CROSS_BASE}/${py3_inc} -I${XBPS_CROSS_BASE}/usr/include"
 		LDFLAGS+=" -L${XBPS_CROSS_BASE}/${py3_lib} -L${XBPS_CROSS_BASE}/usr/lib"
@@ -24,6 +30,11 @@ do_build() {
 }
 
 do_check() {
+	if [ -n "$python_pep517" ]; then
+		msg_warn "No standard test exists for PEP517 Python templates"
+		return 0
+	fi
+
 	if [ -z "$make_check_target" ]; then
 		if ! python3 setup.py --help test >/dev/null 2>&1; then
 			msg_warn "No command 'test' defined by setup.py.\n"
@@ -36,7 +47,15 @@ do_check() {
 }
 
 do_install() {
-	if [ -n "$CROSS_BUILD" ]; then
+	if [ -n "$python_pep517" ]; then
+		# No PEP517 build tool currently supports compiled extensions
+		# Thus, there is no need to accommodate cross compilation here
+		: ${python_pep517_wheel:=${pkgname#python3-}-${version}-*-*-*.whl}
+
+		TMPDIR=build python3 -m pip install --prefix /usr \
+			--root ${DESTDIR} --no-deps --no-build-isolation \
+			--no-clean ${make_install_args} ${python_pep517_wheel}
+	elif [ -n "$CROSS_BUILD" ]; then
 		PYPREFIX="$XBPS_CROSS_BASE"
 		CFLAGS+=" -I${XBPS_CROSS_BASE}/${py3_inc} -I${XBPS_CROSS_BASE}/usr/include"
 		LDFLAGS+=" -L${XBPS_CROSS_BASE}/${py3_lib} -L${XBPS_CROSS_BASE}/usr/lib"
diff --git a/common/environment/build-style/python3-module.sh b/common/environment/build-style/python3-module.sh
index 56471fe88bc..9bc04e6811e 100644
--- a/common/environment/build-style/python3-module.sh
+++ b/common/environment/build-style/python3-module.sh
@@ -1,2 +1,6 @@
 lib32disabled=yes
 makedepends+=" python3"
+
+if [ -n "$python_pep517" ]; then
+	hostmakedepends+=" python3-pip"
+fi

From af70857ed22213b1a51184a063c9af3246f8370c Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Wed, 2 Dec 2020 08:08:33 -0500
Subject: [PATCH 2/7] New package: python3-flit_core-3.0.0

---
 .../python3-flit_core/patches/use_toml.patch  | 254 ++++++++++++++++++
 srcpkgs/python3-flit_core/template            |  24 ++
 2 files changed, 278 insertions(+)
 create mode 100644 srcpkgs/python3-flit_core/patches/use_toml.patch
 create mode 100644 srcpkgs/python3-flit_core/template

diff --git a/srcpkgs/python3-flit_core/patches/use_toml.patch b/srcpkgs/python3-flit_core/patches/use_toml.patch
new file mode 100644
index 00000000000..8a0a668f616
--- /dev/null
+++ b/srcpkgs/python3-flit_core/patches/use_toml.patch
@@ -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 doc/development.rst doc/development.rst
+index 9b8dc5e..f714999 100644
+--- doc/development.rst
++++ 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 doc/pyproject_toml.rst doc/pyproject_toml.rst
+index f9ddc7f..8d38bf9 100644
+--- doc/pyproject_toml.rst
++++ 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 flit/init.py flit/init.py
+index f7ea93a..b0c77c6 100644
+--- flit/init.py
++++ 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 flit/tomlify.py flit/tomlify.py
+index 0c8db69..a9c9c60 100644
+--- flit/tomlify.py
++++ 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 flit_core/flit_core/build_thyself.py flit_core/flit_core/build_thyself.py
+index 7daf67f..f3aaf7c 100644
+--- flit_core/flit_core/build_thyself.py
++++ 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 flit_core/flit_core/config.py flit_core/flit_core/config.py
+index 0af9c00..6ed20d3 100644
+--- flit_core/flit_core/config.py
++++ 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 flit_core/flit_core/sdist.py flit_core/flit_core/sdist.py
+index 1fe5bb4..963b4e5 100644
+--- flit_core/flit_core/sdist.py
++++ 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 flit_core/flit_core/wheel.py flit_core/flit_core/wheel.py
+index 1550846..2bc55e1 100644
+--- flit_core/flit_core/wheel.py
++++ 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 pyproject.toml pyproject.toml
+index ac8d001..0af74b2 100644
+--- pyproject.toml
++++ 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 tests/test_init.py tests/test_init.py
+index fb8ad4d..7330ff5 100644
+--- tests/test_init.py
++++ 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 tests/test_tomlify.py tests/test_tomlify.py
+index 2bd75dc..a7b7978 100644
+--- tests/test_tomlify.py
++++ 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 tox.ini tox.ini
+index 08ce1bf..d1025e1 100644
+--- tox.ini
++++ tox.ini
+@@ -18,7 +18,7 @@ deps =
+     testpath
+     responses
+     docutils
+-    pytoml
++    toml
+     pytest>=2.7.3
+     pytest-cov
+ 
diff --git a/srcpkgs/python3-flit_core/template b/srcpkgs/python3-flit_core/template
new file mode 100644
index 00000000000..f08ceb41806
--- /dev/null
+++ b/srcpkgs/python3-flit_core/template
@@ -0,0 +1,24 @@
+# Template file for 'python3-flit_core'
+pkgname=python3-flit_core
+version=3.0.0
+revision=1
+wrksrc="flit-${version}"
+build_wrksrc="flit_core"
+build_style=python3-module
+python_pep517="yes"
+depends="python3-toml"
+short_desc="Simplified packaging of Python modules - PEP 517 build backend"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="BSD-3-Clause"
+homepage="https://flit.readthedocs.io"
+changelog="https://flit.readthedocs.io/en/latest/history.html"
+distfiles="${PYPI_SITE}/f/flit/flit-${version}.tar.gz"
+checksum=b4fe0f84a1ffbf125d003e253ec98c0b6e3e31290b31fba3ad22d28588c20893
+
+do_check() {
+	: provides no tests
+}
+
+post_install() {
+	vlicense ../LICENSE
+}

From d1322149fdbeff46a7ca0d911f684c9f75ba1ba2 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Wed, 2 Dec 2020 10:28:38 -0500
Subject: [PATCH 3/7] python-packaging: split package

New package: python3-packaging-20.7
---
 srcpkgs/python-packaging/template  | 20 +++++---------------
 srcpkgs/python-packaging/update    |  1 +
 srcpkgs/python3-packaging          |  1 -
 srcpkgs/python3-packaging/template | 25 +++++++++++++++++++++++++
 4 files changed, 31 insertions(+), 16 deletions(-)
 create mode 100644 srcpkgs/python-packaging/update
 delete mode 120000 srcpkgs/python3-packaging
 create mode 100644 srcpkgs/python3-packaging/template

diff --git a/srcpkgs/python-packaging/template b/srcpkgs/python-packaging/template
index e36a04a1540..aa1f64182d7 100644
--- a/srcpkgs/python-packaging/template
+++ b/srcpkgs/python-packaging/template
@@ -1,29 +1,19 @@
 # Template file for 'python-packaging'
 pkgname=python-packaging
 version=20.4
-revision=1
+revision=2
 wrksrc="packaging-${version}"
-build_style=python-module
-pycompile_module="packaging"
-hostmakedepends="python-setuptools python3-setuptools"
-depends="python-attrs python-parsing python-six"
+build_style=python2-module
+hostmakedepends="python-setuptools"
+depends="python-parsing python-six"
 short_desc="Core utilities for Python packages (Python2)"
 maintainer="Alessio Sergi <al3hex@gmail.com>"
 license="Apache-2.0, BSD-2-Clause"
 homepage="https://github.com/pypa/packaging"
+changelog="https://raw.githubusercontent.com/pypa/packaging/master/CHANGELOG.rst"
 distfiles="${PYPI_SITE}/p/packaging/packaging-${version}.tar.gz"
 checksum=4357f74f47b9c12db93624a82154e9b120fa8293699949152b22065d556079f8
 
 post_install() {
 	vlicense LICENSE
 }
-
-python3-packaging_package() {
-	pycompile_module="packaging"
-	depends="python3-attrs python3-parsing python3-six"
-	short_desc="${short_desc/Python2/Python3}"
-	pkg_install() {
-		vmove usr/lib/python3*
-		vlicense LICENSE
-	}
-}
diff --git a/srcpkgs/python-packaging/update b/srcpkgs/python-packaging/update
new file mode 100644
index 00000000000..f3300f258a6
--- /dev/null
+++ b/srcpkgs/python-packaging/update
@@ -0,0 +1 @@
+pattern="packaging-\K20\.4(\.[0-9.]+)?(?=.tar.gz)"
diff --git a/srcpkgs/python3-packaging b/srcpkgs/python3-packaging
deleted file mode 120000
index 98299fdb1d7..00000000000
--- a/srcpkgs/python3-packaging
+++ /dev/null
@@ -1 +0,0 @@
-python-packaging
\ No newline at end of file
diff --git a/srcpkgs/python3-packaging/template b/srcpkgs/python3-packaging/template
new file mode 100644
index 00000000000..7be1238d7a2
--- /dev/null
+++ b/srcpkgs/python3-packaging/template
@@ -0,0 +1,25 @@
+# Template file for 'python3-packaging'
+pkgname=python3-packaging
+version=20.7
+revision=1
+wrksrc="packaging-${version}"
+build_style=python3-module
+python_pep517=yes
+hostmakedepends="python3-flit_core"
+depends="python3-parsing"
+checkdepends="python3-pytest"
+short_desc="Core utilities for Python packages (Python3)"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="Apache-2.0, BSD-2-Clause"
+homepage="https://github.com/pypa/packaging"
+checksum=05af3bb85d320377db281cf254ab050e1a7ebcbf5410685a9a407e18a1f81236
+distfiles="${PYPI_SITE}/p/packaging/packaging-${version}.tar.gz"
+checksum=05af3bb85d320377db281cf254ab050e1a7ebcbf5410685a9a407e18a1f81236
+
+do_check() {
+	: provides no tests
+}
+
+post_install() {
+	vlicense LICENSE
+}

From 26c21a4dab8c3b9943435a8c0fb6c6eb7f68f489 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Wed, 2 Dec 2020 13:58:38 -0500
Subject: [PATCH 4/7] build-style/python3-module: automatically detect tox,
 pytest in do_check

---
 common/build-style/python3-module.sh | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/common/build-style/python3-module.sh b/common/build-style/python3-module.sh
index 14943d69356..aea801066ed 100644
--- a/common/build-style/python3-module.sh
+++ b/common/build-style/python3-module.sh
@@ -30,20 +30,26 @@ do_build() {
 }
 
 do_check() {
-	if [ -n "$python_pep517" ]; then
-		msg_warn "No standard test exists for PEP517 Python templates"
+	if python3 -m tox --help >/dev/null 2>&1; then
+		: ${make_check_target:=py${py3_ver/./}}
+		python3 -m tox -e ${make_check_target} ${make_check_args}
+	elif python3 -m pytest --help >/dev/null 2>&1; then
+		python3 -m pytest ${make_check_args} ${make_check_target}
+	elif [ -n "$python_pep517" ]; then
+		msg_warn "Unable to determine tests for PEP517 Python templates"
 		return 0
-	fi
-
-	if [ -z "$make_check_target" ]; then
-		if ! python3 setup.py --help test >/dev/null 2>&1; then
-			msg_warn "No command 'test' defined by setup.py.\n"
-			return 0
+	else
+		# Fall back to deprecated setup.py test orchestration without pytest
+		if [ -z "$make_check_target" ]; then
+			if ! python3 setup.py --help test >/dev/null 2>&1; then
+				msg_warn "No command 'test' defined by setup.py.\n"
+				return 0
+			fi
 		fi
-	fi
 
-	: ${make_check_target:=test}
-	python3 setup.py ${make_check_target} ${make_check_args}
+		: ${make_check_target:=test}
+		python3 setup.py ${make_check_target} ${make_check_args}
+	fi
 }
 
 do_install() {

From e53c159fff6ad0039654063cf8fc6cea70c8ea41 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Wed, 2 Dec 2020 14:00:31 -0500
Subject: [PATCH 5/7] python3-tifffile: employ improved, automatic do_check

---
 srcpkgs/python3-tifffile/template | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/srcpkgs/python3-tifffile/template b/srcpkgs/python3-tifffile/template
index c5bf27a1424..1d6dcb2a522 100644
--- a/srcpkgs/python3-tifffile/template
+++ b/srcpkgs/python3-tifffile/template
@@ -15,10 +15,6 @@ changelog="https://raw.githubusercontent.com/cgohlke/tifffile/master/CHANGES.rst
 distfiles="${homepage}/archive/v${version}.tar.gz"
 checksum=64fc7602330301e910cc343e99bac02f9b453e933c1ee2050f316cbfee725df3
 
-do_check() {
-	python3 -m pytest
-}
-
 post_install() {
 	vlicense LICENSE
 }

From 31ff5a2889d9f5b5114aaae2168a8a794e63cc1a Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Wed, 2 Dec 2020 14:00:31 -0500
Subject: [PATCH 6/7] python3-wsproto: employ improved, automatic do_check

---
 srcpkgs/python3-wsproto/template | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/srcpkgs/python3-wsproto/template b/srcpkgs/python3-wsproto/template
index 1da34b94340..fd64d5d71e7 100644
--- a/srcpkgs/python3-wsproto/template
+++ b/srcpkgs/python3-wsproto/template
@@ -15,10 +15,6 @@ changelog="https://raw.githubusercontent.com/python-hyper/wsproto/master/CHANGEL
 distfiles="${PYPI_SITE}/w/wsproto/wsproto-${version}.tar.gz"
 checksum=868776f8456997ad0d9720f7322b746bbe9193751b5b290b7f924659377c8c38
 
-do_check() {
-	tox -e py${py3_ver/./}
-}
-
 post_install() {
 	vlicense LICENSE
 }

From 0e132f6ca4fdab2ccff4eef9d9b688cf5cba0faf Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Wed, 2 Dec 2020 14:00:31 -0500
Subject: [PATCH 7/7] python3-hypothesis: employ improved, automatic do_check

---
 srcpkgs/python3-hypothesis/template | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/srcpkgs/python3-hypothesis/template b/srcpkgs/python3-hypothesis/template
index 692eb54c52c..a640b15d304 100644
--- a/srcpkgs/python3-hypothesis/template
+++ b/srcpkgs/python3-hypothesis/template
@@ -5,6 +5,7 @@ revision=1
 wrksrc="hypothesis-hypothesis-python-${version}"
 build_wrksrc=hypothesis-python
 build_style=python3-module
+make_check_target="py${py3_ver/./}-full"
 hostmakedepends="python3-setuptools"
 depends="python3-attrs python3-sortedcontainers"
 checkdepends="tox"
@@ -15,7 +16,3 @@ homepage="https://hypothesis.works/"
 changelog="https://hypothesis.readthedocs.io/en/latest/changes.html"
 distfiles="https://github.com/HypothesisWorks/hypothesis/archive/hypothesis-python-${version}.tar.gz"
 checksum=865027f77db5be518a8398e88bf937eb602d6f1a49643faa6c8dbb8804570bbb
-
-do_check() {
-	tox -e "py${py3_ver/./}-full"
-}

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PR REVIEW] [RFC] Support for PEP517 build systems in python3-module
  2020-12-02 16:00 [PR PATCH] [RFC] Support for PEP517 build systems in python3-module ahesford
  2020-12-02 17:45 ` [PR REVIEW] " ericonr
  2020-12-02 19:02 ` [PR PATCH] [Updated] " ahesford
@ 2020-12-02 19:06 ` ahesford
  2020-12-02 19:10 ` ericonr
                   ` (18 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: ahesford @ 2020-12-02 19:06 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 766 bytes --]

New review comment by ahesford on void-packages repository

https://github.com/void-linux/void-packages/pull/26883#discussion_r534413104

Comment:
Not a bad idea, but I've gone one step further. Running `python setup.py test` complains about deprectation and suggests `tox` instead. Because that is the official recommendation, I try `tox` first if possible, otherwise try `pytest` if possible, and finally fall back to the old behavior for non-PEP517 builds.

I've modified a few templates as an example of how the change eliminates some redundancy.

If there is not significant debate about the PEP517 changes, I'll squash the two `build-style/python3-module` commits before merging. For now, I'll keep them apart so we can separate the two issues if need be.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PR REVIEW] [RFC] Support for PEP517 build systems in python3-module
  2020-12-02 16:00 [PR PATCH] [RFC] Support for PEP517 build systems in python3-module ahesford
                   ` (2 preceding siblings ...)
  2020-12-02 19:06 ` [PR REVIEW] " ahesford
@ 2020-12-02 19:10 ` ericonr
  2020-12-02 19:11 ` ericonr
                   ` (17 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: ericonr @ 2020-12-02 19:10 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 188 bytes --]

New review comment by ericonr on void-packages repository

https://github.com/void-linux/void-packages/pull/26883#discussion_r534415566

Comment:
See #25052 for some discussion about tox.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PR REVIEW] [RFC] Support for PEP517 build systems in python3-module
  2020-12-02 16:00 [PR PATCH] [RFC] Support for PEP517 build systems in python3-module ahesford
                   ` (3 preceding siblings ...)
  2020-12-02 19:10 ` ericonr
@ 2020-12-02 19:11 ` ericonr
  2020-12-02 19:14 ` ericonr
                   ` (16 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: ericonr @ 2020-12-02 19:11 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 187 bytes --]

New review comment by ericonr on void-packages repository

https://github.com/void-linux/void-packages/pull/26883#discussion_r534416133

Comment:
For style points, I wouldn't use quotes.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PR REVIEW] [RFC] Support for PEP517 build systems in python3-module
  2020-12-02 16:00 [PR PATCH] [RFC] Support for PEP517 build systems in python3-module ahesford
                   ` (4 preceding siblings ...)
  2020-12-02 19:11 ` ericonr
@ 2020-12-02 19:14 ` ericonr
  2020-12-02 19:27 ` [PR PATCH] [Updated] " ahesford
                   ` (15 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: ericonr @ 2020-12-02 19:14 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 223 bytes --]

New review comment by ericonr on void-packages repository

https://github.com/void-linux/void-packages/pull/26883#discussion_r534415566

Comment:
See #25052 for some discussion about tox.

Btw, this PR closes that issue.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PR PATCH] [Updated] [RFC] Support for PEP517 build systems in python3-module
  2020-12-02 16:00 [PR PATCH] [RFC] Support for PEP517 build systems in python3-module ahesford
                   ` (5 preceding siblings ...)
  2020-12-02 19:14 ` ericonr
@ 2020-12-02 19:27 ` ahesford
  2020-12-02 19:28 ` [PR REVIEW] " ahesford
                   ` (14 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: ahesford @ 2020-12-02 19:27 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 2539 bytes --]

There is an updated pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages packaging
https://github.com/void-linux/void-packages/pull/26883

[RFC] Support for PEP517 build systems in python3-module
I [have been told](https://github.com/pypa/packaging/issues/363) that PEP517 build systems are the way of the future for Python package building and installation, and `setuptools` will become (or is now) disfavored. `python3-packaging` is the first of our packages to drop `setuptools` and specifically require a PEP517 builder.

This is an attempt to support PEP517 builds in our `python3-module` build style. For now, the preferred (only?) way to do PEP517 builds is to rely on `pip` to do the work. Fortunately, because no PEP517 builder supports compiled extensions, we can avoid the pain of trying to force `pip` to behave with cross compilers (for now).

Use of the PEP517 build procedure in a template is enabled by setting `python_pep517=yes`. If this is adopted, we'll have to modify `xlint` as well.

`pip` can do a one-pass build and install, but I figured it was better to split into a build-wheel stage and an install-wheel stage so people can do `./xbps-src build` and investigate the artifacts.

I am not thrilled with the use of globs in `do_install` when setting a default `$python_pep517_wheel` but, according to [PEP 427](https://www.python.org/dev/peps/pep-0427/#file-name-convention) and its referenced [PEP 425](https://www.python.org/dev/peps/pep-0425), the filename components I'm trying to match with the globs are not easily predicted. In any case, if this produces undesirable behavior in specific templates, the author can manually set that variable. Any other ideas are welcome.

Finally, the build process produces `direct_url.json` in the Python `dist-info` directory to comply with [PEP 610](https://www.python.org/dev/peps/pep-0610), which replaces a simple version number in `pip freeze` output with a `file://` URL pointing to the location of the wheel used for installation. (In our case, this will be `/builddir/$wrksrc/$build_wrksrc/$python_pep517_wheel`.) For distribution packages, I do not believe this is desirable. We can manually remove the file, for example in `do_install`, assuming the `dist-info` directory is predictable. Comments about doing this are welcome.

cc: any @void-linux/pkg-committers with a stake in Python packages

A patch file from https://github.com/void-linux/void-packages/pull/26883.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-packaging-26883.patch --]
[-- Type: text/x-diff, Size: 19946 bytes --]

From 92427aa895cc9546c1579b614c671986521314b2 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Wed, 2 Dec 2020 10:30:13 -0500
Subject: [PATCH 1/5] build-style/python3-module: add support for PEP517 build
 systems

---
 Manual.md                                     |  9 ++++++++
 common/build-style/python3-module.sh          | 23 +++++++++++++++++--
 .../environment/build-style/python3-module.sh |  4 ++++
 3 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/Manual.md b/Manual.md
index 7647f957129..8bab006868b 100644
--- a/Manual.md
+++ b/Manual.md
@@ -1516,6 +1516,15 @@ By default it's set to `2`. This variable is needed for multi-language
 applications (e.g., the application is written in C while the command is
 written in Python) or just single Python file ones that live in `/usr/bin`.
 
+- `python_pep517`: valid only for the `python3-module` build style, setting this to any non-empty
+value will cause `xbps-src` to build and install Python packages that conform to the PEP517 build
+description format. With this enabled, the `xbps-src` build stage produces a Python wheel and the
+the install stage installs the wheel to `$DESTDIR`.
+
+- `python_pep517_wheel`: if necessary, set this to the location of the wheel produced by the build
+stage when `python_pep517` is defined. In most circumstances, `xbps-src` will automatically find and
+install the correct wheel without requiring that this variable be set.
+
 > NOTE: you need to define it *only* for non-Python modules.
 
 Also, a set of useful variables are defined to use in the templates:
diff --git a/common/build-style/python3-module.sh b/common/build-style/python3-module.sh
index db56feb5e0e..14943d69356 100644
--- a/common/build-style/python3-module.sh
+++ b/common/build-style/python3-module.sh
@@ -3,7 +3,13 @@
 #
 
 do_build() {
-	if [ -n "$CROSS_BUILD" ]; then
+	if [ -n "$python_pep517" ]; then
+		# No PEP517 build tool currently supports compiled extensions
+		# Thus, there is no need to accommodate cross compilation here
+		mkdir -p build dist
+		TMPDIR=build python3 -m pip wheel --no-deps \
+			--no-build-isolation --no-clean ${make_build_args} .
+	elif [ -n "$CROSS_BUILD" ]; then
 		PYPREFIX="$XBPS_CROSS_BASE"
 		CFLAGS+=" -I${XBPS_CROSS_BASE}/${py3_inc} -I${XBPS_CROSS_BASE}/usr/include"
 		LDFLAGS+=" -L${XBPS_CROSS_BASE}/${py3_lib} -L${XBPS_CROSS_BASE}/usr/lib"
@@ -24,6 +30,11 @@ do_build() {
 }
 
 do_check() {
+	if [ -n "$python_pep517" ]; then
+		msg_warn "No standard test exists for PEP517 Python templates"
+		return 0
+	fi
+
 	if [ -z "$make_check_target" ]; then
 		if ! python3 setup.py --help test >/dev/null 2>&1; then
 			msg_warn "No command 'test' defined by setup.py.\n"
@@ -36,7 +47,15 @@ do_check() {
 }
 
 do_install() {
-	if [ -n "$CROSS_BUILD" ]; then
+	if [ -n "$python_pep517" ]; then
+		# No PEP517 build tool currently supports compiled extensions
+		# Thus, there is no need to accommodate cross compilation here
+		: ${python_pep517_wheel:=${pkgname#python3-}-${version}-*-*-*.whl}
+
+		TMPDIR=build python3 -m pip install --prefix /usr \
+			--root ${DESTDIR} --no-deps --no-build-isolation \
+			--no-clean ${make_install_args} ${python_pep517_wheel}
+	elif [ -n "$CROSS_BUILD" ]; then
 		PYPREFIX="$XBPS_CROSS_BASE"
 		CFLAGS+=" -I${XBPS_CROSS_BASE}/${py3_inc} -I${XBPS_CROSS_BASE}/usr/include"
 		LDFLAGS+=" -L${XBPS_CROSS_BASE}/${py3_lib} -L${XBPS_CROSS_BASE}/usr/lib"
diff --git a/common/environment/build-style/python3-module.sh b/common/environment/build-style/python3-module.sh
index 56471fe88bc..9bc04e6811e 100644
--- a/common/environment/build-style/python3-module.sh
+++ b/common/environment/build-style/python3-module.sh
@@ -1,2 +1,6 @@
 lib32disabled=yes
 makedepends+=" python3"
+
+if [ -n "$python_pep517" ]; then
+	hostmakedepends+=" python3-pip"
+fi

From c31ff9dd2a1ef7d97ed65030a6e695f0bd1dbe9b Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Wed, 2 Dec 2020 08:08:33 -0500
Subject: [PATCH 2/5] New package: python3-flit_core-3.0.0

---
 .../python3-flit_core/patches/use_toml.patch  | 254 ++++++++++++++++++
 srcpkgs/python3-flit_core/template            |  24 ++
 2 files changed, 278 insertions(+)
 create mode 100644 srcpkgs/python3-flit_core/patches/use_toml.patch
 create mode 100644 srcpkgs/python3-flit_core/template

diff --git a/srcpkgs/python3-flit_core/patches/use_toml.patch b/srcpkgs/python3-flit_core/patches/use_toml.patch
new file mode 100644
index 00000000000..8a0a668f616
--- /dev/null
+++ b/srcpkgs/python3-flit_core/patches/use_toml.patch
@@ -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 doc/development.rst doc/development.rst
+index 9b8dc5e..f714999 100644
+--- doc/development.rst
++++ 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 doc/pyproject_toml.rst doc/pyproject_toml.rst
+index f9ddc7f..8d38bf9 100644
+--- doc/pyproject_toml.rst
++++ 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 flit/init.py flit/init.py
+index f7ea93a..b0c77c6 100644
+--- flit/init.py
++++ 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 flit/tomlify.py flit/tomlify.py
+index 0c8db69..a9c9c60 100644
+--- flit/tomlify.py
++++ 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 flit_core/flit_core/build_thyself.py flit_core/flit_core/build_thyself.py
+index 7daf67f..f3aaf7c 100644
+--- flit_core/flit_core/build_thyself.py
++++ 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 flit_core/flit_core/config.py flit_core/flit_core/config.py
+index 0af9c00..6ed20d3 100644
+--- flit_core/flit_core/config.py
++++ 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 flit_core/flit_core/sdist.py flit_core/flit_core/sdist.py
+index 1fe5bb4..963b4e5 100644
+--- flit_core/flit_core/sdist.py
++++ 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 flit_core/flit_core/wheel.py flit_core/flit_core/wheel.py
+index 1550846..2bc55e1 100644
+--- flit_core/flit_core/wheel.py
++++ 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 pyproject.toml pyproject.toml
+index ac8d001..0af74b2 100644
+--- pyproject.toml
++++ 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 tests/test_init.py tests/test_init.py
+index fb8ad4d..7330ff5 100644
+--- tests/test_init.py
++++ 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 tests/test_tomlify.py tests/test_tomlify.py
+index 2bd75dc..a7b7978 100644
+--- tests/test_tomlify.py
++++ 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 tox.ini tox.ini
+index 08ce1bf..d1025e1 100644
+--- tox.ini
++++ tox.ini
+@@ -18,7 +18,7 @@ deps =
+     testpath
+     responses
+     docutils
+-    pytoml
++    toml
+     pytest>=2.7.3
+     pytest-cov
+ 
diff --git a/srcpkgs/python3-flit_core/template b/srcpkgs/python3-flit_core/template
new file mode 100644
index 00000000000..f08ceb41806
--- /dev/null
+++ b/srcpkgs/python3-flit_core/template
@@ -0,0 +1,24 @@
+# Template file for 'python3-flit_core'
+pkgname=python3-flit_core
+version=3.0.0
+revision=1
+wrksrc="flit-${version}"
+build_wrksrc="flit_core"
+build_style=python3-module
+python_pep517="yes"
+depends="python3-toml"
+short_desc="Simplified packaging of Python modules - PEP 517 build backend"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="BSD-3-Clause"
+homepage="https://flit.readthedocs.io"
+changelog="https://flit.readthedocs.io/en/latest/history.html"
+distfiles="${PYPI_SITE}/f/flit/flit-${version}.tar.gz"
+checksum=b4fe0f84a1ffbf125d003e253ec98c0b6e3e31290b31fba3ad22d28588c20893
+
+do_check() {
+	: provides no tests
+}
+
+post_install() {
+	vlicense ../LICENSE
+}

From a4c0173c4b14bd204ae430ef611d276a669884b8 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Wed, 2 Dec 2020 10:28:38 -0500
Subject: [PATCH 3/5] python-packaging: split package

New package: python3-packaging-20.7
---
 srcpkgs/python-packaging/template  | 20 +++++---------------
 srcpkgs/python-packaging/update    |  1 +
 srcpkgs/python3-packaging          |  1 -
 srcpkgs/python3-packaging/template | 25 +++++++++++++++++++++++++
 4 files changed, 31 insertions(+), 16 deletions(-)
 create mode 100644 srcpkgs/python-packaging/update
 delete mode 120000 srcpkgs/python3-packaging
 create mode 100644 srcpkgs/python3-packaging/template

diff --git a/srcpkgs/python-packaging/template b/srcpkgs/python-packaging/template
index e36a04a1540..aa1f64182d7 100644
--- a/srcpkgs/python-packaging/template
+++ b/srcpkgs/python-packaging/template
@@ -1,29 +1,19 @@
 # Template file for 'python-packaging'
 pkgname=python-packaging
 version=20.4
-revision=1
+revision=2
 wrksrc="packaging-${version}"
-build_style=python-module
-pycompile_module="packaging"
-hostmakedepends="python-setuptools python3-setuptools"
-depends="python-attrs python-parsing python-six"
+build_style=python2-module
+hostmakedepends="python-setuptools"
+depends="python-parsing python-six"
 short_desc="Core utilities for Python packages (Python2)"
 maintainer="Alessio Sergi <al3hex@gmail.com>"
 license="Apache-2.0, BSD-2-Clause"
 homepage="https://github.com/pypa/packaging"
+changelog="https://raw.githubusercontent.com/pypa/packaging/master/CHANGELOG.rst"
 distfiles="${PYPI_SITE}/p/packaging/packaging-${version}.tar.gz"
 checksum=4357f74f47b9c12db93624a82154e9b120fa8293699949152b22065d556079f8
 
 post_install() {
 	vlicense LICENSE
 }
-
-python3-packaging_package() {
-	pycompile_module="packaging"
-	depends="python3-attrs python3-parsing python3-six"
-	short_desc="${short_desc/Python2/Python3}"
-	pkg_install() {
-		vmove usr/lib/python3*
-		vlicense LICENSE
-	}
-}
diff --git a/srcpkgs/python-packaging/update b/srcpkgs/python-packaging/update
new file mode 100644
index 00000000000..f3300f258a6
--- /dev/null
+++ b/srcpkgs/python-packaging/update
@@ -0,0 +1 @@
+pattern="packaging-\K20\.4(\.[0-9.]+)?(?=.tar.gz)"
diff --git a/srcpkgs/python3-packaging b/srcpkgs/python3-packaging
deleted file mode 120000
index 98299fdb1d7..00000000000
--- a/srcpkgs/python3-packaging
+++ /dev/null
@@ -1 +0,0 @@
-python-packaging
\ No newline at end of file
diff --git a/srcpkgs/python3-packaging/template b/srcpkgs/python3-packaging/template
new file mode 100644
index 00000000000..7be1238d7a2
--- /dev/null
+++ b/srcpkgs/python3-packaging/template
@@ -0,0 +1,25 @@
+# Template file for 'python3-packaging'
+pkgname=python3-packaging
+version=20.7
+revision=1
+wrksrc="packaging-${version}"
+build_style=python3-module
+python_pep517=yes
+hostmakedepends="python3-flit_core"
+depends="python3-parsing"
+checkdepends="python3-pytest"
+short_desc="Core utilities for Python packages (Python3)"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="Apache-2.0, BSD-2-Clause"
+homepage="https://github.com/pypa/packaging"
+checksum=05af3bb85d320377db281cf254ab050e1a7ebcbf5410685a9a407e18a1f81236
+distfiles="${PYPI_SITE}/p/packaging/packaging-${version}.tar.gz"
+checksum=05af3bb85d320377db281cf254ab050e1a7ebcbf5410685a9a407e18a1f81236
+
+do_check() {
+	: provides no tests
+}
+
+post_install() {
+	vlicense LICENSE
+}

From 8358a9d02a89122fbdb75d695a3bc196cf6b88de Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Wed, 2 Dec 2020 13:58:38 -0500
Subject: [PATCH 4/5] build-style/python3-module: automatically detect pytest
 in do_check

---
 common/build-style/python3-module.sh | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/common/build-style/python3-module.sh b/common/build-style/python3-module.sh
index 14943d69356..4d9ecd3433b 100644
--- a/common/build-style/python3-module.sh
+++ b/common/build-style/python3-module.sh
@@ -30,20 +30,23 @@ do_build() {
 }
 
 do_check() {
-	if [ -n "$python_pep517" ]; then
-		msg_warn "No standard test exists for PEP517 Python templates"
+	if python3 -m pytest --help >/dev/null 2>&1; then
+		python3 -m pytest ${make_check_args} ${make_check_target}
+	elif [ -n "$python_pep517" ]; then
+		msg_warn "Unable to determine tests for PEP517 Python templates"
 		return 0
-	fi
-
-	if [ -z "$make_check_target" ]; then
-		if ! python3 setup.py --help test >/dev/null 2>&1; then
-			msg_warn "No command 'test' defined by setup.py.\n"
-			return 0
+	else
+		# Fall back to deprecated setup.py test orchestration without pytest
+		if [ -z "$make_check_target" ]; then
+			if ! python3 setup.py --help test >/dev/null 2>&1; then
+				msg_warn "No command 'test' defined by setup.py.\n"
+				return 0
+			fi
 		fi
-	fi
 
-	: ${make_check_target:=test}
-	python3 setup.py ${make_check_target} ${make_check_args}
+		: ${make_check_target:=test}
+		python3 setup.py ${make_check_target} ${make_check_args}
+	fi
 }
 
 do_install() {

From f72fa4e155200b062bea515fa59d0040217106e1 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Wed, 2 Dec 2020 14:00:31 -0500
Subject: [PATCH 5/5] python3-tifffile: employ improved, automatic do_check

---
 srcpkgs/python3-tifffile/template | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/srcpkgs/python3-tifffile/template b/srcpkgs/python3-tifffile/template
index c5bf27a1424..1d6dcb2a522 100644
--- a/srcpkgs/python3-tifffile/template
+++ b/srcpkgs/python3-tifffile/template
@@ -15,10 +15,6 @@ changelog="https://raw.githubusercontent.com/cgohlke/tifffile/master/CHANGES.rst
 distfiles="${homepage}/archive/v${version}.tar.gz"
 checksum=64fc7602330301e910cc343e99bac02f9b453e933c1ee2050f316cbfee725df3
 
-do_check() {
-	python3 -m pytest
-}
-
 post_install() {
 	vlicense LICENSE
 }

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PR REVIEW] [RFC] Support for PEP517 build systems in python3-module
  2020-12-02 16:00 [PR PATCH] [RFC] Support for PEP517 build systems in python3-module ahesford
                   ` (6 preceding siblings ...)
  2020-12-02 19:27 ` [PR PATCH] [Updated] " ahesford
@ 2020-12-02 19:28 ` ahesford
  2020-12-02 19:30 ` [PR PATCH] [Updated] " ahesford
                   ` (13 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: ahesford @ 2020-12-02 19:28 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 309 bytes --]

New review comment by ahesford on void-packages repository

https://github.com/void-linux/void-packages/pull/26883#discussion_r534426012

Comment:
Based on opposition in the mentioned issue, I dropped `tox` from the build style and kept the preference for `pytest` over the deprecated `setup.py test` method.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PR PATCH] [Updated] [RFC] Support for PEP517 build systems in python3-module
  2020-12-02 16:00 [PR PATCH] [RFC] Support for PEP517 build systems in python3-module ahesford
                   ` (7 preceding siblings ...)
  2020-12-02 19:28 ` [PR REVIEW] " ahesford
@ 2020-12-02 19:30 ` ahesford
  2020-12-02 19:42 ` Johnnynator
                   ` (12 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: ahesford @ 2020-12-02 19:30 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 2539 bytes --]

There is an updated pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages packaging
https://github.com/void-linux/void-packages/pull/26883

[RFC] Support for PEP517 build systems in python3-module
I [have been told](https://github.com/pypa/packaging/issues/363) that PEP517 build systems are the way of the future for Python package building and installation, and `setuptools` will become (or is now) disfavored. `python3-packaging` is the first of our packages to drop `setuptools` and specifically require a PEP517 builder.

This is an attempt to support PEP517 builds in our `python3-module` build style. For now, the preferred (only?) way to do PEP517 builds is to rely on `pip` to do the work. Fortunately, because no PEP517 builder supports compiled extensions, we can avoid the pain of trying to force `pip` to behave with cross compilers (for now).

Use of the PEP517 build procedure in a template is enabled by setting `python_pep517=yes`. If this is adopted, we'll have to modify `xlint` as well.

`pip` can do a one-pass build and install, but I figured it was better to split into a build-wheel stage and an install-wheel stage so people can do `./xbps-src build` and investigate the artifacts.

I am not thrilled with the use of globs in `do_install` when setting a default `$python_pep517_wheel` but, according to [PEP 427](https://www.python.org/dev/peps/pep-0427/#file-name-convention) and its referenced [PEP 425](https://www.python.org/dev/peps/pep-0425), the filename components I'm trying to match with the globs are not easily predicted. In any case, if this produces undesirable behavior in specific templates, the author can manually set that variable. Any other ideas are welcome.

Finally, the build process produces `direct_url.json` in the Python `dist-info` directory to comply with [PEP 610](https://www.python.org/dev/peps/pep-0610), which replaces a simple version number in `pip freeze` output with a `file://` URL pointing to the location of the wheel used for installation. (In our case, this will be `/builddir/$wrksrc/$build_wrksrc/$python_pep517_wheel`.) For distribution packages, I do not believe this is desirable. We can manually remove the file, for example in `do_install`, assuming the `dist-info` directory is predictable. Comments about doing this are welcome.

cc: any @void-linux/pkg-committers with a stake in Python packages

A patch file from https://github.com/void-linux/void-packages/pull/26883.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-packaging-26883.patch --]
[-- Type: text/x-diff, Size: 19944 bytes --]

From 92427aa895cc9546c1579b614c671986521314b2 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Wed, 2 Dec 2020 10:30:13 -0500
Subject: [PATCH 1/5] build-style/python3-module: add support for PEP517 build
 systems

---
 Manual.md                                     |  9 ++++++++
 common/build-style/python3-module.sh          | 23 +++++++++++++++++--
 .../environment/build-style/python3-module.sh |  4 ++++
 3 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/Manual.md b/Manual.md
index 7647f957129..8bab006868b 100644
--- a/Manual.md
+++ b/Manual.md
@@ -1516,6 +1516,15 @@ By default it's set to `2`. This variable is needed for multi-language
 applications (e.g., the application is written in C while the command is
 written in Python) or just single Python file ones that live in `/usr/bin`.
 
+- `python_pep517`: valid only for the `python3-module` build style, setting this to any non-empty
+value will cause `xbps-src` to build and install Python packages that conform to the PEP517 build
+description format. With this enabled, the `xbps-src` build stage produces a Python wheel and the
+the install stage installs the wheel to `$DESTDIR`.
+
+- `python_pep517_wheel`: if necessary, set this to the location of the wheel produced by the build
+stage when `python_pep517` is defined. In most circumstances, `xbps-src` will automatically find and
+install the correct wheel without requiring that this variable be set.
+
 > NOTE: you need to define it *only* for non-Python modules.
 
 Also, a set of useful variables are defined to use in the templates:
diff --git a/common/build-style/python3-module.sh b/common/build-style/python3-module.sh
index db56feb5e0e..14943d69356 100644
--- a/common/build-style/python3-module.sh
+++ b/common/build-style/python3-module.sh
@@ -3,7 +3,13 @@
 #
 
 do_build() {
-	if [ -n "$CROSS_BUILD" ]; then
+	if [ -n "$python_pep517" ]; then
+		# No PEP517 build tool currently supports compiled extensions
+		# Thus, there is no need to accommodate cross compilation here
+		mkdir -p build dist
+		TMPDIR=build python3 -m pip wheel --no-deps \
+			--no-build-isolation --no-clean ${make_build_args} .
+	elif [ -n "$CROSS_BUILD" ]; then
 		PYPREFIX="$XBPS_CROSS_BASE"
 		CFLAGS+=" -I${XBPS_CROSS_BASE}/${py3_inc} -I${XBPS_CROSS_BASE}/usr/include"
 		LDFLAGS+=" -L${XBPS_CROSS_BASE}/${py3_lib} -L${XBPS_CROSS_BASE}/usr/lib"
@@ -24,6 +30,11 @@ do_build() {
 }
 
 do_check() {
+	if [ -n "$python_pep517" ]; then
+		msg_warn "No standard test exists for PEP517 Python templates"
+		return 0
+	fi
+
 	if [ -z "$make_check_target" ]; then
 		if ! python3 setup.py --help test >/dev/null 2>&1; then
 			msg_warn "No command 'test' defined by setup.py.\n"
@@ -36,7 +47,15 @@ do_check() {
 }
 
 do_install() {
-	if [ -n "$CROSS_BUILD" ]; then
+	if [ -n "$python_pep517" ]; then
+		# No PEP517 build tool currently supports compiled extensions
+		# Thus, there is no need to accommodate cross compilation here
+		: ${python_pep517_wheel:=${pkgname#python3-}-${version}-*-*-*.whl}
+
+		TMPDIR=build python3 -m pip install --prefix /usr \
+			--root ${DESTDIR} --no-deps --no-build-isolation \
+			--no-clean ${make_install_args} ${python_pep517_wheel}
+	elif [ -n "$CROSS_BUILD" ]; then
 		PYPREFIX="$XBPS_CROSS_BASE"
 		CFLAGS+=" -I${XBPS_CROSS_BASE}/${py3_inc} -I${XBPS_CROSS_BASE}/usr/include"
 		LDFLAGS+=" -L${XBPS_CROSS_BASE}/${py3_lib} -L${XBPS_CROSS_BASE}/usr/lib"
diff --git a/common/environment/build-style/python3-module.sh b/common/environment/build-style/python3-module.sh
index 56471fe88bc..9bc04e6811e 100644
--- a/common/environment/build-style/python3-module.sh
+++ b/common/environment/build-style/python3-module.sh
@@ -1,2 +1,6 @@
 lib32disabled=yes
 makedepends+=" python3"
+
+if [ -n "$python_pep517" ]; then
+	hostmakedepends+=" python3-pip"
+fi

From cbc7dec975bab17ee97c146e6c35d4dbbf86071b Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Wed, 2 Dec 2020 08:08:33 -0500
Subject: [PATCH 2/5] New package: python3-flit_core-3.0.0

---
 .../python3-flit_core/patches/use_toml.patch  | 254 ++++++++++++++++++
 srcpkgs/python3-flit_core/template            |  24 ++
 2 files changed, 278 insertions(+)
 create mode 100644 srcpkgs/python3-flit_core/patches/use_toml.patch
 create mode 100644 srcpkgs/python3-flit_core/template

diff --git a/srcpkgs/python3-flit_core/patches/use_toml.patch b/srcpkgs/python3-flit_core/patches/use_toml.patch
new file mode 100644
index 00000000000..8a0a668f616
--- /dev/null
+++ b/srcpkgs/python3-flit_core/patches/use_toml.patch
@@ -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 doc/development.rst doc/development.rst
+index 9b8dc5e..f714999 100644
+--- doc/development.rst
++++ 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 doc/pyproject_toml.rst doc/pyproject_toml.rst
+index f9ddc7f..8d38bf9 100644
+--- doc/pyproject_toml.rst
++++ 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 flit/init.py flit/init.py
+index f7ea93a..b0c77c6 100644
+--- flit/init.py
++++ 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 flit/tomlify.py flit/tomlify.py
+index 0c8db69..a9c9c60 100644
+--- flit/tomlify.py
++++ 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 flit_core/flit_core/build_thyself.py flit_core/flit_core/build_thyself.py
+index 7daf67f..f3aaf7c 100644
+--- flit_core/flit_core/build_thyself.py
++++ 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 flit_core/flit_core/config.py flit_core/flit_core/config.py
+index 0af9c00..6ed20d3 100644
+--- flit_core/flit_core/config.py
++++ 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 flit_core/flit_core/sdist.py flit_core/flit_core/sdist.py
+index 1fe5bb4..963b4e5 100644
+--- flit_core/flit_core/sdist.py
++++ 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 flit_core/flit_core/wheel.py flit_core/flit_core/wheel.py
+index 1550846..2bc55e1 100644
+--- flit_core/flit_core/wheel.py
++++ 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 pyproject.toml pyproject.toml
+index ac8d001..0af74b2 100644
+--- pyproject.toml
++++ 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 tests/test_init.py tests/test_init.py
+index fb8ad4d..7330ff5 100644
+--- tests/test_init.py
++++ 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 tests/test_tomlify.py tests/test_tomlify.py
+index 2bd75dc..a7b7978 100644
+--- tests/test_tomlify.py
++++ 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 tox.ini tox.ini
+index 08ce1bf..d1025e1 100644
+--- tox.ini
++++ tox.ini
+@@ -18,7 +18,7 @@ deps =
+     testpath
+     responses
+     docutils
+-    pytoml
++    toml
+     pytest>=2.7.3
+     pytest-cov
+ 
diff --git a/srcpkgs/python3-flit_core/template b/srcpkgs/python3-flit_core/template
new file mode 100644
index 00000000000..a14afa5e65f
--- /dev/null
+++ b/srcpkgs/python3-flit_core/template
@@ -0,0 +1,24 @@
+# Template file for 'python3-flit_core'
+pkgname=python3-flit_core
+version=3.0.0
+revision=1
+wrksrc="flit-${version}"
+build_wrksrc="flit_core"
+build_style=python3-module
+python_pep517=yes
+depends="python3-toml"
+short_desc="Simplified packaging of Python modules - PEP 517 build backend"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="BSD-3-Clause"
+homepage="https://flit.readthedocs.io"
+changelog="https://flit.readthedocs.io/en/latest/history.html"
+distfiles="${PYPI_SITE}/f/flit/flit-${version}.tar.gz"
+checksum=b4fe0f84a1ffbf125d003e253ec98c0b6e3e31290b31fba3ad22d28588c20893
+
+do_check() {
+	: provides no tests
+}
+
+post_install() {
+	vlicense ../LICENSE
+}

From 76e6765e5579dc75d7489e1d96a981fa7c14a832 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Wed, 2 Dec 2020 10:28:38 -0500
Subject: [PATCH 3/5] python-packaging: split package

New package: python3-packaging-20.7
---
 srcpkgs/python-packaging/template  | 20 +++++---------------
 srcpkgs/python-packaging/update    |  1 +
 srcpkgs/python3-packaging          |  1 -
 srcpkgs/python3-packaging/template | 25 +++++++++++++++++++++++++
 4 files changed, 31 insertions(+), 16 deletions(-)
 create mode 100644 srcpkgs/python-packaging/update
 delete mode 120000 srcpkgs/python3-packaging
 create mode 100644 srcpkgs/python3-packaging/template

diff --git a/srcpkgs/python-packaging/template b/srcpkgs/python-packaging/template
index e36a04a1540..aa1f64182d7 100644
--- a/srcpkgs/python-packaging/template
+++ b/srcpkgs/python-packaging/template
@@ -1,29 +1,19 @@
 # Template file for 'python-packaging'
 pkgname=python-packaging
 version=20.4
-revision=1
+revision=2
 wrksrc="packaging-${version}"
-build_style=python-module
-pycompile_module="packaging"
-hostmakedepends="python-setuptools python3-setuptools"
-depends="python-attrs python-parsing python-six"
+build_style=python2-module
+hostmakedepends="python-setuptools"
+depends="python-parsing python-six"
 short_desc="Core utilities for Python packages (Python2)"
 maintainer="Alessio Sergi <al3hex@gmail.com>"
 license="Apache-2.0, BSD-2-Clause"
 homepage="https://github.com/pypa/packaging"
+changelog="https://raw.githubusercontent.com/pypa/packaging/master/CHANGELOG.rst"
 distfiles="${PYPI_SITE}/p/packaging/packaging-${version}.tar.gz"
 checksum=4357f74f47b9c12db93624a82154e9b120fa8293699949152b22065d556079f8
 
 post_install() {
 	vlicense LICENSE
 }
-
-python3-packaging_package() {
-	pycompile_module="packaging"
-	depends="python3-attrs python3-parsing python3-six"
-	short_desc="${short_desc/Python2/Python3}"
-	pkg_install() {
-		vmove usr/lib/python3*
-		vlicense LICENSE
-	}
-}
diff --git a/srcpkgs/python-packaging/update b/srcpkgs/python-packaging/update
new file mode 100644
index 00000000000..f3300f258a6
--- /dev/null
+++ b/srcpkgs/python-packaging/update
@@ -0,0 +1 @@
+pattern="packaging-\K20\.4(\.[0-9.]+)?(?=.tar.gz)"
diff --git a/srcpkgs/python3-packaging b/srcpkgs/python3-packaging
deleted file mode 120000
index 98299fdb1d7..00000000000
--- a/srcpkgs/python3-packaging
+++ /dev/null
@@ -1 +0,0 @@
-python-packaging
\ No newline at end of file
diff --git a/srcpkgs/python3-packaging/template b/srcpkgs/python3-packaging/template
new file mode 100644
index 00000000000..7be1238d7a2
--- /dev/null
+++ b/srcpkgs/python3-packaging/template
@@ -0,0 +1,25 @@
+# Template file for 'python3-packaging'
+pkgname=python3-packaging
+version=20.7
+revision=1
+wrksrc="packaging-${version}"
+build_style=python3-module
+python_pep517=yes
+hostmakedepends="python3-flit_core"
+depends="python3-parsing"
+checkdepends="python3-pytest"
+short_desc="Core utilities for Python packages (Python3)"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="Apache-2.0, BSD-2-Clause"
+homepage="https://github.com/pypa/packaging"
+checksum=05af3bb85d320377db281cf254ab050e1a7ebcbf5410685a9a407e18a1f81236
+distfiles="${PYPI_SITE}/p/packaging/packaging-${version}.tar.gz"
+checksum=05af3bb85d320377db281cf254ab050e1a7ebcbf5410685a9a407e18a1f81236
+
+do_check() {
+	: provides no tests
+}
+
+post_install() {
+	vlicense LICENSE
+}

From 191150a157f7b222de6651e1e7b496f4f9120390 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Wed, 2 Dec 2020 13:58:38 -0500
Subject: [PATCH 4/5] build-style/python3-module: automatically detect pytest
 in do_check

---
 common/build-style/python3-module.sh | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/common/build-style/python3-module.sh b/common/build-style/python3-module.sh
index 14943d69356..4d9ecd3433b 100644
--- a/common/build-style/python3-module.sh
+++ b/common/build-style/python3-module.sh
@@ -30,20 +30,23 @@ do_build() {
 }
 
 do_check() {
-	if [ -n "$python_pep517" ]; then
-		msg_warn "No standard test exists for PEP517 Python templates"
+	if python3 -m pytest --help >/dev/null 2>&1; then
+		python3 -m pytest ${make_check_args} ${make_check_target}
+	elif [ -n "$python_pep517" ]; then
+		msg_warn "Unable to determine tests for PEP517 Python templates"
 		return 0
-	fi
-
-	if [ -z "$make_check_target" ]; then
-		if ! python3 setup.py --help test >/dev/null 2>&1; then
-			msg_warn "No command 'test' defined by setup.py.\n"
-			return 0
+	else
+		# Fall back to deprecated setup.py test orchestration without pytest
+		if [ -z "$make_check_target" ]; then
+			if ! python3 setup.py --help test >/dev/null 2>&1; then
+				msg_warn "No command 'test' defined by setup.py.\n"
+				return 0
+			fi
 		fi
-	fi
 
-	: ${make_check_target:=test}
-	python3 setup.py ${make_check_target} ${make_check_args}
+		: ${make_check_target:=test}
+		python3 setup.py ${make_check_target} ${make_check_args}
+	fi
 }
 
 do_install() {

From 195c58d56db4cf542c0dc2506e61d50dda78f718 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Wed, 2 Dec 2020 14:00:31 -0500
Subject: [PATCH 5/5] python3-tifffile: employ improved, automatic do_check

---
 srcpkgs/python3-tifffile/template | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/srcpkgs/python3-tifffile/template b/srcpkgs/python3-tifffile/template
index c5bf27a1424..1d6dcb2a522 100644
--- a/srcpkgs/python3-tifffile/template
+++ b/srcpkgs/python3-tifffile/template
@@ -15,10 +15,6 @@ changelog="https://raw.githubusercontent.com/cgohlke/tifffile/master/CHANGES.rst
 distfiles="${homepage}/archive/v${version}.tar.gz"
 checksum=64fc7602330301e910cc343e99bac02f9b453e933c1ee2050f316cbfee725df3
 
-do_check() {
-	python3 -m pytest
-}
-
 post_install() {
 	vlicense LICENSE
 }

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [RFC] Support for PEP517 build systems in python3-module
  2020-12-02 16:00 [PR PATCH] [RFC] Support for PEP517 build systems in python3-module ahesford
                   ` (8 preceding siblings ...)
  2020-12-02 19:30 ` [PR PATCH] [Updated] " ahesford
@ 2020-12-02 19:42 ` Johnnynator
  2020-12-02 19:59 ` ahesford
                   ` (11 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: Johnnynator @ 2020-12-02 19:42 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 385 bytes --]

New comment by Johnnynator on void-packages repository

https://github.com/void-linux/void-packages/pull/26883#issuecomment-737453232

Comment:
Why not do it as a seperate build_style? I would see it as a totally different build system and therefore it also should be in it's own build_style, especially since it already doesn't do it automatically but you need to manually set a var.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [RFC] Support for PEP517 build systems in python3-module
  2020-12-02 16:00 [PR PATCH] [RFC] Support for PEP517 build systems in python3-module ahesford
                   ` (9 preceding siblings ...)
  2020-12-02 19:42 ` Johnnynator
@ 2020-12-02 19:59 ` ahesford
  2020-12-02 20:21 ` [PR REVIEW] " Chocimier
                   ` (10 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: ahesford @ 2020-12-02 19:59 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 743 bytes --]

New comment by ahesford on void-packages repository

https://github.com/void-linux/void-packages/pull/26883#issuecomment-737461829

Comment:
On 2020-12-02 at 14:43 (UTC -0500), John Zimmermann wrote:
> Why not do it as a seperate build_style? I would see it as a totally
> different build system and therefore it also should be in it's own
> build_style, especially since it already doesn't do it automatically
> but you need to manually set a var.

I don't oppose splitting this into a separate build style. Are there
arguments against doing so?

If it does become its own style, any thoughts on the name? An obvious
choice is `python3-pep517`, but we could also go for something like
`python3-wheel` if "pep517" seems like inside baseball.


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PR REVIEW] [RFC] Support for PEP517 build systems in python3-module
  2020-12-02 16:00 [PR PATCH] [RFC] Support for PEP517 build systems in python3-module ahesford
                   ` (10 preceding siblings ...)
  2020-12-02 19:59 ` ahesford
@ 2020-12-02 20:21 ` Chocimier
  2020-12-02 23:37 ` fosslinux
                   ` (9 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: Chocimier @ 2020-12-02 20:21 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 172 bytes --]

New review comment by Chocimier on void-packages repository

https://github.com/void-linux/void-packages/pull/26883#discussion_r534456376

Comment:
Please leave a comment.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [RFC] Support for PEP517 build systems in python3-module
  2020-12-02 16:00 [PR PATCH] [RFC] Support for PEP517 build systems in python3-module ahesford
                   ` (11 preceding siblings ...)
  2020-12-02 20:21 ` [PR REVIEW] " Chocimier
@ 2020-12-02 23:37 ` fosslinux
  2020-12-03  3:43 ` [PR PATCH] [Updated] " ahesford
                   ` (8 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: fosslinux @ 2020-12-02 23:37 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 169 bytes --]

New comment by fosslinux on void-packages repository

https://github.com/void-linux/void-packages/pull/26883#issuecomment-737561118

Comment:
I agree with @Johnnynator 

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PR PATCH] [Updated] [RFC] Support for PEP517 build systems in python3-module
  2020-12-02 16:00 [PR PATCH] [RFC] Support for PEP517 build systems in python3-module ahesford
                   ` (12 preceding siblings ...)
  2020-12-02 23:37 ` fosslinux
@ 2020-12-03  3:43 ` ahesford
  2020-12-03  3:52 ` ahesford
                   ` (7 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: ahesford @ 2020-12-03  3:43 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 2539 bytes --]

There is an updated pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages packaging
https://github.com/void-linux/void-packages/pull/26883

[RFC] Support for PEP517 build systems in python3-module
I [have been told](https://github.com/pypa/packaging/issues/363) that PEP517 build systems are the way of the future for Python package building and installation, and `setuptools` will become (or is now) disfavored. `python3-packaging` is the first of our packages to drop `setuptools` and specifically require a PEP517 builder.

This is an attempt to support PEP517 builds in our `python3-module` build style. For now, the preferred (only?) way to do PEP517 builds is to rely on `pip` to do the work. Fortunately, because no PEP517 builder supports compiled extensions, we can avoid the pain of trying to force `pip` to behave with cross compilers (for now).

Use of the PEP517 build procedure in a template is enabled by setting `python_pep517=yes`. If this is adopted, we'll have to modify `xlint` as well.

`pip` can do a one-pass build and install, but I figured it was better to split into a build-wheel stage and an install-wheel stage so people can do `./xbps-src build` and investigate the artifacts.

I am not thrilled with the use of globs in `do_install` when setting a default `$python_pep517_wheel` but, according to [PEP 427](https://www.python.org/dev/peps/pep-0427/#file-name-convention) and its referenced [PEP 425](https://www.python.org/dev/peps/pep-0425), the filename components I'm trying to match with the globs are not easily predicted. In any case, if this produces undesirable behavior in specific templates, the author can manually set that variable. Any other ideas are welcome.

Finally, the build process produces `direct_url.json` in the Python `dist-info` directory to comply with [PEP 610](https://www.python.org/dev/peps/pep-0610), which replaces a simple version number in `pip freeze` output with a `file://` URL pointing to the location of the wheel used for installation. (In our case, this will be `/builddir/$wrksrc/$build_wrksrc/$python_pep517_wheel`.) For distribution packages, I do not believe this is desirable. We can manually remove the file, for example in `do_install`, assuming the `dist-info` directory is predictable. Comments about doing this are welcome.

cc: any @void-linux/pkg-committers with a stake in Python packages

A patch file from https://github.com/void-linux/void-packages/pull/26883.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-packaging-26883.patch --]
[-- Type: text/x-diff, Size: 17002 bytes --]

From 36746748984d41c40cfad6eba80f8c76ff8ca41a Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Wed, 2 Dec 2020 22:20:18 -0500
Subject: [PATCH 1/3] build-style/python3-pep517: new style for PEP517 Python
 packages

---
 Manual.md                                     |  8 +++--
 common/build-style/python3-pep517.sh          | 31 +++++++++++++++++++
 .../environment/build-style/python3-pep517.sh |  2 ++
 3 files changed, 38 insertions(+), 3 deletions(-)
 create mode 100644 common/build-style/python3-pep517.sh
 create mode 100644 common/environment/build-style/python3-pep517.sh

diff --git a/Manual.md b/Manual.md
index 7647f957129..dc31abfd522 100644
--- a/Manual.md
+++ b/Manual.md
@@ -1479,9 +1479,11 @@ be your guidance to decide whether or not to split off a `-doc` subpackage.
 <a id="pkgs_python"></a>
 ### Python packages
 
-Python packages should be built with the `python{,2,3}-module` build style, if possible.
-This sets some environment variables required to allow cross compilation. Support to allow
-building a python module for multiple versions from a single template is also possible.
+Python packages should be built with the `python{,2,3}-module` build style, if possible.  This sets
+some environment variables required to allow cross compilation. Support to allow building a python
+module for multiple versions from a single template is also possible. The `python3-pep517` build
+style provides means to build python packages that provide a build-system definition compliant with
+[PEP 517](https://www.python.org/dev/peps/pep-0517/) without a traditional `setup.py` script.
 
 Python packages that rely on `python3-setuptools` should generally map `setup_requires`
 dependencies in `setup.py` to `hostmakedepends` in the template and `install_requires`
diff --git a/common/build-style/python3-pep517.sh b/common/build-style/python3-pep517.sh
new file mode 100644
index 00000000000..1a3c6d31eed
--- /dev/null
+++ b/common/build-style/python3-pep517.sh
@@ -0,0 +1,31 @@
+#
+# This style is for templates installing python3 modules adhering to PEP517
+#
+
+do_build() {
+	# No PEP517 build tool currently supports compiled extensions
+	# Thus, there is no need to accommodate cross compilation here
+	: ${make_build_target:=.}
+
+	mkdir -p build
+	TMPDIR=build python3 -m pip wheel --no-deps --use-pep517 --no-clean \
+		--no-build-isolation ${make_build_args} ${make_build_target}
+}
+
+do_check() {
+	if python3 -m pytest --help >/dev/null 2>&1; then
+		python3 -m pytest ${make_check_args} ${make_check_target}
+	else
+		msg_warn "Unable to determine tests for PEP517 Python templates"
+		return 0
+	fi
+}
+
+do_install() {
+	# As with do_build, no need to accommodate cross compilation here
+	: ${make_install_target:=${pkgname#python3-}-${version}-*-*-*.whl}
+
+	TMPDIR=build python3 -m pip install --use-pep517 --prefix /usr \
+		--root ${DESTDIR} --no-deps --no-build-isolation \
+		--no-clean ${make_install_args} ${make_install_target}
+}
diff --git a/common/environment/build-style/python3-pep517.sh b/common/environment/build-style/python3-pep517.sh
new file mode 100644
index 00000000000..48f0c1b17f4
--- /dev/null
+++ b/common/environment/build-style/python3-pep517.sh
@@ -0,0 +1,2 @@
+hostmakedepends+=" python3-pip"
+lib32disabled=yes

From 932036e36b68f28fed971536fdeeeb20b341b8b9 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Wed, 2 Dec 2020 08:08:33 -0500
Subject: [PATCH 2/3] New package: python3-flit_core-3.0.0

---
 .../python3-flit_core/patches/use_toml.patch  | 254 ++++++++++++++++++
 srcpkgs/python3-flit_core/template            |  23 ++
 2 files changed, 277 insertions(+)
 create mode 100644 srcpkgs/python3-flit_core/patches/use_toml.patch
 create mode 100644 srcpkgs/python3-flit_core/template

diff --git a/srcpkgs/python3-flit_core/patches/use_toml.patch b/srcpkgs/python3-flit_core/patches/use_toml.patch
new file mode 100644
index 00000000000..8a0a668f616
--- /dev/null
+++ b/srcpkgs/python3-flit_core/patches/use_toml.patch
@@ -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 doc/development.rst doc/development.rst
+index 9b8dc5e..f714999 100644
+--- doc/development.rst
++++ 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 doc/pyproject_toml.rst doc/pyproject_toml.rst
+index f9ddc7f..8d38bf9 100644
+--- doc/pyproject_toml.rst
++++ 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 flit/init.py flit/init.py
+index f7ea93a..b0c77c6 100644
+--- flit/init.py
++++ 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 flit/tomlify.py flit/tomlify.py
+index 0c8db69..a9c9c60 100644
+--- flit/tomlify.py
++++ 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 flit_core/flit_core/build_thyself.py flit_core/flit_core/build_thyself.py
+index 7daf67f..f3aaf7c 100644
+--- flit_core/flit_core/build_thyself.py
++++ 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 flit_core/flit_core/config.py flit_core/flit_core/config.py
+index 0af9c00..6ed20d3 100644
+--- flit_core/flit_core/config.py
++++ 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 flit_core/flit_core/sdist.py flit_core/flit_core/sdist.py
+index 1fe5bb4..963b4e5 100644
+--- flit_core/flit_core/sdist.py
++++ 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 flit_core/flit_core/wheel.py flit_core/flit_core/wheel.py
+index 1550846..2bc55e1 100644
+--- flit_core/flit_core/wheel.py
++++ 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 pyproject.toml pyproject.toml
+index ac8d001..0af74b2 100644
+--- pyproject.toml
++++ 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 tests/test_init.py tests/test_init.py
+index fb8ad4d..7330ff5 100644
+--- tests/test_init.py
++++ 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 tests/test_tomlify.py tests/test_tomlify.py
+index 2bd75dc..a7b7978 100644
+--- tests/test_tomlify.py
++++ 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 tox.ini tox.ini
+index 08ce1bf..d1025e1 100644
+--- tox.ini
++++ tox.ini
+@@ -18,7 +18,7 @@ deps =
+     testpath
+     responses
+     docutils
+-    pytoml
++    toml
+     pytest>=2.7.3
+     pytest-cov
+ 
diff --git a/srcpkgs/python3-flit_core/template b/srcpkgs/python3-flit_core/template
new file mode 100644
index 00000000000..f3b166c60ff
--- /dev/null
+++ b/srcpkgs/python3-flit_core/template
@@ -0,0 +1,23 @@
+# Template file for 'python3-flit_core'
+pkgname=python3-flit_core
+version=3.0.0
+revision=1
+wrksrc="flit-${version}"
+build_wrksrc="flit_core"
+build_style=python3-pep517
+depends="python3-toml"
+short_desc="Simplified packaging of Python modules - PEP 517 build backend"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="BSD-3-Clause"
+homepage="https://flit.readthedocs.io"
+changelog="https://flit.readthedocs.io/en/latest/history.html"
+distfiles="${PYPI_SITE}/f/flit/flit-${version}.tar.gz"
+checksum=b4fe0f84a1ffbf125d003e253ec98c0b6e3e31290b31fba3ad22d28588c20893
+
+do_check() {
+	: provides no tests
+}
+
+post_install() {
+	vlicense ../LICENSE
+}

From 719be4d2e51a4248134f27d3d3f60879bf4e3d9f Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Wed, 2 Dec 2020 10:28:38 -0500
Subject: [PATCH 3/3] python-packaging: split package

New package: python3-packaging-20.7
---
 srcpkgs/python-packaging/template  | 20 +++++---------------
 srcpkgs/python-packaging/update    |  3 +++
 srcpkgs/python3-packaging          |  1 -
 srcpkgs/python3-packaging/template | 23 +++++++++++++++++++++++
 4 files changed, 31 insertions(+), 16 deletions(-)
 create mode 100644 srcpkgs/python-packaging/update
 delete mode 120000 srcpkgs/python3-packaging
 create mode 100644 srcpkgs/python3-packaging/template

diff --git a/srcpkgs/python-packaging/template b/srcpkgs/python-packaging/template
index e36a04a1540..aa1f64182d7 100644
--- a/srcpkgs/python-packaging/template
+++ b/srcpkgs/python-packaging/template
@@ -1,29 +1,19 @@
 # Template file for 'python-packaging'
 pkgname=python-packaging
 version=20.4
-revision=1
+revision=2
 wrksrc="packaging-${version}"
-build_style=python-module
-pycompile_module="packaging"
-hostmakedepends="python-setuptools python3-setuptools"
-depends="python-attrs python-parsing python-six"
+build_style=python2-module
+hostmakedepends="python-setuptools"
+depends="python-parsing python-six"
 short_desc="Core utilities for Python packages (Python2)"
 maintainer="Alessio Sergi <al3hex@gmail.com>"
 license="Apache-2.0, BSD-2-Clause"
 homepage="https://github.com/pypa/packaging"
+changelog="https://raw.githubusercontent.com/pypa/packaging/master/CHANGELOG.rst"
 distfiles="${PYPI_SITE}/p/packaging/packaging-${version}.tar.gz"
 checksum=4357f74f47b9c12db93624a82154e9b120fa8293699949152b22065d556079f8
 
 post_install() {
 	vlicense LICENSE
 }
-
-python3-packaging_package() {
-	pycompile_module="packaging"
-	depends="python3-attrs python3-parsing python3-six"
-	short_desc="${short_desc/Python2/Python3}"
-	pkg_install() {
-		vmove usr/lib/python3*
-		vlicense LICENSE
-	}
-}
diff --git a/srcpkgs/python-packaging/update b/srcpkgs/python-packaging/update
new file mode 100644
index 00000000000..3b1a41fb94a
--- /dev/null
+++ b/srcpkgs/python-packaging/update
@@ -0,0 +1,3 @@
+# packaging >= 20.5 drops setuptools for flit, which is py3-only;
+# prevent update hits on newer versions since they require py3 to build
+pattern="packaging-\K20\.4(\.[0-9.]+)?(?=.tar.gz)"
diff --git a/srcpkgs/python3-packaging b/srcpkgs/python3-packaging
deleted file mode 120000
index 98299fdb1d7..00000000000
--- a/srcpkgs/python3-packaging
+++ /dev/null
@@ -1 +0,0 @@
-python-packaging
\ No newline at end of file
diff --git a/srcpkgs/python3-packaging/template b/srcpkgs/python3-packaging/template
new file mode 100644
index 00000000000..a4323dad4d6
--- /dev/null
+++ b/srcpkgs/python3-packaging/template
@@ -0,0 +1,23 @@
+# Template file for 'python3-packaging'
+pkgname=python3-packaging
+version=20.7
+revision=1
+wrksrc="packaging-${version}"
+build_style=python3-pep517
+hostmakedepends="python3-flit_core"
+depends="python3-parsing"
+checkdepends="python3-pytest"
+short_desc="Core utilities for Python packages (Python3)"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="Apache-2.0, BSD-2-Clause"
+homepage="https://github.com/pypa/packaging"
+distfiles="${PYPI_SITE}/p/packaging/packaging-${version}.tar.gz"
+checksum=05af3bb85d320377db281cf254ab050e1a7ebcbf5410685a9a407e18a1f81236
+
+do_check() {
+	: provides no tests
+}
+
+post_install() {
+	vlicense LICENSE
+}

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [RFC] Support for PEP517 build systems in python3-module
  2020-12-02 16:00 [PR PATCH] [RFC] Support for PEP517 build systems in python3-module ahesford
                   ` (13 preceding siblings ...)
  2020-12-03  3:43 ` [PR PATCH] [Updated] " ahesford
@ 2020-12-03  3:52 ` ahesford
  2020-12-05 16:29 ` [RFC] Support for PEP517 build systems with new build style Chocimier
                   ` (6 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: ahesford @ 2020-12-03  3:52 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 671 bytes --]

New comment by ahesford on void-packages repository

https://github.com/void-linux/void-packages/pull/26883#issuecomment-737648438

Comment:
Comment added to `update` restriction on `python-packaging`, created a separate `python3-pep517` build style and updated the manual. This simplified some things, and I moved the `pytest` adoption in `python3-module` to #26901 for separate consideration.

While doing a separate build style, I decided to allow `$make_build_target` to override the default `$PWD` target when necessary, and uesd `$make_install_target` instead of a new variable to select the wheel used for installation. This avoids the need for an xlint update.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [RFC] Support for PEP517 build systems with new build style
  2020-12-02 16:00 [PR PATCH] [RFC] Support for PEP517 build systems in python3-module ahesford
                   ` (14 preceding siblings ...)
  2020-12-03  3:52 ` ahesford
@ 2020-12-05 16:29 ` Chocimier
  2020-12-06  5:48 ` [PR PATCH] [Updated] " ahesford
                   ` (5 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: Chocimier @ 2020-12-05 16:29 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 423 bytes --]

New comment by Chocimier on void-packages repository

https://github.com/void-linux/void-packages/pull/26883#issuecomment-739317579

Comment:
`make_*_target` needs documentation, as they are used a bit different than in make-based build styles.
Add new build style to _build style scripts_ section too.
Please do not reformat existing manual sections when they stay with same content. Minimal, meaningful diffs are good.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PR PATCH] [Updated] [RFC] Support for PEP517 build systems with new build style
  2020-12-02 16:00 [PR PATCH] [RFC] Support for PEP517 build systems in python3-module ahesford
                   ` (15 preceding siblings ...)
  2020-12-05 16:29 ` [RFC] Support for PEP517 build systems with new build style Chocimier
@ 2020-12-06  5:48 ` ahesford
  2020-12-06  5:53 ` ahesford
                   ` (4 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: ahesford @ 2020-12-06  5:48 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 2542 bytes --]

There is an updated pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages packaging
https://github.com/void-linux/void-packages/pull/26883

[RFC] Support for PEP517 build systems with new build style
I [have been told](https://github.com/pypa/packaging/issues/363) that PEP517 build systems are the way of the future for Python package building and installation, and `setuptools` will become (or is now) disfavored. `python3-packaging` is the first of our packages to drop `setuptools` and specifically require a PEP517 builder.

This is an attempt to support PEP517 builds in our `python3-module` build style. For now, the preferred (only?) way to do PEP517 builds is to rely on `pip` to do the work. Fortunately, because no PEP517 builder supports compiled extensions, we can avoid the pain of trying to force `pip` to behave with cross compilers (for now).

Use of the PEP517 build procedure in a template is enabled by setting `python_pep517=yes`. If this is adopted, we'll have to modify `xlint` as well.

`pip` can do a one-pass build and install, but I figured it was better to split into a build-wheel stage and an install-wheel stage so people can do `./xbps-src build` and investigate the artifacts.

I am not thrilled with the use of globs in `do_install` when setting a default `$python_pep517_wheel` but, according to [PEP 427](https://www.python.org/dev/peps/pep-0427/#file-name-convention) and its referenced [PEP 425](https://www.python.org/dev/peps/pep-0425), the filename components I'm trying to match with the globs are not easily predicted. In any case, if this produces undesirable behavior in specific templates, the author can manually set that variable. Any other ideas are welcome.

Finally, the build process produces `direct_url.json` in the Python `dist-info` directory to comply with [PEP 610](https://www.python.org/dev/peps/pep-0610), which replaces a simple version number in `pip freeze` output with a `file://` URL pointing to the location of the wheel used for installation. (In our case, this will be `/builddir/$wrksrc/$build_wrksrc/$python_pep517_wheel`.) For distribution packages, I do not believe this is desirable. We can manually remove the file, for example in `do_install`, assuming the `dist-info` directory is predictable. Comments about doing this are welcome.

cc: any @void-linux/pkg-committers with a stake in Python packages

A patch file from https://github.com/void-linux/void-packages/pull/26883.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-packaging-26883.patch --]
[-- Type: text/x-diff, Size: 18718 bytes --]

From f4cb9e9526f735bd347725b1d6165e989fb27218 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Wed, 2 Dec 2020 22:20:18 -0500
Subject: [PATCH 1/3] build-style/python3-pep517: new style for PEP517 Python
 packages

---
 Manual.md                                     | 22 ++++++++-----
 common/build-style/python3-pep517.sh          | 31 +++++++++++++++++++
 .../environment/build-style/python3-pep517.sh |  2 ++
 3 files changed, 48 insertions(+), 7 deletions(-)
 create mode 100644 common/build-style/python3-pep517.sh
 create mode 100644 common/environment/build-style/python3-pep517.sh

diff --git a/Manual.md b/Manual.md
index 7647f957129..3c4807a7c58 100644
--- a/Manual.md
+++ b/Manual.md
@@ -561,17 +561,22 @@ phase if `${build_style}` is set to `configure`, `gnu-configure` or
 `gnu-makefile` build methods. By default set to
 `PREFIX=/usr DESTDIR=${DESTDIR}`.
 
-- `make_build_target` The target to be passed in to `${make_cmd}` at the build phase if
-`${build_style}` is set to `configure`, `gnu-configure` or `gnu-makefile`
-build methods. Unset by default (`all` target).
+- `make_build_target` The build target. If `${build_style}` is set to `configure`, `gnu-configure`
+or `gnu-makefile`, this is the target passed to `${make_cmd}` in the build phase; when unset, it
+defaults to `all`. If `${build_style}` is `python3-pep517`, this is the path of the package
+directory that should be built as a Python wheel; when unset, defaults to `.` (the current
+directory with respect to the build).
 
 - `make_check_target` The target to be passed in to `${make_cmd}` at the check phase if
 `${build_style}` is set to `configure`, `gnu-configure` or `gnu-makefile`
 build methods. By default set to `check`.
 
-- `make_install_target` The target to be passed in to `${make_cmd}` at the `install-destdir` phase
-if `${build_style}` is set to `configure`, `gnu-configure` or `gnu-makefile`
-build methods. By default set to `install`.
+- `make_install_target` The installation target. When `${build_style}` is set to `configure`,
+`gnu-configure` or `gnu-makefile`, this is the target passed to `${make_command}` in the install
+phase; when unset, it defaults to `install`. If `${build_style}` is `python-pep517`, this is the
+path of the Python wheel produced by the build phase that will be installed; when unset, the
+`python-pep517` build style will look for a wheel matching the package name and version in the
+current directory with respect to the install.
 
 - `patch_args` The arguments to be passed in to the `patch(1)` command when applying
 patches to the package sources during `do_patch()`. Patches are stored in
@@ -1481,7 +1486,10 @@ be your guidance to decide whether or not to split off a `-doc` subpackage.
 
 Python packages should be built with the `python{,2,3}-module` build style, if possible.
 This sets some environment variables required to allow cross compilation. Support to allow
-building a python module for multiple versions from a single template is also possible.
+building a python module for multiple versions from a single template is also possible. The
+`python3-pep517` build style provides means to build python packages that provide a build-system
+definition compliant with [PEP 517](https://www.python.org/dev/peps/pep-0517/) without a traditional
+`setup.py` script.
 
 Python packages that rely on `python3-setuptools` should generally map `setup_requires`
 dependencies in `setup.py` to `hostmakedepends` in the template and `install_requires`
diff --git a/common/build-style/python3-pep517.sh b/common/build-style/python3-pep517.sh
new file mode 100644
index 00000000000..1a3c6d31eed
--- /dev/null
+++ b/common/build-style/python3-pep517.sh
@@ -0,0 +1,31 @@
+#
+# This style is for templates installing python3 modules adhering to PEP517
+#
+
+do_build() {
+	# No PEP517 build tool currently supports compiled extensions
+	# Thus, there is no need to accommodate cross compilation here
+	: ${make_build_target:=.}
+
+	mkdir -p build
+	TMPDIR=build python3 -m pip wheel --no-deps --use-pep517 --no-clean \
+		--no-build-isolation ${make_build_args} ${make_build_target}
+}
+
+do_check() {
+	if python3 -m pytest --help >/dev/null 2>&1; then
+		python3 -m pytest ${make_check_args} ${make_check_target}
+	else
+		msg_warn "Unable to determine tests for PEP517 Python templates"
+		return 0
+	fi
+}
+
+do_install() {
+	# As with do_build, no need to accommodate cross compilation here
+	: ${make_install_target:=${pkgname#python3-}-${version}-*-*-*.whl}
+
+	TMPDIR=build python3 -m pip install --use-pep517 --prefix /usr \
+		--root ${DESTDIR} --no-deps --no-build-isolation \
+		--no-clean ${make_install_args} ${make_install_target}
+}
diff --git a/common/environment/build-style/python3-pep517.sh b/common/environment/build-style/python3-pep517.sh
new file mode 100644
index 00000000000..48f0c1b17f4
--- /dev/null
+++ b/common/environment/build-style/python3-pep517.sh
@@ -0,0 +1,2 @@
+hostmakedepends+=" python3-pip"
+lib32disabled=yes

From e60c5bbdaa74b957cdd9c9cdacbf1ef54ef1ca14 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Wed, 2 Dec 2020 08:08:33 -0500
Subject: [PATCH 2/3] New package: python3-flit_core-3.0.0

---
 .../python3-flit_core/patches/use_toml.patch  | 254 ++++++++++++++++++
 srcpkgs/python3-flit_core/template            |  23 ++
 2 files changed, 277 insertions(+)
 create mode 100644 srcpkgs/python3-flit_core/patches/use_toml.patch
 create mode 100644 srcpkgs/python3-flit_core/template

diff --git a/srcpkgs/python3-flit_core/patches/use_toml.patch b/srcpkgs/python3-flit_core/patches/use_toml.patch
new file mode 100644
index 00000000000..8a0a668f616
--- /dev/null
+++ b/srcpkgs/python3-flit_core/patches/use_toml.patch
@@ -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 doc/development.rst doc/development.rst
+index 9b8dc5e..f714999 100644
+--- doc/development.rst
++++ 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 doc/pyproject_toml.rst doc/pyproject_toml.rst
+index f9ddc7f..8d38bf9 100644
+--- doc/pyproject_toml.rst
++++ 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 flit/init.py flit/init.py
+index f7ea93a..b0c77c6 100644
+--- flit/init.py
++++ 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 flit/tomlify.py flit/tomlify.py
+index 0c8db69..a9c9c60 100644
+--- flit/tomlify.py
++++ 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 flit_core/flit_core/build_thyself.py flit_core/flit_core/build_thyself.py
+index 7daf67f..f3aaf7c 100644
+--- flit_core/flit_core/build_thyself.py
++++ 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 flit_core/flit_core/config.py flit_core/flit_core/config.py
+index 0af9c00..6ed20d3 100644
+--- flit_core/flit_core/config.py
++++ 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 flit_core/flit_core/sdist.py flit_core/flit_core/sdist.py
+index 1fe5bb4..963b4e5 100644
+--- flit_core/flit_core/sdist.py
++++ 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 flit_core/flit_core/wheel.py flit_core/flit_core/wheel.py
+index 1550846..2bc55e1 100644
+--- flit_core/flit_core/wheel.py
++++ 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 pyproject.toml pyproject.toml
+index ac8d001..0af74b2 100644
+--- pyproject.toml
++++ 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 tests/test_init.py tests/test_init.py
+index fb8ad4d..7330ff5 100644
+--- tests/test_init.py
++++ 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 tests/test_tomlify.py tests/test_tomlify.py
+index 2bd75dc..a7b7978 100644
+--- tests/test_tomlify.py
++++ 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 tox.ini tox.ini
+index 08ce1bf..d1025e1 100644
+--- tox.ini
++++ tox.ini
+@@ -18,7 +18,7 @@ deps =
+     testpath
+     responses
+     docutils
+-    pytoml
++    toml
+     pytest>=2.7.3
+     pytest-cov
+ 
diff --git a/srcpkgs/python3-flit_core/template b/srcpkgs/python3-flit_core/template
new file mode 100644
index 00000000000..f3b166c60ff
--- /dev/null
+++ b/srcpkgs/python3-flit_core/template
@@ -0,0 +1,23 @@
+# Template file for 'python3-flit_core'
+pkgname=python3-flit_core
+version=3.0.0
+revision=1
+wrksrc="flit-${version}"
+build_wrksrc="flit_core"
+build_style=python3-pep517
+depends="python3-toml"
+short_desc="Simplified packaging of Python modules - PEP 517 build backend"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="BSD-3-Clause"
+homepage="https://flit.readthedocs.io"
+changelog="https://flit.readthedocs.io/en/latest/history.html"
+distfiles="${PYPI_SITE}/f/flit/flit-${version}.tar.gz"
+checksum=b4fe0f84a1ffbf125d003e253ec98c0b6e3e31290b31fba3ad22d28588c20893
+
+do_check() {
+	: provides no tests
+}
+
+post_install() {
+	vlicense ../LICENSE
+}

From 901c4f9ac021eff0fcbd12c69f0a1dc2c902dd1d Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Wed, 2 Dec 2020 10:28:38 -0500
Subject: [PATCH 3/3] python-packaging: split package

New package: python3-packaging-20.7
---
 srcpkgs/python-packaging/template  | 20 +++++---------------
 srcpkgs/python-packaging/update    |  3 +++
 srcpkgs/python3-packaging          |  1 -
 srcpkgs/python3-packaging/template | 23 +++++++++++++++++++++++
 4 files changed, 31 insertions(+), 16 deletions(-)
 create mode 100644 srcpkgs/python-packaging/update
 delete mode 120000 srcpkgs/python3-packaging
 create mode 100644 srcpkgs/python3-packaging/template

diff --git a/srcpkgs/python-packaging/template b/srcpkgs/python-packaging/template
index e36a04a1540..aa1f64182d7 100644
--- a/srcpkgs/python-packaging/template
+++ b/srcpkgs/python-packaging/template
@@ -1,29 +1,19 @@
 # Template file for 'python-packaging'
 pkgname=python-packaging
 version=20.4
-revision=1
+revision=2
 wrksrc="packaging-${version}"
-build_style=python-module
-pycompile_module="packaging"
-hostmakedepends="python-setuptools python3-setuptools"
-depends="python-attrs python-parsing python-six"
+build_style=python2-module
+hostmakedepends="python-setuptools"
+depends="python-parsing python-six"
 short_desc="Core utilities for Python packages (Python2)"
 maintainer="Alessio Sergi <al3hex@gmail.com>"
 license="Apache-2.0, BSD-2-Clause"
 homepage="https://github.com/pypa/packaging"
+changelog="https://raw.githubusercontent.com/pypa/packaging/master/CHANGELOG.rst"
 distfiles="${PYPI_SITE}/p/packaging/packaging-${version}.tar.gz"
 checksum=4357f74f47b9c12db93624a82154e9b120fa8293699949152b22065d556079f8
 
 post_install() {
 	vlicense LICENSE
 }
-
-python3-packaging_package() {
-	pycompile_module="packaging"
-	depends="python3-attrs python3-parsing python3-six"
-	short_desc="${short_desc/Python2/Python3}"
-	pkg_install() {
-		vmove usr/lib/python3*
-		vlicense LICENSE
-	}
-}
diff --git a/srcpkgs/python-packaging/update b/srcpkgs/python-packaging/update
new file mode 100644
index 00000000000..3b1a41fb94a
--- /dev/null
+++ b/srcpkgs/python-packaging/update
@@ -0,0 +1,3 @@
+# packaging >= 20.5 drops setuptools for flit, which is py3-only;
+# prevent update hits on newer versions since they require py3 to build
+pattern="packaging-\K20\.4(\.[0-9.]+)?(?=.tar.gz)"
diff --git a/srcpkgs/python3-packaging b/srcpkgs/python3-packaging
deleted file mode 120000
index 98299fdb1d7..00000000000
--- a/srcpkgs/python3-packaging
+++ /dev/null
@@ -1 +0,0 @@
-python-packaging
\ No newline at end of file
diff --git a/srcpkgs/python3-packaging/template b/srcpkgs/python3-packaging/template
new file mode 100644
index 00000000000..a4323dad4d6
--- /dev/null
+++ b/srcpkgs/python3-packaging/template
@@ -0,0 +1,23 @@
+# Template file for 'python3-packaging'
+pkgname=python3-packaging
+version=20.7
+revision=1
+wrksrc="packaging-${version}"
+build_style=python3-pep517
+hostmakedepends="python3-flit_core"
+depends="python3-parsing"
+checkdepends="python3-pytest"
+short_desc="Core utilities for Python packages (Python3)"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="Apache-2.0, BSD-2-Clause"
+homepage="https://github.com/pypa/packaging"
+distfiles="${PYPI_SITE}/p/packaging/packaging-${version}.tar.gz"
+checksum=05af3bb85d320377db281cf254ab050e1a7ebcbf5410685a9a407e18a1f81236
+
+do_check() {
+	: provides no tests
+}
+
+post_install() {
+	vlicense LICENSE
+}

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PR PATCH] [Updated] [RFC] Support for PEP517 build systems with new build style
  2020-12-02 16:00 [PR PATCH] [RFC] Support for PEP517 build systems in python3-module ahesford
                   ` (16 preceding siblings ...)
  2020-12-06  5:48 ` [PR PATCH] [Updated] " ahesford
@ 2020-12-06  5:53 ` ahesford
  2020-12-06  5:56 ` ahesford
                   ` (3 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: ahesford @ 2020-12-06  5:53 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 2542 bytes --]

There is an updated pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages packaging
https://github.com/void-linux/void-packages/pull/26883

[RFC] Support for PEP517 build systems with new build style
I [have been told](https://github.com/pypa/packaging/issues/363) that PEP517 build systems are the way of the future for Python package building and installation, and `setuptools` will become (or is now) disfavored. `python3-packaging` is the first of our packages to drop `setuptools` and specifically require a PEP517 builder.

This is an attempt to support PEP517 builds in our `python3-module` build style. For now, the preferred (only?) way to do PEP517 builds is to rely on `pip` to do the work. Fortunately, because no PEP517 builder supports compiled extensions, we can avoid the pain of trying to force `pip` to behave with cross compilers (for now).

Use of the PEP517 build procedure in a template is enabled by setting `python_pep517=yes`. If this is adopted, we'll have to modify `xlint` as well.

`pip` can do a one-pass build and install, but I figured it was better to split into a build-wheel stage and an install-wheel stage so people can do `./xbps-src build` and investigate the artifacts.

I am not thrilled with the use of globs in `do_install` when setting a default `$python_pep517_wheel` but, according to [PEP 427](https://www.python.org/dev/peps/pep-0427/#file-name-convention) and its referenced [PEP 425](https://www.python.org/dev/peps/pep-0425), the filename components I'm trying to match with the globs are not easily predicted. In any case, if this produces undesirable behavior in specific templates, the author can manually set that variable. Any other ideas are welcome.

Finally, the build process produces `direct_url.json` in the Python `dist-info` directory to comply with [PEP 610](https://www.python.org/dev/peps/pep-0610), which replaces a simple version number in `pip freeze` output with a `file://` URL pointing to the location of the wheel used for installation. (In our case, this will be `/builddir/$wrksrc/$build_wrksrc/$python_pep517_wheel`.) For distribution packages, I do not believe this is desirable. We can manually remove the file, for example in `do_install`, assuming the `dist-info` directory is predictable. Comments about doing this are welcome.

cc: any @void-linux/pkg-committers with a stake in Python packages

A patch file from https://github.com/void-linux/void-packages/pull/26883.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-packaging-26883.patch --]
[-- Type: text/x-diff, Size: 19606 bytes --]

From 43ff042b7ae28259963ed034f0762d228d82e6d0 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Wed, 2 Dec 2020 22:20:18 -0500
Subject: [PATCH 1/3] build-style/python3-pep517: new style for PEP517 Python
 packages

---
 Manual.md                                     | 29 +++++++++++------
 common/build-style/python3-pep517.sh          | 31 +++++++++++++++++++
 .../environment/build-style/python3-pep517.sh |  2 ++
 3 files changed, 53 insertions(+), 9 deletions(-)
 create mode 100644 common/build-style/python3-pep517.sh
 create mode 100644 common/environment/build-style/python3-pep517.sh

diff --git a/Manual.md b/Manual.md
index 7647f957129..79667b103f7 100644
--- a/Manual.md
+++ b/Manual.md
@@ -561,17 +561,22 @@ phase if `${build_style}` is set to `configure`, `gnu-configure` or
 `gnu-makefile` build methods. By default set to
 `PREFIX=/usr DESTDIR=${DESTDIR}`.
 
-- `make_build_target` The target to be passed in to `${make_cmd}` at the build phase if
-`${build_style}` is set to `configure`, `gnu-configure` or `gnu-makefile`
-build methods. Unset by default (`all` target).
+- `make_build_target` The build target. If `${build_style}` is set to `configure`, `gnu-configure`
+or `gnu-makefile`, this is the target passed to `${make_cmd}` in the build phase; when unset, it
+defaults to `all`. If `${build_style}` is `python3-pep517`, this is the path of the package
+directory that should be built as a Python wheel; when unset, defaults to `.` (the current
+directory with respect to the build).
 
 - `make_check_target` The target to be passed in to `${make_cmd}` at the check phase if
 `${build_style}` is set to `configure`, `gnu-configure` or `gnu-makefile`
 build methods. By default set to `check`.
 
-- `make_install_target` The target to be passed in to `${make_cmd}` at the `install-destdir` phase
-if `${build_style}` is set to `configure`, `gnu-configure` or `gnu-makefile`
-build methods. By default set to `install`.
+- `make_install_target` The installation target. When `${build_style}` is set to `configure`,
+`gnu-configure` or `gnu-makefile`, this is the target passed to `${make_command}` in the install
+phase; when unset, it defaults to `install`. If `${build_style}` is `python-pep517`, this is the
+path of the Python wheel produced by the build phase that will be installed; when unset, the
+`python-pep517` build style will look for a wheel matching the package name and version in the
+current directory with respect to the install.
 
 - `patch_args` The arguments to be passed in to the `patch(1)` command when applying
 patches to the package sources during `do_patch()`. Patches are stored in
@@ -952,8 +957,8 @@ via `make_install_target`.
 via `configure_args`, the meson command can be overridden by `meson_cmd` and the location of
 the out of source build by `meson_builddir`
 
-For packages that use the Python module build method (`setup.py`), you
-can choose one of the following:
+For packages that use the Python module build method (`setup.py` or
+[PEP 517](https://www.python.org/dev/peps/pep-0517/)), you can choose one of the following:
 
 - `python-module` to build *both* Python 2.x and 3.x modules
 
@@ -961,6 +966,9 @@ can choose one of the following:
 
 - `python3-module` to build Python 3.x only modules
 
+- `python3-pep517` to build Python 3.x only modules that provide a PEP 517 build description without
+a `setup.py` script
+
 Environment variables for a specific `build_style` can be declared in a filename
 matching the `build_style` name, Example:
 
@@ -1481,7 +1489,10 @@ be your guidance to decide whether or not to split off a `-doc` subpackage.
 
 Python packages should be built with the `python{,2,3}-module` build style, if possible.
 This sets some environment variables required to allow cross compilation. Support to allow
-building a python module for multiple versions from a single template is also possible.
+building a python module for multiple versions from a single template is also possible. The
+`python3-pep517` build style provides means to build python packages that provide a build-system
+definition compliant with [PEP 517](https://www.python.org/dev/peps/pep-0517/) without a traditional
+`setup.py` script.
 
 Python packages that rely on `python3-setuptools` should generally map `setup_requires`
 dependencies in `setup.py` to `hostmakedepends` in the template and `install_requires`
diff --git a/common/build-style/python3-pep517.sh b/common/build-style/python3-pep517.sh
new file mode 100644
index 00000000000..1a3c6d31eed
--- /dev/null
+++ b/common/build-style/python3-pep517.sh
@@ -0,0 +1,31 @@
+#
+# This style is for templates installing python3 modules adhering to PEP517
+#
+
+do_build() {
+	# No PEP517 build tool currently supports compiled extensions
+	# Thus, there is no need to accommodate cross compilation here
+	: ${make_build_target:=.}
+
+	mkdir -p build
+	TMPDIR=build python3 -m pip wheel --no-deps --use-pep517 --no-clean \
+		--no-build-isolation ${make_build_args} ${make_build_target}
+}
+
+do_check() {
+	if python3 -m pytest --help >/dev/null 2>&1; then
+		python3 -m pytest ${make_check_args} ${make_check_target}
+	else
+		msg_warn "Unable to determine tests for PEP517 Python templates"
+		return 0
+	fi
+}
+
+do_install() {
+	# As with do_build, no need to accommodate cross compilation here
+	: ${make_install_target:=${pkgname#python3-}-${version}-*-*-*.whl}
+
+	TMPDIR=build python3 -m pip install --use-pep517 --prefix /usr \
+		--root ${DESTDIR} --no-deps --no-build-isolation \
+		--no-clean ${make_install_args} ${make_install_target}
+}
diff --git a/common/environment/build-style/python3-pep517.sh b/common/environment/build-style/python3-pep517.sh
new file mode 100644
index 00000000000..48f0c1b17f4
--- /dev/null
+++ b/common/environment/build-style/python3-pep517.sh
@@ -0,0 +1,2 @@
+hostmakedepends+=" python3-pip"
+lib32disabled=yes

From 11c22494db251498663a4e56c82f527a1e556e2d Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Wed, 2 Dec 2020 08:08:33 -0500
Subject: [PATCH 2/3] New package: python3-flit_core-3.0.0

---
 .../python3-flit_core/patches/use_toml.patch  | 254 ++++++++++++++++++
 srcpkgs/python3-flit_core/template            |  23 ++
 2 files changed, 277 insertions(+)
 create mode 100644 srcpkgs/python3-flit_core/patches/use_toml.patch
 create mode 100644 srcpkgs/python3-flit_core/template

diff --git a/srcpkgs/python3-flit_core/patches/use_toml.patch b/srcpkgs/python3-flit_core/patches/use_toml.patch
new file mode 100644
index 00000000000..8a0a668f616
--- /dev/null
+++ b/srcpkgs/python3-flit_core/patches/use_toml.patch
@@ -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 doc/development.rst doc/development.rst
+index 9b8dc5e..f714999 100644
+--- doc/development.rst
++++ 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 doc/pyproject_toml.rst doc/pyproject_toml.rst
+index f9ddc7f..8d38bf9 100644
+--- doc/pyproject_toml.rst
++++ 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 flit/init.py flit/init.py
+index f7ea93a..b0c77c6 100644
+--- flit/init.py
++++ 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 flit/tomlify.py flit/tomlify.py
+index 0c8db69..a9c9c60 100644
+--- flit/tomlify.py
++++ 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 flit_core/flit_core/build_thyself.py flit_core/flit_core/build_thyself.py
+index 7daf67f..f3aaf7c 100644
+--- flit_core/flit_core/build_thyself.py
++++ 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 flit_core/flit_core/config.py flit_core/flit_core/config.py
+index 0af9c00..6ed20d3 100644
+--- flit_core/flit_core/config.py
++++ 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 flit_core/flit_core/sdist.py flit_core/flit_core/sdist.py
+index 1fe5bb4..963b4e5 100644
+--- flit_core/flit_core/sdist.py
++++ 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 flit_core/flit_core/wheel.py flit_core/flit_core/wheel.py
+index 1550846..2bc55e1 100644
+--- flit_core/flit_core/wheel.py
++++ 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 pyproject.toml pyproject.toml
+index ac8d001..0af74b2 100644
+--- pyproject.toml
++++ 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 tests/test_init.py tests/test_init.py
+index fb8ad4d..7330ff5 100644
+--- tests/test_init.py
++++ 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 tests/test_tomlify.py tests/test_tomlify.py
+index 2bd75dc..a7b7978 100644
+--- tests/test_tomlify.py
++++ 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 tox.ini tox.ini
+index 08ce1bf..d1025e1 100644
+--- tox.ini
++++ tox.ini
+@@ -18,7 +18,7 @@ deps =
+     testpath
+     responses
+     docutils
+-    pytoml
++    toml
+     pytest>=2.7.3
+     pytest-cov
+ 
diff --git a/srcpkgs/python3-flit_core/template b/srcpkgs/python3-flit_core/template
new file mode 100644
index 00000000000..f3b166c60ff
--- /dev/null
+++ b/srcpkgs/python3-flit_core/template
@@ -0,0 +1,23 @@
+# Template file for 'python3-flit_core'
+pkgname=python3-flit_core
+version=3.0.0
+revision=1
+wrksrc="flit-${version}"
+build_wrksrc="flit_core"
+build_style=python3-pep517
+depends="python3-toml"
+short_desc="Simplified packaging of Python modules - PEP 517 build backend"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="BSD-3-Clause"
+homepage="https://flit.readthedocs.io"
+changelog="https://flit.readthedocs.io/en/latest/history.html"
+distfiles="${PYPI_SITE}/f/flit/flit-${version}.tar.gz"
+checksum=b4fe0f84a1ffbf125d003e253ec98c0b6e3e31290b31fba3ad22d28588c20893
+
+do_check() {
+	: provides no tests
+}
+
+post_install() {
+	vlicense ../LICENSE
+}

From e056782975825bad92ebaa0a4ed51960a40724b3 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Wed, 2 Dec 2020 10:28:38 -0500
Subject: [PATCH 3/3] python-packaging: split package

New package: python3-packaging-20.7
---
 srcpkgs/python-packaging/template  | 20 +++++---------------
 srcpkgs/python-packaging/update    |  3 +++
 srcpkgs/python3-packaging          |  1 -
 srcpkgs/python3-packaging/template | 23 +++++++++++++++++++++++
 4 files changed, 31 insertions(+), 16 deletions(-)
 create mode 100644 srcpkgs/python-packaging/update
 delete mode 120000 srcpkgs/python3-packaging
 create mode 100644 srcpkgs/python3-packaging/template

diff --git a/srcpkgs/python-packaging/template b/srcpkgs/python-packaging/template
index e36a04a1540..aa1f64182d7 100644
--- a/srcpkgs/python-packaging/template
+++ b/srcpkgs/python-packaging/template
@@ -1,29 +1,19 @@
 # Template file for 'python-packaging'
 pkgname=python-packaging
 version=20.4
-revision=1
+revision=2
 wrksrc="packaging-${version}"
-build_style=python-module
-pycompile_module="packaging"
-hostmakedepends="python-setuptools python3-setuptools"
-depends="python-attrs python-parsing python-six"
+build_style=python2-module
+hostmakedepends="python-setuptools"
+depends="python-parsing python-six"
 short_desc="Core utilities for Python packages (Python2)"
 maintainer="Alessio Sergi <al3hex@gmail.com>"
 license="Apache-2.0, BSD-2-Clause"
 homepage="https://github.com/pypa/packaging"
+changelog="https://raw.githubusercontent.com/pypa/packaging/master/CHANGELOG.rst"
 distfiles="${PYPI_SITE}/p/packaging/packaging-${version}.tar.gz"
 checksum=4357f74f47b9c12db93624a82154e9b120fa8293699949152b22065d556079f8
 
 post_install() {
 	vlicense LICENSE
 }
-
-python3-packaging_package() {
-	pycompile_module="packaging"
-	depends="python3-attrs python3-parsing python3-six"
-	short_desc="${short_desc/Python2/Python3}"
-	pkg_install() {
-		vmove usr/lib/python3*
-		vlicense LICENSE
-	}
-}
diff --git a/srcpkgs/python-packaging/update b/srcpkgs/python-packaging/update
new file mode 100644
index 00000000000..3b1a41fb94a
--- /dev/null
+++ b/srcpkgs/python-packaging/update
@@ -0,0 +1,3 @@
+# packaging >= 20.5 drops setuptools for flit, which is py3-only;
+# prevent update hits on newer versions since they require py3 to build
+pattern="packaging-\K20\.4(\.[0-9.]+)?(?=.tar.gz)"
diff --git a/srcpkgs/python3-packaging b/srcpkgs/python3-packaging
deleted file mode 120000
index 98299fdb1d7..00000000000
--- a/srcpkgs/python3-packaging
+++ /dev/null
@@ -1 +0,0 @@
-python-packaging
\ No newline at end of file
diff --git a/srcpkgs/python3-packaging/template b/srcpkgs/python3-packaging/template
new file mode 100644
index 00000000000..a4323dad4d6
--- /dev/null
+++ b/srcpkgs/python3-packaging/template
@@ -0,0 +1,23 @@
+# Template file for 'python3-packaging'
+pkgname=python3-packaging
+version=20.7
+revision=1
+wrksrc="packaging-${version}"
+build_style=python3-pep517
+hostmakedepends="python3-flit_core"
+depends="python3-parsing"
+checkdepends="python3-pytest"
+short_desc="Core utilities for Python packages (Python3)"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="Apache-2.0, BSD-2-Clause"
+homepage="https://github.com/pypa/packaging"
+distfiles="${PYPI_SITE}/p/packaging/packaging-${version}.tar.gz"
+checksum=05af3bb85d320377db281cf254ab050e1a7ebcbf5410685a9a407e18a1f81236
+
+do_check() {
+	: provides no tests
+}
+
+post_install() {
+	vlicense LICENSE
+}

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PR PATCH] [Updated] [RFC] Support for PEP517 build systems with new build style
  2020-12-02 16:00 [PR PATCH] [RFC] Support for PEP517 build systems in python3-module ahesford
                   ` (17 preceding siblings ...)
  2020-12-06  5:53 ` ahesford
@ 2020-12-06  5:56 ` ahesford
  2020-12-06  5:56 ` ahesford
                   ` (2 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: ahesford @ 2020-12-06  5:56 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 2542 bytes --]

There is an updated pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages packaging
https://github.com/void-linux/void-packages/pull/26883

[RFC] Support for PEP517 build systems with new build style
I [have been told](https://github.com/pypa/packaging/issues/363) that PEP517 build systems are the way of the future for Python package building and installation, and `setuptools` will become (or is now) disfavored. `python3-packaging` is the first of our packages to drop `setuptools` and specifically require a PEP517 builder.

This is an attempt to support PEP517 builds in our `python3-module` build style. For now, the preferred (only?) way to do PEP517 builds is to rely on `pip` to do the work. Fortunately, because no PEP517 builder supports compiled extensions, we can avoid the pain of trying to force `pip` to behave with cross compilers (for now).

Use of the PEP517 build procedure in a template is enabled by setting `python_pep517=yes`. If this is adopted, we'll have to modify `xlint` as well.

`pip` can do a one-pass build and install, but I figured it was better to split into a build-wheel stage and an install-wheel stage so people can do `./xbps-src build` and investigate the artifacts.

I am not thrilled with the use of globs in `do_install` when setting a default `$python_pep517_wheel` but, according to [PEP 427](https://www.python.org/dev/peps/pep-0427/#file-name-convention) and its referenced [PEP 425](https://www.python.org/dev/peps/pep-0425), the filename components I'm trying to match with the globs are not easily predicted. In any case, if this produces undesirable behavior in specific templates, the author can manually set that variable. Any other ideas are welcome.

Finally, the build process produces `direct_url.json` in the Python `dist-info` directory to comply with [PEP 610](https://www.python.org/dev/peps/pep-0610), which replaces a simple version number in `pip freeze` output with a `file://` URL pointing to the location of the wheel used for installation. (In our case, this will be `/builddir/$wrksrc/$build_wrksrc/$python_pep517_wheel`.) For distribution packages, I do not believe this is desirable. We can manually remove the file, for example in `do_install`, assuming the `dist-info` directory is predictable. Comments about doing this are welcome.

cc: any @void-linux/pkg-committers with a stake in Python packages

A patch file from https://github.com/void-linux/void-packages/pull/26883.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-packaging-26883.patch --]
[-- Type: text/x-diff, Size: 19606 bytes --]

From 43ff042b7ae28259963ed034f0762d228d82e6d0 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Wed, 2 Dec 2020 22:20:18 -0500
Subject: [PATCH 1/3] build-style/python3-pep517: new style for PEP517 Python
 packages

---
 Manual.md                                     | 29 +++++++++++------
 common/build-style/python3-pep517.sh          | 31 +++++++++++++++++++
 .../environment/build-style/python3-pep517.sh |  2 ++
 3 files changed, 53 insertions(+), 9 deletions(-)
 create mode 100644 common/build-style/python3-pep517.sh
 create mode 100644 common/environment/build-style/python3-pep517.sh

diff --git a/Manual.md b/Manual.md
index 7647f957129..79667b103f7 100644
--- a/Manual.md
+++ b/Manual.md
@@ -561,17 +561,22 @@ phase if `${build_style}` is set to `configure`, `gnu-configure` or
 `gnu-makefile` build methods. By default set to
 `PREFIX=/usr DESTDIR=${DESTDIR}`.
 
-- `make_build_target` The target to be passed in to `${make_cmd}` at the build phase if
-`${build_style}` is set to `configure`, `gnu-configure` or `gnu-makefile`
-build methods. Unset by default (`all` target).
+- `make_build_target` The build target. If `${build_style}` is set to `configure`, `gnu-configure`
+or `gnu-makefile`, this is the target passed to `${make_cmd}` in the build phase; when unset, it
+defaults to `all`. If `${build_style}` is `python3-pep517`, this is the path of the package
+directory that should be built as a Python wheel; when unset, defaults to `.` (the current
+directory with respect to the build).
 
 - `make_check_target` The target to be passed in to `${make_cmd}` at the check phase if
 `${build_style}` is set to `configure`, `gnu-configure` or `gnu-makefile`
 build methods. By default set to `check`.
 
-- `make_install_target` The target to be passed in to `${make_cmd}` at the `install-destdir` phase
-if `${build_style}` is set to `configure`, `gnu-configure` or `gnu-makefile`
-build methods. By default set to `install`.
+- `make_install_target` The installation target. When `${build_style}` is set to `configure`,
+`gnu-configure` or `gnu-makefile`, this is the target passed to `${make_command}` in the install
+phase; when unset, it defaults to `install`. If `${build_style}` is `python-pep517`, this is the
+path of the Python wheel produced by the build phase that will be installed; when unset, the
+`python-pep517` build style will look for a wheel matching the package name and version in the
+current directory with respect to the install.
 
 - `patch_args` The arguments to be passed in to the `patch(1)` command when applying
 patches to the package sources during `do_patch()`. Patches are stored in
@@ -952,8 +957,8 @@ via `make_install_target`.
 via `configure_args`, the meson command can be overridden by `meson_cmd` and the location of
 the out of source build by `meson_builddir`
 
-For packages that use the Python module build method (`setup.py`), you
-can choose one of the following:
+For packages that use the Python module build method (`setup.py` or
+[PEP 517](https://www.python.org/dev/peps/pep-0517/)), you can choose one of the following:
 
 - `python-module` to build *both* Python 2.x and 3.x modules
 
@@ -961,6 +966,9 @@ can choose one of the following:
 
 - `python3-module` to build Python 3.x only modules
 
+- `python3-pep517` to build Python 3.x only modules that provide a PEP 517 build description without
+a `setup.py` script
+
 Environment variables for a specific `build_style` can be declared in a filename
 matching the `build_style` name, Example:
 
@@ -1481,7 +1489,10 @@ be your guidance to decide whether or not to split off a `-doc` subpackage.
 
 Python packages should be built with the `python{,2,3}-module` build style, if possible.
 This sets some environment variables required to allow cross compilation. Support to allow
-building a python module for multiple versions from a single template is also possible.
+building a python module for multiple versions from a single template is also possible. The
+`python3-pep517` build style provides means to build python packages that provide a build-system
+definition compliant with [PEP 517](https://www.python.org/dev/peps/pep-0517/) without a traditional
+`setup.py` script.
 
 Python packages that rely on `python3-setuptools` should generally map `setup_requires`
 dependencies in `setup.py` to `hostmakedepends` in the template and `install_requires`
diff --git a/common/build-style/python3-pep517.sh b/common/build-style/python3-pep517.sh
new file mode 100644
index 00000000000..1a3c6d31eed
--- /dev/null
+++ b/common/build-style/python3-pep517.sh
@@ -0,0 +1,31 @@
+#
+# This style is for templates installing python3 modules adhering to PEP517
+#
+
+do_build() {
+	# No PEP517 build tool currently supports compiled extensions
+	# Thus, there is no need to accommodate cross compilation here
+	: ${make_build_target:=.}
+
+	mkdir -p build
+	TMPDIR=build python3 -m pip wheel --no-deps --use-pep517 --no-clean \
+		--no-build-isolation ${make_build_args} ${make_build_target}
+}
+
+do_check() {
+	if python3 -m pytest --help >/dev/null 2>&1; then
+		python3 -m pytest ${make_check_args} ${make_check_target}
+	else
+		msg_warn "Unable to determine tests for PEP517 Python templates"
+		return 0
+	fi
+}
+
+do_install() {
+	# As with do_build, no need to accommodate cross compilation here
+	: ${make_install_target:=${pkgname#python3-}-${version}-*-*-*.whl}
+
+	TMPDIR=build python3 -m pip install --use-pep517 --prefix /usr \
+		--root ${DESTDIR} --no-deps --no-build-isolation \
+		--no-clean ${make_install_args} ${make_install_target}
+}
diff --git a/common/environment/build-style/python3-pep517.sh b/common/environment/build-style/python3-pep517.sh
new file mode 100644
index 00000000000..48f0c1b17f4
--- /dev/null
+++ b/common/environment/build-style/python3-pep517.sh
@@ -0,0 +1,2 @@
+hostmakedepends+=" python3-pip"
+lib32disabled=yes

From 11c22494db251498663a4e56c82f527a1e556e2d Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Wed, 2 Dec 2020 08:08:33 -0500
Subject: [PATCH 2/3] New package: python3-flit_core-3.0.0

---
 .../python3-flit_core/patches/use_toml.patch  | 254 ++++++++++++++++++
 srcpkgs/python3-flit_core/template            |  23 ++
 2 files changed, 277 insertions(+)
 create mode 100644 srcpkgs/python3-flit_core/patches/use_toml.patch
 create mode 100644 srcpkgs/python3-flit_core/template

diff --git a/srcpkgs/python3-flit_core/patches/use_toml.patch b/srcpkgs/python3-flit_core/patches/use_toml.patch
new file mode 100644
index 00000000000..8a0a668f616
--- /dev/null
+++ b/srcpkgs/python3-flit_core/patches/use_toml.patch
@@ -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 doc/development.rst doc/development.rst
+index 9b8dc5e..f714999 100644
+--- doc/development.rst
++++ 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 doc/pyproject_toml.rst doc/pyproject_toml.rst
+index f9ddc7f..8d38bf9 100644
+--- doc/pyproject_toml.rst
++++ 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 flit/init.py flit/init.py
+index f7ea93a..b0c77c6 100644
+--- flit/init.py
++++ 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 flit/tomlify.py flit/tomlify.py
+index 0c8db69..a9c9c60 100644
+--- flit/tomlify.py
++++ 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 flit_core/flit_core/build_thyself.py flit_core/flit_core/build_thyself.py
+index 7daf67f..f3aaf7c 100644
+--- flit_core/flit_core/build_thyself.py
++++ 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 flit_core/flit_core/config.py flit_core/flit_core/config.py
+index 0af9c00..6ed20d3 100644
+--- flit_core/flit_core/config.py
++++ 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 flit_core/flit_core/sdist.py flit_core/flit_core/sdist.py
+index 1fe5bb4..963b4e5 100644
+--- flit_core/flit_core/sdist.py
++++ 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 flit_core/flit_core/wheel.py flit_core/flit_core/wheel.py
+index 1550846..2bc55e1 100644
+--- flit_core/flit_core/wheel.py
++++ 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 pyproject.toml pyproject.toml
+index ac8d001..0af74b2 100644
+--- pyproject.toml
++++ 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 tests/test_init.py tests/test_init.py
+index fb8ad4d..7330ff5 100644
+--- tests/test_init.py
++++ 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 tests/test_tomlify.py tests/test_tomlify.py
+index 2bd75dc..a7b7978 100644
+--- tests/test_tomlify.py
++++ 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 tox.ini tox.ini
+index 08ce1bf..d1025e1 100644
+--- tox.ini
++++ tox.ini
+@@ -18,7 +18,7 @@ deps =
+     testpath
+     responses
+     docutils
+-    pytoml
++    toml
+     pytest>=2.7.3
+     pytest-cov
+ 
diff --git a/srcpkgs/python3-flit_core/template b/srcpkgs/python3-flit_core/template
new file mode 100644
index 00000000000..f3b166c60ff
--- /dev/null
+++ b/srcpkgs/python3-flit_core/template
@@ -0,0 +1,23 @@
+# Template file for 'python3-flit_core'
+pkgname=python3-flit_core
+version=3.0.0
+revision=1
+wrksrc="flit-${version}"
+build_wrksrc="flit_core"
+build_style=python3-pep517
+depends="python3-toml"
+short_desc="Simplified packaging of Python modules - PEP 517 build backend"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="BSD-3-Clause"
+homepage="https://flit.readthedocs.io"
+changelog="https://flit.readthedocs.io/en/latest/history.html"
+distfiles="${PYPI_SITE}/f/flit/flit-${version}.tar.gz"
+checksum=b4fe0f84a1ffbf125d003e253ec98c0b6e3e31290b31fba3ad22d28588c20893
+
+do_check() {
+	: provides no tests
+}
+
+post_install() {
+	vlicense ../LICENSE
+}

From e056782975825bad92ebaa0a4ed51960a40724b3 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Wed, 2 Dec 2020 10:28:38 -0500
Subject: [PATCH 3/3] python-packaging: split package

New package: python3-packaging-20.7
---
 srcpkgs/python-packaging/template  | 20 +++++---------------
 srcpkgs/python-packaging/update    |  3 +++
 srcpkgs/python3-packaging          |  1 -
 srcpkgs/python3-packaging/template | 23 +++++++++++++++++++++++
 4 files changed, 31 insertions(+), 16 deletions(-)
 create mode 100644 srcpkgs/python-packaging/update
 delete mode 120000 srcpkgs/python3-packaging
 create mode 100644 srcpkgs/python3-packaging/template

diff --git a/srcpkgs/python-packaging/template b/srcpkgs/python-packaging/template
index e36a04a1540..aa1f64182d7 100644
--- a/srcpkgs/python-packaging/template
+++ b/srcpkgs/python-packaging/template
@@ -1,29 +1,19 @@
 # Template file for 'python-packaging'
 pkgname=python-packaging
 version=20.4
-revision=1
+revision=2
 wrksrc="packaging-${version}"
-build_style=python-module
-pycompile_module="packaging"
-hostmakedepends="python-setuptools python3-setuptools"
-depends="python-attrs python-parsing python-six"
+build_style=python2-module
+hostmakedepends="python-setuptools"
+depends="python-parsing python-six"
 short_desc="Core utilities for Python packages (Python2)"
 maintainer="Alessio Sergi <al3hex@gmail.com>"
 license="Apache-2.0, BSD-2-Clause"
 homepage="https://github.com/pypa/packaging"
+changelog="https://raw.githubusercontent.com/pypa/packaging/master/CHANGELOG.rst"
 distfiles="${PYPI_SITE}/p/packaging/packaging-${version}.tar.gz"
 checksum=4357f74f47b9c12db93624a82154e9b120fa8293699949152b22065d556079f8
 
 post_install() {
 	vlicense LICENSE
 }
-
-python3-packaging_package() {
-	pycompile_module="packaging"
-	depends="python3-attrs python3-parsing python3-six"
-	short_desc="${short_desc/Python2/Python3}"
-	pkg_install() {
-		vmove usr/lib/python3*
-		vlicense LICENSE
-	}
-}
diff --git a/srcpkgs/python-packaging/update b/srcpkgs/python-packaging/update
new file mode 100644
index 00000000000..3b1a41fb94a
--- /dev/null
+++ b/srcpkgs/python-packaging/update
@@ -0,0 +1,3 @@
+# packaging >= 20.5 drops setuptools for flit, which is py3-only;
+# prevent update hits on newer versions since they require py3 to build
+pattern="packaging-\K20\.4(\.[0-9.]+)?(?=.tar.gz)"
diff --git a/srcpkgs/python3-packaging b/srcpkgs/python3-packaging
deleted file mode 120000
index 98299fdb1d7..00000000000
--- a/srcpkgs/python3-packaging
+++ /dev/null
@@ -1 +0,0 @@
-python-packaging
\ No newline at end of file
diff --git a/srcpkgs/python3-packaging/template b/srcpkgs/python3-packaging/template
new file mode 100644
index 00000000000..a4323dad4d6
--- /dev/null
+++ b/srcpkgs/python3-packaging/template
@@ -0,0 +1,23 @@
+# Template file for 'python3-packaging'
+pkgname=python3-packaging
+version=20.7
+revision=1
+wrksrc="packaging-${version}"
+build_style=python3-pep517
+hostmakedepends="python3-flit_core"
+depends="python3-parsing"
+checkdepends="python3-pytest"
+short_desc="Core utilities for Python packages (Python3)"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="Apache-2.0, BSD-2-Clause"
+homepage="https://github.com/pypa/packaging"
+distfiles="${PYPI_SITE}/p/packaging/packaging-${version}.tar.gz"
+checksum=05af3bb85d320377db281cf254ab050e1a7ebcbf5410685a9a407e18a1f81236
+
+do_check() {
+	: provides no tests
+}
+
+post_install() {
+	vlicense LICENSE
+}

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [RFC] Support for PEP517 build systems with new build style
  2020-12-02 16:00 [PR PATCH] [RFC] Support for PEP517 build systems in python3-module ahesford
                   ` (18 preceding siblings ...)
  2020-12-06  5:56 ` ahesford
@ 2020-12-06  5:56 ` ahesford
  2020-12-08 20:57 ` ahesford
  2020-12-08 20:57 ` [PR PATCH] [Closed]: " ahesford
  21 siblings, 0 replies; 23+ messages in thread
From: ahesford @ 2020-12-06  5:56 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 283 bytes --]

New comment by ahesford on void-packages repository

https://github.com/void-linux/void-packages/pull/26883#issuecomment-739460283

Comment:
I added the `make_*_target` behaviors to `#optional_vars`, added the new style to `#build_scripts` and cleaned up the diff in `#pkgs_python`.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [RFC] Support for PEP517 build systems with new build style
  2020-12-02 16:00 [PR PATCH] [RFC] Support for PEP517 build systems in python3-module ahesford
                   ` (19 preceding siblings ...)
  2020-12-06  5:56 ` ahesford
@ 2020-12-08 20:57 ` ahesford
  2020-12-08 20:57 ` [PR PATCH] [Closed]: " ahesford
  21 siblings, 0 replies; 23+ messages in thread
From: ahesford @ 2020-12-08 20:57 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 193 bytes --]

New comment by ahesford on void-packages repository

https://github.com/void-linux/void-packages/pull/26883#issuecomment-741017755

Comment:
Closed in fe9c2d01b5f84176a933581b97213dea3158fe41.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PR PATCH] [Closed]: [RFC] Support for PEP517 build systems with new build style
  2020-12-02 16:00 [PR PATCH] [RFC] Support for PEP517 build systems in python3-module ahesford
                   ` (20 preceding siblings ...)
  2020-12-08 20:57 ` ahesford
@ 2020-12-08 20:57 ` ahesford
  21 siblings, 0 replies; 23+ messages in thread
From: ahesford @ 2020-12-08 20:57 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 2382 bytes --]

There's a closed pull request on the void-packages repository

[RFC] Support for PEP517 build systems with new build style
https://github.com/void-linux/void-packages/pull/26883

Description:
I [have been told](https://github.com/pypa/packaging/issues/363) that PEP517 build systems are the way of the future for Python package building and installation, and `setuptools` will become (or is now) disfavored. `python3-packaging` is the first of our packages to drop `setuptools` and specifically require a PEP517 builder.

This is an attempt to support PEP517 builds in our `python3-module` build style. For now, the preferred (only?) way to do PEP517 builds is to rely on `pip` to do the work. Fortunately, because no PEP517 builder supports compiled extensions, we can avoid the pain of trying to force `pip` to behave with cross compilers (for now).

Use of the PEP517 build procedure in a template is enabled by setting `python_pep517=yes`. If this is adopted, we'll have to modify `xlint` as well.

`pip` can do a one-pass build and install, but I figured it was better to split into a build-wheel stage and an install-wheel stage so people can do `./xbps-src build` and investigate the artifacts.

I am not thrilled with the use of globs in `do_install` when setting a default `$python_pep517_wheel` but, according to [PEP 427](https://www.python.org/dev/peps/pep-0427/#file-name-convention) and its referenced [PEP 425](https://www.python.org/dev/peps/pep-0425), the filename components I'm trying to match with the globs are not easily predicted. In any case, if this produces undesirable behavior in specific templates, the author can manually set that variable. Any other ideas are welcome.

Finally, the build process produces `direct_url.json` in the Python `dist-info` directory to comply with [PEP 610](https://www.python.org/dev/peps/pep-0610), which replaces a simple version number in `pip freeze` output with a `file://` URL pointing to the location of the wheel used for installation. (In our case, this will be `/builddir/$wrksrc/$build_wrksrc/$python_pep517_wheel`.) For distribution packages, I do not believe this is desirable. We can manually remove the file, for example in `do_install`, assuming the `dist-info` directory is predictable. Comments about doing this are welcome.

cc: any @void-linux/pkg-committers with a stake in Python packages

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2020-12-08 20:57 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-02 16:00 [PR PATCH] [RFC] Support for PEP517 build systems in python3-module ahesford
2020-12-02 17:45 ` [PR REVIEW] " ericonr
2020-12-02 19:02 ` [PR PATCH] [Updated] " ahesford
2020-12-02 19:06 ` [PR REVIEW] " ahesford
2020-12-02 19:10 ` ericonr
2020-12-02 19:11 ` ericonr
2020-12-02 19:14 ` ericonr
2020-12-02 19:27 ` [PR PATCH] [Updated] " ahesford
2020-12-02 19:28 ` [PR REVIEW] " ahesford
2020-12-02 19:30 ` [PR PATCH] [Updated] " ahesford
2020-12-02 19:42 ` Johnnynator
2020-12-02 19:59 ` ahesford
2020-12-02 20:21 ` [PR REVIEW] " Chocimier
2020-12-02 23:37 ` fosslinux
2020-12-03  3:43 ` [PR PATCH] [Updated] " ahesford
2020-12-03  3:52 ` ahesford
2020-12-05 16:29 ` [RFC] Support for PEP517 build systems with new build style Chocimier
2020-12-06  5:48 ` [PR PATCH] [Updated] " ahesford
2020-12-06  5:53 ` ahesford
2020-12-06  5:56 ` ahesford
2020-12-06  5:56 ` ahesford
2020-12-08 20:57 ` ahesford
2020-12-08 20:57 ` [PR PATCH] [Closed]: " ahesford

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).