1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2015, 2020 Efraim Flashner <efraim@flashner.co.il>
3 ;;; Copyright © 2016 Leo Famulari <leo@famulari.name>
4 ;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
5 ;;; Copyright © 2020 Tanguy Le Carrour <tanguy@bioneland.org>
6 ;;; Copyright © 2018, 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
7 ;;; Copyright © 2021 Tobias Geerinckx-Rice <me@tobias.gr>
8 ;;; Copyright © 2021, 2022 Ricardo Wurmus <rekado@elephly.net>
10 ;;; This file is part of GNU Guix.
12 ;;; GNU Guix is free software; you can redistribute it and/or modify it
13 ;;; under the terms of the GNU General Public License as published by
14 ;;; the Free Software Foundation; either version 3 of the License, or (at
15 ;;; your option) any later version.
17 ;;; GNU Guix is distributed in the hope that it will be useful, but
18 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;;; GNU General Public License for more details.
22 ;;; You should have received a copy of the GNU General Public License
23 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
25 (define-module (gnu packages python-build)
26 #:use-module (gnu packages)
27 #:use-module ((guix licenses) #:prefix license:)
28 #:use-module (guix build-system python)
29 #:use-module (guix gexp)
30 #:use-module (guix download)
31 #:use-module (guix git-download)
32 #:use-module (guix packages))
36 ;;; Python packages to build... Python packages. Since they are bound to be
37 ;;; relied on by many, their dependencies should be kept minimal, and this
38 ;;; module should not depend on other modules containing Python packages.
42 (define-public python-wheel
49 (uri (pypi-uri "wheel" version))
52 "1bbga5i49rj1cwi4sjpkvfhl1f8vl9lfky2lblsy768nk4wp5vz2"))))
53 (build-system python-build-system)
55 ;; FIXME: The test suite runs "python setup.py bdist_wheel", which in turn
56 ;; fails to find the newly-built bdist_wheel library, even though it is
57 ;; available on PYTHONPATH. What search path is consulted by setup.py?
59 (home-page "https://bitbucket.org/pypa/wheel/")
60 (synopsis "Format for built Python packages")
62 "A wheel is a ZIP-format archive with a specially formatted filename and
63 the @code{.whl} extension. It is designed to contain all the files for a PEP
64 376 compatible install in a way that is very close to the on-disk format. Many
65 packages will be properly installed with only the @code{Unpack} step and the
66 unpacked archive preserves enough information to @code{Spread} (copy data and
67 scripts to their final locations) at any later time. Wheel files can be
68 installed with a newer @code{pip} or with wheel's own command line utility.")
69 (license license:expat)))
71 (define-public python2-wheel
72 (package-with-python2 python-wheel))
74 ;;; XXX: Not really at home, but this seems the best place to prevent circular
75 ;;; module dependencies.
76 (define-public python-toml
83 (uri (pypi-uri "toml" version))
85 (base32 "13z6rff86bzdpl094x0vmfvls779931xj90dlbs9kpfm138s3gdk"))))
86 (build-system python-build-system)
88 `(#:tests? #f)) ;no tests suite in release
89 (home-page "https://github.com/uiri/toml")
90 (synopsis "Library for TOML")
92 "@code{toml} is a library for parsing and creating Tom's Obvious, Minimal
93 Language (TOML) configuration files.")
94 (license license:expat)))
96 (define-public python-tomli-w
98 (name "python-tomli-w")
103 (uri (pypi-uri "tomli_w" version))
105 (base32 "1fg13bfq5qy1ym4x77815nhxh1xpfs0drhn9r9464cz00m1l6qzl"))))
106 (build-system python-build-system)
109 #:tests? #f ;to avoid extra dependencies
111 #~(modify-phases %standard-phases
112 ;; XXX: PEP 517 manual build copied from python-isort.
115 (invoke "python" "-m" "build" "--wheel" "--no-isolation" ".")))
118 (let ((whl (car (find-files "dist" "\\.whl$"))))
119 (invoke "pip" "--no-cache-dir" "--no-input"
120 "install" "--no-deps" "--prefix" #$output whl)))))))
121 (native-inputs (list python-pypa-build python-flit-core))
122 (home-page "https://github.com/hukkin/tomli-w")
123 (synopsis "Minimal TOML writer")
124 (description "Tomli-W is a Python library for writing TOML. It is a
125 write-only counterpart to Tomli, which is a read-only TOML parser.")
126 (license license:expat)))
128 (define-public python-pytoml
130 (name "python-pytoml")
135 (uri (pypi-uri "pytoml" version))
138 "1rv1byiw82k7mj6aprcrqi2vdabs801y97xhfnrz7kxds34ggv4f"))))
139 (build-system python-build-system)
140 (home-page "https://github.com/avakar/pytoml")
141 (synopsis "Parser for TOML")
142 (description "This package provides a Python parser for TOML-0.4.0.")
143 (license license:expat)))
145 (define-public python-six-bootstrap
147 (name "python-six-bootstrap")
152 (uri (pypi-uri "six" version))
155 "09n9qih9rpj95q3r4a40li7hk6swma11syvgwdc68qm1fxsc6q8y"))))
156 (build-system python-build-system)
157 (arguments `(#:tests? #f)) ;to avoid pytest dependency
158 (home-page "https://pypi.org/project/six/")
159 (synopsis "Python 2 and 3 compatibility utilities")
161 "Six is a Python 2 and 3 compatibility library. It provides utility
162 functions for smoothing over the differences between the Python versions with
163 the goal of writing Python code that is compatible on both Python versions.
164 Six supports every Python version since 2.5. It is contained in only one
165 Python file, so it can be easily copied into your project.")
166 (license license:x11)))
168 (define-public python2-six-bootstrap
169 (package-with-python2 python-six-bootstrap))
171 (define-public python-tomli
173 (name "python-tomli")
178 (uri (pypi-uri "tomli" version))
180 (base32 "1q8lrh9ypa6zpgbc5f7z23p7phzblp4vpxdrpfr1wajhb17w74n2"))))
181 (build-system python-build-system)
183 `(#:tests? #f ;disabled to avoid extra dependencies
185 (modify-phases %standard-phases
188 (setenv "PYTHONPATH" (string-append (getcwd) ":"
189 (getenv "GUIX_PYTHONPATH")))
190 (invoke "python" "-m" "build" "--wheel" "--no-isolation"
191 "--skip-dependency-check")))
193 (lambda* (#:key outputs #:allow-other-keys)
194 (let ((out (assoc-ref outputs "out"))
195 (whl (car (find-files "dist" "\\.whl$"))))
196 (invoke "pip" "--no-cache-dir" "--no-input"
197 "install" "--no-deps" "--prefix" out whl)))))))
199 `(("python-flit-core-bootstrap" ,python-flit-core-bootstrap)
200 ("python-pypa-build" ,python-pypa-build)
201 ("python-six", python-six-bootstrap)))
202 (home-page "https://github.com/hukkin/tomli")
203 (synopsis "Small and fast TOML parser")
204 (description "Tomli is a minimal TOML parser that is fully compatible with
205 @url{https://toml.io/en/v1.0.0,TOML v1.0.0}. It is about 2.4 times as fast as
206 @code{python-toml}.")
207 (license license:expat)))
209 (define-public python-pep517-bootstrap
212 (name "python-pep517-bootstrap")
217 (uri (pypi-uri "pep517" version))
220 "0zqidxah03qpnp6zkg3zd1kmd5f79hhdsfmlc0cldaniy80qddxf"))))
221 (build-system python-build-system)
223 `(#:tests? #f)) ;to avoid circular dependencies
225 (list python-toml python-wheel))
226 (home-page "https://github.com/pypa/pep517")
227 (synopsis "Wrappers to build Python packages using PEP 517 hooks")
229 "Wrappers to build Python packages using PEP 517 hooks.")
230 (license license:expat))))
232 (define-public python-pyparsing
234 (name "python-pyparsing")
239 (uri (pypi-uri "pyparsing" version))
241 (base32 "109b9r802wb472hgmxclljprh5cid0w3p6mk9alba7pg2c0frgfr"))))
242 (build-system python-build-system)
243 (outputs '("out" "doc"))
245 `(#:tests? #f ;no test target
247 (modify-phases %standard-phases
248 (add-after 'install 'install-doc
249 (lambda* (#:key outputs #:allow-other-keys)
250 (let* ((doc (string-append (assoc-ref outputs "doc")
251 "/share/doc/" ,name "-" ,version))
252 (html-doc (string-append doc "/html"))
253 (examples (string-append doc "/examples")))
259 (install-file file tgt))
260 (find-files dir ".*")))
261 (list "docs" "htmldoc" "examples")
262 (list doc html-doc examples))))))))
263 (home-page "https://github.com/pyparsing/pyparsing")
264 (synopsis "Python parsing class library")
266 "The pyparsing module is an alternative approach to creating and
267 executing simple grammars, vs. the traditional lex/yacc approach, or the use
268 of regular expressions. The pyparsing module provides a library of classes
269 that client code uses to construct the grammar directly in Python code.")
270 (license license:expat)
271 (properties `((python2-variant . ,(delay python2-pyparsing))))))
273 ;;; This is the last release compatible with Python 2.
274 (define-public python-pyparsing-2.4.7
276 (inherit python-pyparsing)
281 (uri (pypi-uri "pyparsing" version))
283 (base32 "1hgc8qrbq1ymxbwfbjghv01fm3fbpjwpjwi0bcailxxzhf3yq0y2"))))))
285 (define-public python2-pyparsing
286 (package-with-python2 (strip-python2-variant python-pyparsing-2.4.7)))
288 (define-public python-packaging-bootstrap
290 (name "python-packaging-bootstrap")
295 (uri (pypi-uri "packaging" version))
298 "1sygirdrqgv4f1ckh9nhpcw1yfidrh3qjl86wq8vk6nq4wlw8iyx"))))
299 (build-system python-build-system)
300 (arguments `(#:tests? #f)) ;disabled to avoid extra dependencies
302 (list python-pyparsing python-six-bootstrap))
303 (home-page "https://github.com/pypa/packaging")
304 (synopsis "Core utilities for Python packages")
305 (description "Packaging is a Python module for dealing with Python packages.
306 It offers an interface for working with package versions, names, and dependency
308 ;; From 'LICENSE': This software is made available under the terms of
309 ;; *either* of the licenses found in LICENSE.APACHE or LICENSE.BSD.
310 ;; Contributions to this software is made under the terms of *both* these
312 (license (list license:asl2.0 license:bsd-2))
313 (properties `((python2-variant . ,(delay python2-packaging-bootstrap))))))
315 (define-public python2-packaging-bootstrap
316 (let ((base (package-with-python2
317 (strip-python2-variant python-packaging-bootstrap))))
318 (package/inherit base
319 (version "20.0") ;last version with Python 2 support
323 (uri (pypi-uri "packaging" version))
324 ;; XXX: The URL in the patch file is wrong, it should be
325 ;; <https://github.com/pypa/packaging/pull/256>.
326 (patches (search-patches "python-packaging-test-arch.patch"))
329 "1y2ip3a4ykkpgnwgn85j6hkspcl0cg3mzms97f40mk57vwqq67gy")))))))
331 ;;; The name 'python-pypa-build' is chosen rather than 'python-build' to avoid
332 ;;; a name clash with python-build from (guix build-system python).
333 (define-public python-pypa-build
335 (name "python-pypa-build")
339 (uri (pypi-uri "build" version))
342 "17xqija27x4my1yrnk6q2vwln60r39g2dhby9zg2l99qjgbdrahs"))))
343 (build-system python-build-system)
345 `(#:tests? #f ;to tests in the PyPI release
346 #:phases (modify-phases %standard-phases
347 (add-after 'unpack 'use-toml-instead-of-tomli
348 ;; Using toml instead of tomli eases bootstrapping.
350 (substitute* "setup.cfg"
354 `(("python-packaging" ,python-packaging-bootstrap)
355 ("python-pep517", python-pep517-bootstrap)
356 ("python-toml" ,python-toml)))
357 (home-page "https://pypa-build.readthedocs.io/en/latest/")
358 (synopsis "Simple Python PEP 517 package builder")
359 (description "The @command{build} command invokes the PEP 517 hooks to
360 build a distribution package. It is a simple build tool and does not perform
361 any dependency management. It aims to keep dependencies to a minimum, in
362 order to make bootstrapping easier.")
363 (license license:expat)))
365 (define-public python-poetry-core
367 (name "python-poetry-core")
372 (uri (pypi-uri "poetry-core" version))
374 (base32 "01n2rbsvks7snrq3m1d08r3xz9q2715ajb62fdb6rvqnb9sirhcq"))))
375 (build-system python-build-system)
376 (home-page "https://github.com/python-poetry/poetry-core")
377 (synopsis "Poetry PEP 517 build back-end")
379 "The @code{poetry-core} module provides a PEP 517 build back-end
380 implementation developed for Poetry. This project is intended to be
381 a light weight, fully compliant, self-contained package allowing PEP 517
382 compatible build front-ends to build Poetry managed projects.")
383 (license license:expat)))
385 ;;; This package exists to bootstrap python-tomli.
386 (define-public python-flit-core-bootstrap
388 (name "python-flit-core-bootstrap")
393 (uri (pypi-uri "flit" version))
395 (base32 "04152qj46sqbnlrj7ch9p7svjrrlpzbk0qr39g2yr0s4f5vp6frf"))))
396 (build-system python-build-system)
400 ;; flit-core has a test suite, but it requires Pytest. Disable it so
401 ;; as to not pull pytest as an input.
404 (modify-phases %standard-phases
406 ;; flit-core requires itself to build. Luckily, a
407 ;; bootstrapping script exists, which does so using just
408 ;; the checkout sources and Python.
410 (invoke "python" "flit_core/build_dists.py")))
412 (lambda* (#:key inputs outputs #:allow-other-keys)
413 (let ((out (assoc-ref outputs "out"))
414 (whl (car (find-files "." "\\.whl$"))))
415 (invoke "pip" "--no-cache-dir" "--no-input"
416 "install" "--no-deps" "--prefix" out whl))))
417 ;; The sanity-check phase fails because flit depends on tomli at
418 ;; run-time, but this core variant avoids it to avoid a cycle.
419 (delete 'sanity-check))))
420 (home-page "https://github.com/takluyver/flit")
421 (synopsis "Core package of the Flit Python build system")
422 (description "This package provides @code{flit-core}, a PEP 517 build
423 backend for packages using Flit. The only public interface is the API
424 specified by PEP 517, @code{flit_core.buildapi}.")
425 (license license:bsd-3)))
427 (define-public python-flit-core
428 (package/inherit python-flit-core-bootstrap
429 (name "python-flit-core")
431 (modify-inputs (package-propagated-inputs python-flit-core-bootstrap)
432 (replace "python-toml" python-tomli)))))