From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id YNkdDRkbl2I70gAAbAwnHQ (envelope-from ) for ; Wed, 01 Jun 2022 09:54:01 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id KJHzDBkbl2KfGQAAauVa8A (envelope-from ) for ; Wed, 01 Jun 2022 09:54:01 +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 6BFD614927 for ; Wed, 1 Jun 2022 09:54:00 +0200 (CEST) Received: from localhost ([::1]:49026 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nwJB1-0008H8-LE for larch@yhetil.org; Wed, 01 Jun 2022 03:53:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43860) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nwJAm-0008Gz-Bv for guix-devel@gnu.org; Wed, 01 Jun 2022 03:53:44 -0400 Received: from sender4-of-o50.zoho.com ([136.143.188.50]:21017) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nwJAj-0000yo-RQ for guix-devel@gnu.org; Wed, 01 Jun 2022 03:53:43 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1654070010; cv=none; d=zohomail.com; s=zohoarc; b=DGT54tXi4i77GJisgSzaqC9qTe+zlI9qCcTC9Bp0UKk+2FP6PLxjqDMs8y7uUbqIIEk2biJM5NjWEf3NtW+FSunxwx5Sk5Ss7lSlahsmp0qSVmMFJMFvUGSkXef7XBLYhvrbRLDKmNgGgflLeXy+SqTM4cKWwnB+PjYp4ZAXyuo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654070010; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=LV2T9qCbPase1aL6fYvK7phDCvFfFMTykSjyqsRvV3A=; b=I2+d7Y28NNsJXf4khskAIe1/lXEU3F+5xT8/AyJ3TKoSDkiwcc1rSayvZ0ZJa2+dAPPrusXJXxtJmyiTMFYh0CTojUK4aXn6v9FrITFk2ByLBYAWloM/SRREj5Dred48lEpWq/CBsN8Apfqu/5j0HHpAp4+b3FunYszIkTpvd3c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=elephly.net; spf=pass smtp.mailfrom=rekado@elephly.net; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1654070010; s=zoho; d=elephly.net; i=rekado@elephly.net; h=References:From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:In-reply-to:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To; bh=LV2T9qCbPase1aL6fYvK7phDCvFfFMTykSjyqsRvV3A=; b=gk70yMKp98yBiC19wgQ9hVw+s4/VgNCDD/6nZ8tGjSDfdK20LxCycRbsll7ak8pa CWdQhxTLv4mZvw16J8eppSZRpPpmYPpNUfNT+jaQAfZwuw7bDeJRP3zUOCll9zAPBXn hKL8NegMhvPlNB9gf6QhW+iK+c+UpgPhoe5K5sPk= Received: from localhost (46-108-142-46.pool.kielnet.net [46.142.108.46]) by mx.zohomail.com with SMTPS id 1654070007053757.2132509831606; Wed, 1 Jun 2022 00:53:27 -0700 (PDT) References: User-agent: mu4e 1.6.10; emacs 28.1 From: Ricardo Wurmus To: guix-devel@gnu.org Cc: jgart Subject: Re: Supporting upstream supported Python versions Date: Wed, 01 Jun 2022 09:50:39 +0200 In-reply-to: X-URL: https://elephly.net X-PGP-Key: https://elephly.net/rekado.pubkey X-PGP-Fingerprint: BCA6 89B6 3655 3801 C3C6 2150 197A 5888 235F ACAC Message-ID: <87v8tkzuoc.fsf@elephly.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Received-SPF: pass client-ip=136.143.188.50; envelope-from=rekado@elephly.net; helo=sender4-of-o50.zoho.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: "Guix-devel" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1654070040; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=LV2T9qCbPase1aL6fYvK7phDCvFfFMTykSjyqsRvV3A=; b=nATJGmUY+ZqwiSFgHE8mfDR/JN8g2i9G4PYu56nJy6zkRZwoQO/yAzVeAth45T6VmngZ7H XP686tbGz8c/6fkLb5PsodWn/2Wh5NVnJZ0PECPySa6InhOkT5GaN27nOeBrEw3N+k2o/J U1Y2A+k34m54+IovxFUHy+N7eT8WKgVy0KapIbu0s1Jb03cSVZ8/3MsKO0CYOL3/LObaEi fyOYLt1WPZg8ycEpBP3qElYCGWNfb+RJ5rV+CjuWKM+Y1NnWGVnD2XcByYCVGdDKljOUwp /y0p8YZFOp5SmVbh/slp4TTZn+0yhbdPH8nbICHSpbto1VhDHf237hg97Tkbgw== ARC-Seal: i=2; s=key1; d=yhetil.org; t=1654070040; a=rsa-sha256; cv=pass; b=Wq14i7vlGYqPUvrhOCyq7WS6G5zWZvoKD3am3gzs86Bb4d8HHZh1Pat/S1EeM16l11wIm2 68I90aFNdoRsP3Ni60wQ8Gyyl2dgOcN/IVbaskA+B1f6bYXdn9yldpcWIPl9FfhXMhZhsw heib2iVI7N9kIGKuePjmYgOEt1bGU7E7KfPjX+5nqSeU9UTpKC6Spw6xi0jJbW/OPUiAIK Ca6xuib8gvX9fPi2jQxOC0XoFiDpltGBR0LUOf865GOuojnuFxNLRIv7xNZ7LXnLDpDb4j wB6fDyNGwOqBd2U5K/wsj/wLjXtOK5jvPCQlNBBoTloSAtsOFa/aFijwVCpEtw== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=pass header.d=elephly.net header.s=zoho header.b=gk70yMKp; arc=pass ("zohomail.com:s=zohoarc:i=1"); dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -3.03 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=elephly.net header.s=zoho header.b=gk70yMKp; arc=pass ("zohomail.com:s=zohoarc:i=1"); dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 6BFD614927 X-Spam-Score: -3.03 X-Migadu-Scanner: scn0.migadu.com X-TUID: 3ELhFwAFUI97 Hi, > From: jgart > To: Guix Devel > Subject: Supporting upstream supported Python versions > Message-ID: <20220517003848.GB18763@gac> [=E2=80=A6] > What is the opinion on supporting current upstream supported versions > of python? > > The master branch only has 3.9 but I'd like to have substitutes available > for 3.7, 3.8 and 3.10: The Guix Past channel now also has python-3.8. I recently needed to be able to build a profile with Python packages that were built with Python 3.8, but without replacing each and every instance of Python (because I don=E2=80=99t want to build librsvg, gtk+, et= c). Here=E2=80=99s the manifest I came up with: --8<---------------cut here---------------start------------->8--- ;;; Manifest to build the latest Python packages with Python 3.8. (use-modules (guix packages) ; for "package", "package-arguments"= ... (guix build-system python) (guix utils) (ice-9 match)) ;; The list of Python packages (or rather specifications) that we want ;; to build with an older Python. (define packages (list "python-numpy" "python-pytorch" "python-matplotlib" "python-scipy" "python-scikit-learn" "python-seaborn")) (define old-python (specification->package "python@3.8")) (define old-python-wrapper ;; We use wrap-python3 to create a "python" executable. Python ;; itself only comes with "python3". Python 3.8 is available in the ;; guix-past channel. ((@@ (gnu packages python) wrap-python3) old-python)) (define (python-package? package) (or (eq? python-build-system (package-build-system package)) ;; Special cases: packages that produce Python modules but don't ;; use the Python build system. (member (package-name package) (list "pybind11")))) ;; I'd love to just use modify-inputs here, but this python-wrapper vs ;; python complication forces me to do this manually. (define (replace-python-in-inputs inputs python-wrapper python) "Some packages have an explicit Python in the inputs, or use a separate output of the Python package. We use PYTHON-WRAPPER wherever the \"python\" executable may be needed and the plain PYTHON package where we need selected outputs." (map (match-lambda (("python" package out) `("python" ,python ,out)) (("python" package) `("python" ,python-wrapper)) (anything anything)) inputs)) (define (package-with-different-python pkg python-wrapper python) "Return a new package based on PKG that uses PYTHON during the build." (package/inherit pkg (arguments (if (eq? (package-build-system pkg) python-build-system) (ensure-keyword-arguments (package-arguments pkg) `(#:python ,python-wrapper #:tests? #false)) ;running tests is slow, so why bother? (package-arguments pkg))) (native-inputs (replace-python-in-inputs (package-native-inputs pkg) python-wrapper python)) (inputs (replace-python-in-inputs (package-inputs pkg) python-wrapper python)) (propagated-inputs (replace-python-in-inputs (package-propagated-inputs pkg) python-wrapper python)))) ;; This is a recursive package transformer. When given a package ;; "pkg" it checks if it is a Python package by looking at its build ;; system; if that is the case, it will return a package variant that ;; is built with the old Python. It does this recursively, so all ;; dependencies are also modified. (define use-old-python (package-mapping (lambda (pkg) (if (python-package? pkg) (let ((modified (package-with-different-python pkg old-python-wrapper old-python))) (match (package-name pkg) ;; This package also needs a newer version of setuptools; ;; Python 3.8 comes with an older version of setuptools. ((or "python-importlib-metadata" "python-ipython") (package/inherit modified (native-inputs (modify-inputs (package-native-inputs modified) (prepend (specification->package "python-setuptools"))))= )) ;; This package expects typing.py to export ;; _SpecialGenericAlias, but this version of Python does ;; not define it. ("python-typing-inspect" (package/inherit modified (arguments (substitute-keyword-arguments (package-arguments modified) ((#:phases phases '%standard-phases) `(modify-phases ,phases (add-after 'unpack 'do-not-import-SpecialGenericAlias (lambda _ (substitute* "typing_inspect.py" (("_SpecialGenericAlias") "_GenericAlias")))))))))) ;; The other packages don't need special treatment. (else modified))) pkg)) ;; Stop recursion when we hit a package that is not considered a ;; Python package. This could be a package that uses Python or ;; Python modules as inputs but does not itself produce a Python ;; module. This is to avoid needlessly rebuilding big things like ;; GTK+. (negate python-package?) #:deep? #false)) ;; Apply the transformer to the list of packages. (define python-packages-with-old-python (map (compose use-old-python specification->package) packages)) ;; Build a manifest from the list of modified packages and the old ;; Python variant itself. (packages->manifest (cons old-python python-packages-with-old-python)) --8<---------------cut here---------------end--------------->8--- --=20 Ricardo