(address . guix-patches@gnu.org)
Hi everyone,
the attached patches switch python-build-system to a PEP 517-based build
system using python-pypa-build.
As discussed previously Python is currently in the process of opening up
for build systems other than setuptools using the API specified in PEP
517. python-pypa-build is a simple tool for building packages using that
new API. It supports setup.py-based builds as a fallback, if no
pyproject.toml is present.
One downside is that this tool is not self-contained and has a few
dependencies. Thus first I bootstrap setuptools using itself (possible
because it bundles all of its own dependencies), then build
python-pypa-build’s dependencies using setuptools (which is fortunately
still possible) and then combine everything into a
python-toolchain(-for-build), which is then used by the build-process.
I can successfully build packages like python-pypa-build and
python-pytest and python-pep517-bootstrap. The latter is using flit as
its build backend. But other packages currently fail because I removed
some arguments.
Cheers,
Lars
From 7ace01faef72f3a48b18fe241fe0524445a154fb Mon Sep 17 00:00:00 2001
From: Lars-Dominik Braun <lars@6xq.net>
Date: Fri, 19 Feb 2021 17:22:35 +0100
Subject: [PATCH 01/12] build/python: Handle missing setuptools in
sanity-check.py
Just skip testing if required dependencies (setuptools) are not
available.
* gnu/packages/aux-files/python/sanity-check.py: Handle ImportError.
---
gnu/packages/aux-files/python/sanity-check.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
Toggle diff (21 lines)
diff --git a/gnu/packages/aux-files/python/sanity-check.py b/gnu/packages/aux-files/python/sanity-check.py
index 83b6d583ca..240155cecc 100644
--- a/gnu/packages/aux-files/python/sanity-check.py
+++ b/gnu/packages/aux-files/python/sanity-check.py
@@ -19,9 +19,13 @@
from __future__ import print_function # Python 2 support.
import importlib
-import pkg_resources
import sys
import traceback
+try:
+ import pkg_resources
+except ImportError:
+ print('Warning: Skipping, because python-setuptools are not available.')
+ sys.exit(0)
try:
from importlib.machinery import PathFinder
--
2.26.2
From 66033f14455456d465a3c9f5a2d1f4961cd3b989 Mon Sep 17 00:00:00 2001
From: Lars-Dominik Braun <lars@6xq.net>
Date: Sun, 28 Feb 2021 12:50:42 +0100
Subject: [PATCH 02/12] gnu: python-pypa-build: Update to 0.3.0.
* gnu/packages/python-build.scm (python-pypa-build): Update to 0.3.0.
---
gnu/packages/python-build.scm | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Toggle diff (22 lines)
diff --git a/gnu/packages/python-build.scm b/gnu/packages/python-build.scm
index 140629ca43..92dbda314f 100644
--- a/gnu/packages/python-build.scm
+++ b/gnu/packages/python-build.scm
@@ -118,13 +118,13 @@ Language (TOML) configuration files.")
(define-public python-pypa-build
(package
(name "python-pypa-build")
- (version "0.1.0")
+ (version "0.3.0")
(source (origin
(method url-fetch)
(uri (pypi-uri "build" version))
(sha256
(base32
- "1d6m21lijwm04g50nwgsgj7x3vhblzw7jv05ah8psqgzk20bbch8"))))
+ "1pazq66c35whrqd5b0zcydjvy2rmghi8riljkd67q3bpiln5pf8f"))))
(build-system python-build-system)
(arguments
`(#:tests? #f ;to tests in the PyPI release
--
2.26.2
From 00ef998413dc0fe6605653ae16f65d6377c2ec77 Mon Sep 17 00:00:00 2001
From: Lars-Dominik Braun <lars@6xq.net>
Date: Sun, 28 Feb 2021 13:02:15 +0100
Subject: [PATCH 03/12] gnu: python-wheel: Install entrypoint scripts
* gnu/packages/python-build.scm (pythont-wheel) [arguments]: Add phase
'patch-enable-entrypoints.
---
gnu/packages/python-build.scm | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
Toggle diff (28 lines)
diff --git a/gnu/packages/python-build.scm b/gnu/packages/python-build.scm
index 92dbda314f..232e24f470 100644
--- a/gnu/packages/python-build.scm
+++ b/gnu/packages/python-build.scm
@@ -47,10 +47,17 @@
"0ii6f34rvpjg3nmw4bc2h7fhdsy38y1h93hghncfs5akfrldmj8h"))))
(build-system python-build-system)
(arguments
- ;; FIXME: The test suite runs "python setup.py bdist_wheel", which in turn
- ;; fails to find the newly-built bdist_wheel library, even though it is
- ;; available on PYTHONPATH. What search path is consulted by setup.py?
- '(#:tests? #f))
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'patch-enable-entrypoints
+ (lambda _
+ ;; python-wheel tells setuptools to not install entry point scripts
+ ;; by default. Stop doing that, so wheels built contain all data
+ ;; required.
+ (substitute* "wheel/bdist_wheel.py"
+ (("(install_scripts\\.no_ep = )True" all assignment)
+ (string-append assignment "False")))
+ #t)))))
(home-page "https://bitbucket.org/pypa/wheel/")
(synopsis "Format for built Python packages")
(description
--
2.26.2
From 61313d8ddba30772e2587e3e16ca30d1565d3c7e Mon Sep 17 00:00:00 2001
From: Lars-Dominik Braun <lars@6xq.net>
Date: Sun, 28 Feb 2021 13:05:51 +0100
Subject: [PATCH 04/12] gnu: python-setuptools: Bootstrap using itself
* gnu/packages/python-xyz.scm (python-setuptools) [arguments]: Add phase
setting GUIX_PYTHONPATH to source directory.
---
gnu/packages/python-xyz.scm | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
Toggle diff (26 lines)
diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index f8afa13f33..79d01f700a 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -1144,7 +1144,18 @@ other machines, such as over the network.")
;; FIXME: Tests require pytest, which itself relies on setuptools.
;; One could bootstrap with an internal untested setuptools.
(arguments
- `(#:tests? #f))
+ `(#:tests? #f
+ #:python ,python-wrapper
+ #:phases (modify-phases %standard-phases
+ ;; Use this setuptools’ sources to bootstrap themselves.
+ (add-before 'build 'set-PYTHONPATH
+ (lambda _
+ (format #t "current working dir ~s~%" (getcwd))
+ (setenv "GUIX_PYTHONPATH"
+ (string-append ".:" (getenv "GUIX_PYTHONPATH")))
+ #t)))))
+ ;; Not required when not building a wheel
+ ;(propagated-inputs `(("python-wheel" ,python-wheel)))
(home-page "https://pypi.org/project/setuptools/")
(synopsis
"Library designed to facilitate packaging Python projects")
--
2.26.2
From 14b70dea3d21684e7fdb66dd072031cef3214b07 Mon Sep 17 00:00:00 2001
From: Lars-Dominik Braun <lars@6xq.net>
Date: Sun, 28 Feb 2021 13:17:10 +0100
Subject: [PATCH 06/12] gnu: Add python-pytoml.
* gnu/packages/python-build.scm (python-pytoml): Add new variable.
---
gnu/packages/python-build.scm | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
Toggle diff (27 lines)
diff --git a/gnu/packages/python-build.scm b/gnu/packages/python-build.scm
index 232e24f470..a6a310177c 100644
--- a/gnu/packages/python-build.scm
+++ b/gnu/packages/python-build.scm
@@ -173,3 +173,20 @@ implementation developed for Poetry. This project is intended to be
a light weight, fully compliant, self-contained package allowing PEP 517
compatible build front-ends to build Poetry managed projects.")
(license license:expat)))
+
+(define-public python-pytoml
+ (package
+ (name "python-pytoml")
+ (version "0.1.21")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (pypi-uri "pytoml" version))
+ (sha256
+ (base32
+ "1rv1byiw82k7mj6aprcrqi2vdabs801y97xhfnrz7kxds34ggv4f"))))
+ (build-system python-build-system)
+ (home-page "https://github.com/avakar/pytoml")
+ (synopsis "A parser for TOML-0.4.0")
+ (description "A parser for TOML-0.4.0")
+ (license license:expat)))
--
2.26.2
From e8b1f40157b3d884bb2fc3e3d10bbfbd469c67b9 Mon Sep 17 00:00:00 2001
From: Lars-Dominik Braun <lars@6xq.net>
Date: Sun, 28 Feb 2021 13:18:17 +0100
Subject: [PATCH 07/12] gnu: Add python-flit-core.
* gnu/packages/python-build.scm (python-flit-core): New variable.
---
gnu/packages/python-build.scm | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
Toggle diff (37 lines)
diff --git a/gnu/packages/python-build.scm b/gnu/packages/python-build.scm
index a6a310177c..f767704a78 100644
--- a/gnu/packages/python-build.scm
+++ b/gnu/packages/python-build.scm
@@ -190,3 +190,30 @@ compatible build front-ends to build Poetry managed projects.")
(synopsis "A parser for TOML-0.4.0")
(description "A parser for TOML-0.4.0")
(license license:expat)))
+
+(define-public python-flit-core
+ (package
+ (name "python-flit-core")
+ (version "3.0.0")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (pypi-uri "flit_core" version))
+ (sha256
+ (base32
+ "0bbw84r33gwi0xyp7m8dzp2dzpjs4harj3l5wrbxkmp2awh0ard4"))))
+ (build-system python-build-system)
+ (arguments
+ `(;; No tests.
+ #:tests? #f))
+ (propagated-inputs
+ `(("python-pytoml" ,python-pytoml)))
+ (home-page "https://github.com/takluyver/flit")
+ (synopsis
+ "Simplified packaging of Python modules, distribution-building parts")
+ (description
+ "Flit is a simple way to put Python packages and modules on PyPI. It
+tries to require less thought about packaging and help you avoid common
+mistakes. Distribution-building parts of Flit.")
+ (license license:bsd-3)))
+
--
2.26.2
From 316c25f310cad4dd8f0cb73a914a4776b1b1375c Mon Sep 17 00:00:00 2001
From: Lars-Dominik Braun <lars@6xq.net>
Date: Sun, 28 Feb 2021 13:20:48 +0100
Subject: [PATCH 08/12] gnu: python-pep517-bootstrap: Build using flit-core.
* gnu/packages/python-build.scm (python-pep517-bootstrap) [arguments]:
Relax dependency on flit-core version.
[native-inputs]: Add flit-core.
---
gnu/packages/python-build.scm | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
Toggle diff (29 lines)
diff --git a/gnu/packages/python-build.scm b/gnu/packages/python-build.scm
index f767704a78..f74a3ee49e 100644
--- a/gnu/packages/python-build.scm
+++ b/gnu/packages/python-build.scm
@@ -110,10 +110,21 @@ Language (TOML) configuration files.")
"0zqidxah03qpnp6zkg3zd1kmd5f79hhdsfmlc0cldaniy80qddxf"))))
(build-system python-build-system)
(arguments
- `(#:tests? #f)) ;to avoid circular dependencies
+ `(#:tests? #f ; To avoid circular dependencies.
+ #:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'relax-dependency
+ (lambda _
+ (substitute* "pyproject.toml"
+ (("flit_core >=2,<3")
+ "flit_core >=2,<4"))
+ #t)))))
(propagated-inputs
`(("python-toml" ,python-toml)
("python-wheel" ,python-wheel)))
+ (native-inputs
+ `(;; Build system.
+ ("python-flit-core" ,python-flit-core)))
(home-page "https://github.com/pypa/pep517")
(synopsis "Wrappers to build Python packages using PEP 517 hooks")
(description
--
2.26.2
From c8898a6a282daaa2cceabfac96e417f7b09e8d5f Mon Sep 17 00:00:00 2001
From: Lars-Dominik Braun <lars@6xq.net>
Date: Sun, 28 Feb 2021 13:23:53 +0100
Subject: [PATCH 09/12] gnu: python-iniconfig: Add missing build input.
* gnu/packages/python-xyz.scm (python-iniconfig) [native-inputs] Add
setuptools-scm.
---
gnu/packages/python-xyz.scm | 1 +
1 file changed, 1 insertion(+)
Toggle diff (14 lines)
diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index 79d01f700a..d598a380a9 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -15704,6 +15704,7 @@ in other versions.")
(base32
"0ckzngs3scaa1mcfmsi1w40a1l8cxxnncscrxzjjwjyisx8z0fmw"))))
(build-system python-build-system)
+ (native-inputs `(("python-setuptools-scm" ,python-setuptools-scm)))
(home-page "https://github.com/RonnyPfannschmidt/iniconfig")
(synopsis "Simple INI-file parser")
(description "The @code{iniconfig} package provides a small and simple
--
2.26.2
From 8f5c9398ac1a6ac1871d5cf8a1efbe6a70ed4a1b Mon Sep 17 00:00:00 2001
From: Lars-Dominik Braun <lars@6xq.net>
Date: Mon, 1 Mar 2021 14:16:07 +0100
Subject: [PATCH 10/12] gnu: Add python-u-msgpack.
* gnu/packages/python-xyz.scm (python-u-msgpack): New variable.
The redundant -python postfix from the original package name has been
removed.
---
gnu/packages/python-xyz.scm | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
Toggle diff (34 lines)
diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index d598a380a9..ab3c6d301e 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -23659,3 +23659,27 @@ Application Programming Interface based on the Open Inventor 2.1 API.")
Crayons automatically wraps a given string in the foreground color and
restores the original state after the string is printed.")
(license license:expat)))
+
+(define-public python-u-msgpack
+ (package
+ (name "python-u-msgpack")
+ (version "2.7.1")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (pypi-uri "u-msgpack-python" version))
+ (sha256
+ (base32
+ "0lcmlr7gc4dydpxn6l5bdcq40c3ghf8mv1sjqyj72wdpr8rx9rxp"))))
+ (build-system python-build-system)
+ (home-page
+ "https://github.com/vsergeev/u-msgpack-python")
+ (synopsis
+ "Portable, lightweight MessagePack serializer and deserializer")
+ (description
+ "A portable, lightweight MessagePack serializer and deserializer written
+in pure Python. u-msgpack-python is fully compliant with the latest MessagePack
+specification. In particular, it supports the new binary, UTF-8 string,
+application-defined ext, and timestamp types.")
+ (license license:expat)))
+
--
2.26.2
From 39eef77658f400ccfceb65b6fcd3f4996ae90807 Mon Sep 17 00:00:00 2001
From: Lars-Dominik Braun <lars@6xq.net>
Date: Mon, 1 Mar 2021 14:20:03 +0100
Subject: [PATCH 11/12] gnu: Add python-pytest-expect.
* gnu/packages/python-check.scm (python-pytest-expect): New variable.
---
gnu/packages/python-check.scm | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
Toggle diff (38 lines)
diff --git a/gnu/packages/python-check.scm b/gnu/packages/python-check.scm
index 9849b16685..4139f3cdde 100644
--- a/gnu/packages/python-check.scm
+++ b/gnu/packages/python-check.scm
@@ -1251,3 +1251,31 @@ help in debugging failures and optimizing the scheduler to improve speed.")
(description "A pytest plugin for Sanic. It helps you to test your
code asynchronously.")
(license license:expat)))
+
+(define-public python-pytest-expect
+ (package
+ (name "python-pytest-expect")
+ (version "1.1.0")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (pypi-uri "pytest-expect" version))
+ (sha256
+ (base32
+ "0iyq3zd1g5ffaz2wv6mskjfn84sfbyh0j209glcrh1s50hkldd1n"))))
+ (build-system python-build-system)
+ (arguments `(#:tests? #f)) ; no tests via pypi
+ (propagated-inputs
+ `(("python-pytest" ,python-pytest) ; package declares this dependency
+ ("python-u-msgpack" ,python-u-msgpack)))
+ (home-page
+ "https://github.com/gsnedders/pytest-expect")
+ (synopsis
+ "Py.test plugin to store test expectations and mark tests based on them")
+ (description
+ "A py.test plugin that stores test expectations by saving the set of
+failing tests, allowing them to be marked as xfail when running them in future.
+The tests expectations are stored such that they can be distributed alongside
+the tests.")
+ (license license:expat)))
+
--
2.26.2
From 4ed7eba12c80dd33f20626ddb81abc34dd667ab3 Mon Sep 17 00:00:00 2001
From: Lars-Dominik Braun <lars@6xq.net>
Date: Mon, 1 Mar 2021 14:23:07 +0100
Subject: [PATCH 12/12] gnu: python-html5lib: Fix tests with pytest 6.
* gnu/packages/python-web.scm (python-html5lib) [source]: Add upstream
patch.
[native-inputs]: Add test dependencies.
[arguments]: Remove unsupported #:test-target.
---
gnu/packages/python-web.scm | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
Toggle diff (37 lines)
diff --git a/gnu/packages/python-web.scm b/gnu/packages/python-web.scm
index 947c200253..c484d7ba36 100644
--- a/gnu/packages/python-web.scm
+++ b/gnu/packages/python-web.scm
@@ -1020,13 +1020,27 @@ storage.")
(uri (pypi-uri "html5lib" version))
(sha256
(base32
- "0vqlhk0hgbsfkh7ybmby93xhlx8dq6pr5blf356ka3z2c41b9rdj"))))
+ "0vqlhk0hgbsfkh7ybmby93xhlx8dq6pr5blf356ka3z2c41b9rdj"))
+ (patches
+ (list
+ ;; Adds Pytest 6 support.
+ (origin
+ (method url-fetch)
+ (uri (string-append
+ "https://github.com/html5lib/"
+ "html5lib-python/commit/"
+ "2c19b9899ab3a3e8bd0ca35e5d78544334204169.patch"))
+ (file-name "python-html5lib-support-pytest6.patch")
+ (sha256
+ (base32
+ "0jg2ry0439q8n7j1mf4p2hdq54i704pq9scv4wwa2pp3cwvb6dvg")))))))
(build-system python-build-system)
(propagated-inputs
`(("python-six" ,python-six)
("python-webencodings" ,python-webencodings)))
- (arguments
- `(#:test-target "check"))
+ (native-inputs
+ `(("python-pytest" ,python-pytest)
+ ("python-pytest-expect" ,python-pytest-expect)))
(home-page
"https://github.com/html5lib/html5lib-python")
(synopsis
--
2.26.2