From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id IA0eI4aEUGOUcQEAbAwnHQ (envelope-from ) for ; Thu, 20 Oct 2022 01:13:10 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id CPI3I4aEUGP3DAEA9RJhRA (envelope-from ) for ; Thu, 20 Oct 2022 01:13:10 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 10F883B46D for ; Thu, 20 Oct 2022 01:13:09 +0200 (CEST) Received: from localhost ([::1]:53042 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olIFH-0006s0-Qx for larch@yhetil.org; Wed, 19 Oct 2022 19:13:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46040) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olIFC-0006rc-P5 for guix-patches@gnu.org; Wed, 19 Oct 2022 19:13:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:33090) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1olIFC-0002s5-HB for guix-patches@gnu.org; Wed, 19 Oct 2022 19:13:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1olIFB-0008LW-VT for guix-patches@gnu.org; Wed, 19 Oct 2022 19:13:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#58587] [PATCH 00/14] Introducing pyproject-build-system. Resent-From: Marius Bakke Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 19 Oct 2022 23:13:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58587 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: zimoun , 58587@debbugs.gnu.org Cc: Lars-Dominik Braun , Maxim Cournoyer Received: via spool by 58587-submit@debbugs.gnu.org id=B58587.166622112732005 (code B ref 58587); Wed, 19 Oct 2022 23:13:01 +0000 Received: (at 58587) by debbugs.gnu.org; 19 Oct 2022 23:12:07 +0000 Received: from localhost ([127.0.0.1]:60401 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1olIEH-0008K8-JC for submit@debbugs.gnu.org; Wed, 19 Oct 2022 19:12:06 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38080) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1olIEB-0008Ja-S4 for 58587@debbugs.gnu.org; Wed, 19 Oct 2022 19:12:03 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:39354) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olIE5-0002lp-VE; Wed, 19 Oct 2022 19:11:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=dHOIYMWInZbHm9YxJV+V4vJYNE3x6nwO5E90wLSn93U=; b=M88OY2kwdU8YSEfxTteA fVH+OmPYW3YGmsnx8buuyLDqP6dmxLivgW4S/BsOlbpze20OVH1Y5mLrChq6il6r69W2RmiKyhXYt VCsYrZxYbqQfPjFX7duWVKG92kYgXa20+AThFEdSc709SQ3MtGpgbGPg2zURwTuOmgipZVAfyYQed OBbuztBqMxiJPm6X+TXMhamiOQCOTbbIV8pJ4XU0jWHz61sSRTJmKwAHmgvSwsTmMqzoww9AxoVBZ Wutz9wd6nbuBOr+XGPCtlWWMQYWZDvz17gdb7sbLwuja5Ha//qATo+JzfiiDvk5TeLumYugMmAXfE iwlcl2iJbO4dMA==; Received: from [84.211.203.64] (port=49444 helo=localhost) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olIE5-0006vQ-9a; Wed, 19 Oct 2022 19:11:53 -0400 From: Marius Bakke In-Reply-To: <86ilkgp2hx.fsf@gmail.com> References: <20221017200624.4076-1-marius@gnu.org> <86sfjlzdbn.fsf@gmail.com> <877d0wvlzg.fsf@gnu.org> <86ilkgp2hx.fsf@gmail.com> Date: Thu, 20 Oct 2022 01:11:49 +0200 Message-ID: <871qr3v26i.fsf@gnu.org> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1666221190; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=dHOIYMWInZbHm9YxJV+V4vJYNE3x6nwO5E90wLSn93U=; b=a6622vPiLeWVHl9f3uqfiZOPB34nmLot7ABSVKJMfRSNS0nDzd6owQXxBei3clrR9zduqW mhQzh1YlxZBD9gaAgrA4qE7bprVHPJiyheNsQJq01gAS9zHv6YG/z1k/MQmsvRiWZJgabj 4Cu/Jj5PyTZUg8SHrcrv2UkJ8Rum60HOeTl6Mz/BfnBPdj7A9zF37zaRgtUAUqQntoinOD GMjWTezaVTPVYB9CLJPJM9O+ROOPIt+huNpma9hbYJfMgXKQKprLUiyKVoV/3JH7wL64sd s+c446ZUdaI0rblPn5muBGju3wNPifBvbegUnWy0NCMl+fgwdfmUrdHkeyT+nw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1666221190; a=rsa-sha256; cv=none; b=KtkvDEs4am2nw5yODPQ+ItMM2Zmna1qi8+6/vdFafOffNuqW077iqqjOR4t3kaO16ByMZv 97VJqvx2P8Os2COkMft3AERFEXzyX7MrbBEH5xMtfu19SSgynD0pD1Sc85aJZoUme5hGmA jzLwisHD8VB0prfRs5JkLr3a+/ILMoZPZv8j9hG+NGjVK7iAqrbnSWyd2OFLTcpF3TQKbr AaXdxF8toGd0laIutafjihXYoPw6p9kDHug7yFRa9GXLMB0rBuPHyQS9lWr4jiCiDm5swk /ewvzEfxmRRWfR0rs2fYibPggK5ERVfWput5rXjQlsPwGGFkmC31LaOrNl5EKg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=M88OY2kw; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -2.92 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=M88OY2kw; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 10F883B46D X-Spam-Score: -2.92 X-Migadu-Scanner: scn1.migadu.com X-TUID: YvWIGr66JIso --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain zimoun skriver: > I would add a note, for instance, something like that: [...] Good idea, although I don't like to duplicate so much information from the build system description. Here is my attempt: --=-=-= Content-Type: text/x-patch Content-Disposition: inline diff --git a/doc/contributing.texi b/doc/contributing.texi index b9260267fa..d12daa7ec3 100644 --- a/doc/contributing.texi +++ b/doc/contributing.texi @@ -786,6 +786,21 @@ for instance, the module python-dateutil is packaged under the names starts with @code{py} (e.g.@: @code{pytz}), we keep it and prefix it as described above. +@quotation Note +Currently there are two different build systems for Python packages in Guix: +@var{python-build-system} and @var{pyproject-build-system}. For the +longest time, Python packages were built from an informally specified +@file{setup.py} file. That worked amazingly well, considering Pythons +success, but was difficult to build tooling around. As a result, a host +of alternative build systems emerged and the community eventually settled on a +@url{https://peps.python.org/pep-0517/, formal standard} for specifying build +requirements. @var{pyproject-build-system} is Guix's implementation of this +standard. It is considered ``experimental'' in that it does not yet support +all the various PEP-517 @emph{build backends}, but you are encouraged to try +it for new Python packages and report any problems. It will eventually be +deprecated and merged into @var{python-build-system}. +@end quotation + @subsubsection Specifying Dependencies @cindex inputs, for Python packages --=-=-= Content-Type: text/plain >> +@defvr {Scheme Variable} pyproject-build-system >> +This is a variable exported by @code{guix build-system pyproject}. It >> +is a reimplementation of @code{python-build-system} designed around > ^ > s/code/var Fixed both instances, thanks. :-) I also made some substantial changes to the build system: * Moved 'python-toolchain' into python.scm which seems to work fine. * Inherit from python-build-system where possible. * Hint about deprecating 'add-installed-pythonpath', which has always annoyed me :-) I think a 'with-installed-pythonpath' would be much more ergonomic and plan to submit that later. * Most importantly, use three ;;; for module commentary. Patch below: --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0001-fixup-pyproject.patch Content-Transfer-Encoding: quoted-printable From=20e765fbe232ddc57dd8ac2622a30736c5483bbf54 Mon Sep 17 00:00:00 2001 From: Marius Bakke Date: Wed, 19 Oct 2022 23:10:24 +0200 Subject: [PATCH] fixup pyproject =2D-- gnu/local.mk | 1 - gnu/packages/python-commencement.scm | 64 --------- gnu/packages/python.scm | 39 +++++- guix/build-system/pyproject.scm | 2 +- guix/build/pyproject-build-system.scm | 180 ++++++++------------------ 5 files changed, 95 insertions(+), 191 deletions(-) delete mode 100644 gnu/packages/python-commencement.scm diff --git a/gnu/local.mk b/gnu/local.mk index b6e0d262be..bf598cec8b 100644 =2D-- a/gnu/local.mk +++ b/gnu/local.mk @@ -511,7 +511,6 @@ GNU_SYSTEM_MODULES =3D \ %D%/packages/python-build.scm \ %D%/packages/python-check.scm \ %D%/packages/python-compression.scm \ =2D %D%/packages/python-commencement.scm \ %D%/packages/python-crypto.scm \ %D%/packages/python-science.scm \ %D%/packages/python-web.scm \ diff --git a/gnu/packages/python-commencement.scm b/gnu/packages/python-com= mencement.scm deleted file mode 100644 index 011ba2c38d..0000000000 =2D-- a/gnu/packages/python-commencement.scm +++ /dev/null @@ -1,64 +0,0 @@ =2D;;; GNU Guix --- Functional package management for GNU =2D;;; Copyright =C2=A9 2021 Lars-Dominik Braun =2D;;; Copyright =C2=A9 2022 Marius Bakke =2D;;; =2D;;; This file is part of GNU Guix. =2D;;; =2D;;; GNU Guix is free software; you can redistribute it and/or modify it =2D;;; under the terms of the GNU General Public License as published by =2D;;; the Free Software Foundation; either version 3 of the License, or (at =2D;;; your option) any later version. =2D;;; =2D;;; GNU Guix is distributed in the hope that it will be useful, but =2D;;; WITHOUT ANY WARRANTY; without even the implied warranty of =2D;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the =2D;;; GNU General Public License for more details. =2D;;; =2D;;; You should have received a copy of the GNU General Public License =2D;;; along with GNU Guix. If not, see . =2D =2D(define-module (gnu packages python-commencement) =2D #:use-module ((guix licenses) #:prefix license:) =2D #:use-module (guix packages) =2D #:use-module (guix gexp) =2D #:use-module (guix build-system trivial) =2D #:use-module (gnu packages) =2D #:use-module (gnu packages python) =2D #:use-module (gnu packages python-build) =2D #:use-module (srfi srfi-1) =2D #:use-module (srfi srfi-26)) =2D =2D(define-public python-toolchain =2D (package =2D (name "python-toolchain") =2D (version (package-version python)) =2D (source #f) =2D (build-system trivial-build-system) =2D (arguments =2D (list #:modules '((guix build union)) =2D #:builder =2D #~(begin =2D (use-modules (ice-9 match) =2D (srfi srfi-1) =2D (guix build union)) =2D (union-build #$output =2D (filter-map (match-lambda =2D ((_ . directory) directory)) =2D %build-inputs))))) =2D (inputs =2D (list python-sans-pip-wrapper =2D python-pypa-build =2D python-pip =2D python-setuptools =2D python-wheel)) =2D (native-search-paths =2D (package-native-search-paths python)) =2D (search-paths =2D (package-search-paths python)) =2D (license (package-license python)) =2D (synopsis "Python toolchain") =2D (description =2D "Python toolchain including Python itself, setuptools and pip. Use= this =2Dpackage if you need a minimal Python toolchain instead of just the =2Dinterpreter.") =2D (home-page (package-home-page python)))) diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm index 953044f55f..f55e5a16da 100644 =2D-- a/gnu/packages/python.scm +++ b/gnu/packages/python.scm @@ -26,7 +26,7 @@ ;;; Copyright =C2=A9 2016, 2017 Nikita ;;; Copyright =C2=A9 2016 Dylan Jeffers ;;; Copyright =C2=A9 2016 David Craven =2D;;; Copyright =C2=A9 2016, 2017, 2018, 2019, 2020, 2021 Marius Bakke +;;; Copyright =C2=A9 2016-2022 Marius Bakke ;;; Copyright =C2=A9 2016, 2017 Stefan Reich=C3=B6r ;;; Copyright =C2=A9 2016, 2017 Alex Vong ;;; Copyright =C2=A9 2016, 2017, 2018 Arun Isaac @@ -60,6 +60,7 @@ ;;; Copyright =C2=A9 2020, 2021 Greg Hogan ;;; Copyright =C2=A9 2022 Philip McGrath ;;; Copyright =C2=A9 2022 jgart +;;; Copyright =C2=A9 2021 Lars-Dominik Braun ;;; ;;; This file is part of GNU Guix. ;;; @@ -87,6 +88,7 @@ (define-module (gnu packages python) #:use-module (gnu packages hurd) #:use-module (gnu packages libffi) #:use-module (gnu packages pkg-config) + #:use-module (gnu packages python-build) #:use-module (gnu packages readline) #:use-module (gnu packages sqlite) #:use-module (gnu packages tcl) @@ -687,6 +689,41 @@ (define-public python-sans-pip (define-public python-sans-pip-wrapper (wrap-python3 python-sans-pip)) =20 +(define-public python-toolchain + (package + (name "python-toolchain") + (version (package-version python)) + (source #f) + (build-system trivial-build-system) + (arguments + (list #:modules '((guix build union)) + #:builder + #~(begin + (use-modules (ice-9 match) + (srfi srfi-1) + (guix build union)) + (union-build #$output + (filter-map (match-lambda + ((_ . directory) directory)) + %build-inputs))))) + (inputs + (list python-sans-pip-wrapper + python-pip + python-pypa-build + python-setuptools + python-wheel)) + (native-search-paths + (package-native-search-paths python)) + (search-paths + (package-search-paths python)) + (license (package-license python)) + (synopsis "Python toolchain") + (description + "Python toolchain including Python itself, setuptools and pip. Use t= his +package if you need a minimal Python toolchain instead of just the +interpreter.") + (home-page (package-home-page python)))) + (define-public micropython (package (name "micropython") diff --git a/guix/build-system/pyproject.scm b/guix/build-system/pyproject.= scm index 8e320529cc..d6b727ab5d 100644 =2D-- a/guix/build-system/pyproject.scm +++ b/guix/build-system/pyproject.scm @@ -56,7 +56,7 @@ (define %pyproject-build-system-modules (define (default-python) "Return the default Python package." ;; Lazily resolve the binding to avoid a circular dependency. =2D (let ((python (resolve-interface '(gnu packages python-commencement)))) + (let ((python (resolve-interface '(gnu packages python)))) (module-ref python 'python-toolchain))) =20 (define sanity-check.py diff --git a/guix/build/pyproject-build-system.scm b/guix/build/pyproject-b= uild-system.scm index 141d4d849f..db317e10e5 100644 =2D-- a/guix/build/pyproject-build-system.scm +++ b/guix/build/pyproject-build-system.scm @@ -32,7 +32,7 @@ ;;; along with GNU Guix. If not, see . =20 (define-module (guix build pyproject-build-system) =2D #:use-module ((guix build gnu-build-system) #:prefix gnu:) + #:use-module ((guix build python-build-system) #:prefix python:) #:use-module (guix build utils) #:use-module (guix build json) #:use-module (ice-9 match) @@ -50,31 +50,42 @@ (define-module (guix build pyproject-build-system) python-version pyproject-build)) =20 =2D;; Commentary: =2D;; =2D;; PEP 517-compatible build system for Python packages. =2D;; =2D;; PEP 517 mandates the use of a TOML file called pyproject.toml at the =2D;; project root, describing build and runtime dependencies, as well as t= he =2D;; build system, which can be different from setuptools. This module uses =2D;; that file to extract the build system used and call its wheel-building =2D;; entry point build_wheel (see 'build). setuptools=E2=80=99 wheel build= er is =2D;; used as a fallback if either no pyproject.toml exists or it does not =2D;; declare a build-system. It supports config_settings through the =2D;; standard #:configure-flags argument. =2D;; =2D;; This wheel, which is just a ZIP file with a file structure defined =2D;; by PEP 427 (https://www.python.org/dev/peps/pep-0427/), is then unpac= ked =2D;; and its contents are moved to the appropriate locations in 'install. =2D;; =2D;; Then entry points, as defined by the PyPa Entry Point Specification =2D;; (https://packaging.python.org/specifications/entry-points/) are read =2D;; from a file called entry_points.txt in the package=E2=80=99s site-pac= kages =2D;; subdirectory and scripts are written to bin/. These are not part of a =2D;; wheel and expected to be created by the installing utility. =2D;; =2D;; Caveats: =2D;; - There is no support for in-tree build backends. +;;; Commentary: +;;; +;;; PEP 517-compatible build system for Python packages. +;;; +;;; PEP 517 mandates the use of a TOML file called pyproject.toml at the +;;; project root, describing build and runtime dependencies, as well as the +;;; build system, which can be different from setuptools. This module uses +;;; that file to extract the build system used and call its wheel-building +;;; entry point build_wheel (see 'build). setuptools=E2=80=99 wheel builde= r is +;;; used as a fallback if either no pyproject.toml exists or it does not +;;; declare a build-system. It supports config_settings through the +;;; standard #:configure-flags argument. +;;; +;;; This wheel, which is just a ZIP file with a file structure defined +;;; by PEP 427 (https://www.python.org/dev/peps/pep-0427/), is then unpack= ed +;;; and its contents are moved to the appropriate locations in 'install. +;;; +;;; Then entry points, as defined by the PyPa Entry Point Specification +;;; (https://packaging.python.org/specifications/entry-points/) are read +;;; from a file called entry_points.txt in the package=E2=80=99s site-pack= ages +;;; subdirectory and scripts are written to bin/. These are not part of a +;;; wheel and expected to be created by the installing utility. +;;; +;;; Caveats: +;;; - There is no support for in-tree build backends. +;;; +;;; Code: +;;; + +;; Re-export these variables from python-build-system as many packages +;; rely on these. +(define python-version python:python-version) +(define site-packages python:site-packages) +;; XXX: This procedure is not very functional, now might be a good time +;; to deprecate it. +(define add-installed-pythonpath python:add-installed-pythonpath) =20 ;; Base error type. (define-condition-type &python-build-error &error @@ -179,39 +190,6 @@ (define* (check #:key inputs outputs tests? test-backe= nd test-flags #:allow-othe (else (raise (condition (&test-system-not-found)))))) (format #t "test suite not run~%"))) =20 =2D(define (python-version python) =2D (let* ((version (last (string-split python #\-))) =2D (components (string-split version #\.)) =2D (major+minor (take components 2))) =2D (string-join major+minor "."))) =2D =2D(define (python-output outputs) =2D "Return the path of the python output, if there is one, or fall-back t= o out." =2D (or (assoc-ref outputs "python") =2D (assoc-ref outputs "out"))) =2D =2D(define (site-packages inputs outputs) =2D "Return the path of the current output's Python site-package." =2D (let* ((out (python-output outputs)) =2D (python (assoc-ref inputs "python"))) =2D (string-append out "/lib/python" (python-version python) "/site-pack= ages"))) =2D =2D(define (add-installed-pythonpath inputs outputs) =2D "Prepend the site-package of OUTPUT to GUIX_PYTHONPATH. This is usefu= l when =2Drunning checks after installing the package." =2D (setenv "GUIX_PYTHONPATH" (string-append (site-packages inputs outputs= ) ":" =2D (getenv "GUIX_PYTHONPATH")))) =2D =2D(define* (add-install-to-pythonpath #:key inputs outputs #:allow-other-k= eys) =2D "A phase that just wraps the 'add-installed-pythonpath' procedure." =2D (add-installed-pythonpath inputs outputs)) =2D =2D(define* (add-install-to-path #:key outputs #:allow-other-keys) =2D "Adding Python scripts to PATH is also often useful in tests." =2D (setenv "PATH" (string-append (assoc-ref outputs "out") =2D "/bin:" =2D (getenv "PATH")))) =2D (define* (install #:key inputs outputs (configure-flags '()) #:allow-other= -keys) "Install a wheel file according to PEP 427" ;; See https://www.python.org/dev/peps/pep-0427/#installing-a-wheel-dist= ribution-1-0-py32-none-any-whl @@ -301,9 +279,20 @@ (define (list-directories base predicate) =20 (define* (compile-bytecode #:key inputs outputs (configure-flags '()) #:al= low-other-keys) "Compile installed byte-code in site-packages." =2D (let ((site-dir (site-packages inputs outputs))) =2D (invoke "python" "-m" "compileall" "--invalidation-mode=3Dunchecked-= hash" =2D site-dir))) + (let* ((site-dir (site-packages inputs outputs)) + (python (assoc-ref inputs "python")) + (major-minor (map string->number + (take (string-split (python-version python) #\.= ) 2))) + (<3.7? (match major-minor + ((major minor) + (or (< major 3) (and (=3D major 3) (< minor 7))))))) + (if <3.7? + ;; These versions don=E2=80=99t have the hash invalidation modes a= nd do + ;; not produce reproducible bytecode files. + (format #t "Skipping bytecode compilation for Python version ~a < = 3.7~%" + (python-version python)) + (invoke "python" "-m" "compileall" "--invalidation-mode=3Dunchecke= d-hash" + site-dir)))) =20 (define* (create-entrypoints #:key inputs outputs (configure-flags '()) #:= allow-other-keys) "Implement Entry Points Specification @@ -371,34 +360,6 @@ (define (create-script path name module function) (entry-points.txt->entry-points f))) entry-point-files))) =20 =2D(define* (wrap #:key inputs outputs search-paths #:allow-other-keys) =2D (define (list-of-files dir) =2D (find-files dir (lambda (file stat) =2D (and (eq? 'regular (stat:type stat)) =2D (not (wrapped-program? file)))))) =2D =2D (define bindirs =2D (append-map (match-lambda =2D ((_ . dir) =2D (list (string-append dir "/bin") =2D (string-append dir "/sbin")))) =2D outputs)) =2D =2D ;; Do not require "bash" to be present in the package inputs =2D ;; even when there is nothing to wrap. =2D ;; Also, calculate (sh) only once to prevent some I/O. =2D (define %sh (delay (search-input-file inputs "bin/bash"))) =2D (define (sh) (force %sh)) =2D =2D (let* ((var `("GUIX_PYTHONPATH" prefix =2D ,(search-path-as-string->list =2D (or (getenv "GUIX_PYTHONPATH") ""))))) =2D (for-each (lambda (dir) =2D (let ((files (list-of-files dir))) =2D (for-each (cut wrap-program <> #:sh (sh) var) =2D files))) =2D bindirs))) =2D (define* (set-SOURCE-DATE-EPOCH #:rest _) "Set the 'SOURCE_DATE_EPOCH' environment variable. This is used by tools that incorporate timestamps as a way to tell them to use a fixed timestamp. @@ -407,54 +368,25 @@ (define* (set-SOURCE-DATE-EPOCH #:rest _) ;; not support timestamps before 1980. (setenv "SOURCE_DATE_EPOCH" "315619200")) =20 =2D(define* (enable-bytecode-determinism #:rest _) =2D "Improve determinism of pyc files." =2D ;; Use deterministic hashes for strings, bytes, and datetime objects. =2D (setenv "PYTHONHASHSEED" "0") =2D ;; Prevent Python from creating .pyc files when loading modules (such = as =2D ;; when running a test suite). =2D (setenv "PYTHONDONTWRITEBYTECODE" "1")) =2D =2D(define* (ensure-no-cythonized-files #:rest _) =2D "Check the source code for @code{.c} files which may have been pre-gen= erated =2Dby Cython." =2D (for-each =2D (lambda (file) =2D (let ((generated-file =2D (string-append (string-drop-right file 3) "c"))) =2D (when (file-exists? generated-file) =2D (format #t "Possible Cythonized file found: ~a~%" generated-fi= le)))) =2D (find-files "." "\\.pyx$"))) =2D (define %standard-phases ;; The build phase only builds C extensions and copies the Python source= s, ;; while the install phase copies then byte-compiles the sources to the ;; prefix directory. The check phase is moved after the installation ph= ase ;; to ease testing the built package. =2D (modify-phases gnu:%standard-phases =2D (add-after 'unpack 'enable-bytecode-determinism =2D enable-bytecode-determinism) =2D (add-after 'enable-bytecode-determinism 'ensure-no-cythonized-files =2D ensure-no-cythonized-files) + (modify-phases python:%standard-phases (replace 'set-SOURCE-DATE-EPOCH set-SOURCE-DATE-EPOCH) =2D (delete 'bootstrap) =2D (delete 'configure) ;not needed (replace 'build build) =2D (delete 'check) ;moved after the install phase (replace 'install install) =2D (add-after 'install 'add-install-to-pythonpath add-install-to-python= path) =2D (add-after 'add-install-to-pythonpath 'add-install-to-path =2D add-install-to-path) =2D (add-after 'add-install-to-path 'wrap wrap) =2D ;; must be before tests, so they can use installed packages=E2=80=99= entry points. + (delete 'check) + ;; Must be before tests, so they can use installed packages=E2=80=99 e= ntry points. (add-before 'wrap 'create-entrypoints create-entrypoints) (add-after 'wrap 'check check) =2D (add-after 'check 'sanity-check sanity-check) + (replace 'sanity-check sanity-check) (add-before 'check 'compile-bytecode compile-bytecode))) =20 (define* (pyproject-build #:key inputs (phases %standard-phases) #:allow-other-keys #:rest args) "Build the given Python package, applying all of PHASES in order." =2D (apply gnu:gnu-build #:inputs inputs #:phases phases args)) + (apply python:python-build #:inputs inputs #:phases phases args)) =20 ;;; pyproject-build-system.scm ends here =2D-=20 2.38.0 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iIUEARYKAC0WIQRNTknu3zbaMQ2ddzTocYulkRQQdwUCY1CENQ8cbWFyaXVzQGdu dS5vcmcACgkQ6HGLpZEUEHf8gQD8DY121u0V6gzcSqLgo6atwR9Cpi01rG3jgHph EO85aFkBAL19JRv/R5qQLp+BxvqlBan/NRqZpWHYEtM6yBWCr7gG =Y0F9 -----END PGP SIGNATURE----- --==-=-=--