gnu: Remove python2-pyaudio.
[jackhill/guix/guix.git] / gnu / packages / python-build.scm
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>
9 ;;;
10 ;;; This file is part of GNU Guix.
11 ;;;
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.
16 ;;;
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.
21 ;;;
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/>.
24
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))
33
34 ;;; Commentary:
35 ;;;
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.
39 ;;;
40 ;;; Code:
41
42 (define-public python-wheel
43 (package
44 (name "python-wheel")
45 (version "0.37.0")
46 (source
47 (origin
48 (method url-fetch)
49 (uri (pypi-uri "wheel" version))
50 (sha256
51 (base32
52 "1bbga5i49rj1cwi4sjpkvfhl1f8vl9lfky2lblsy768nk4wp5vz2"))))
53 (build-system python-build-system)
54 (arguments
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?
58 '(#:tests? #f))
59 (home-page "https://bitbucket.org/pypa/wheel/")
60 (synopsis "Format for built Python packages")
61 (description
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)))
70
71 (define-public python2-wheel
72 (package-with-python2 python-wheel))
73
74 ;;; XXX: Not really at home, but this seems the best place to prevent circular
75 ;;; module dependencies.
76 (define-public python-toml
77 (package
78 (name "python-toml")
79 (version "0.10.2")
80 (source
81 (origin
82 (method url-fetch)
83 (uri (pypi-uri "toml" version))
84 (sha256
85 (base32 "13z6rff86bzdpl094x0vmfvls779931xj90dlbs9kpfm138s3gdk"))))
86 (build-system python-build-system)
87 (arguments
88 `(#:tests? #f)) ;no tests suite in release
89 (home-page "https://github.com/uiri/toml")
90 (synopsis "Library for TOML")
91 (description
92 "@code{toml} is a library for parsing and creating Tom's Obvious, Minimal
93 Language (TOML) configuration files.")
94 (license license:expat)))
95
96 (define-public python-tomli-w
97 (package
98 (name "python-tomli-w")
99 (version "1.0.0")
100 (source
101 (origin
102 (method url-fetch)
103 (uri (pypi-uri "tomli_w" version))
104 (sha256
105 (base32 "1fg13bfq5qy1ym4x77815nhxh1xpfs0drhn9r9464cz00m1l6qzl"))))
106 (build-system python-build-system)
107 (arguments
108 (list
109 #:tests? #f ;to avoid extra dependencies
110 #:phases
111 #~(modify-phases %standard-phases
112 ;; XXX: PEP 517 manual build copied from python-isort.
113 (replace 'build
114 (lambda _
115 (invoke "python" "-m" "build" "--wheel" "--no-isolation" ".")))
116 (replace 'install
117 (lambda _
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)))
127
128 (define-public python-pytoml
129 (package
130 (name "python-pytoml")
131 (version "0.1.21")
132 (source
133 (origin
134 (method url-fetch)
135 (uri (pypi-uri "pytoml" version))
136 (sha256
137 (base32
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)))
144
145 (define-public python-six-bootstrap
146 (package
147 (name "python-six-bootstrap")
148 (version "1.16.0")
149 (source
150 (origin
151 (method url-fetch)
152 (uri (pypi-uri "six" version))
153 (sha256
154 (base32
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")
160 (description
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)))
167
168 (define-public python2-six-bootstrap
169 (package-with-python2 python-six-bootstrap))
170
171 (define-public python-tomli
172 (package
173 (name "python-tomli")
174 (version "2.0.0")
175 (source
176 (origin
177 (method url-fetch)
178 (uri (pypi-uri "tomli" version))
179 (sha256
180 (base32 "1q8lrh9ypa6zpgbc5f7z23p7phzblp4vpxdrpfr1wajhb17w74n2"))))
181 (build-system python-build-system)
182 (arguments
183 `(#:tests? #f ;disabled to avoid extra dependencies
184 #:phases
185 (modify-phases %standard-phases
186 (replace 'build
187 (lambda _
188 (setenv "PYTHONPATH" (string-append (getcwd) ":"
189 (getenv "GUIX_PYTHONPATH")))
190 (invoke "python" "-m" "build" "--wheel" "--no-isolation"
191 "--skip-dependency-check")))
192 (replace 'install
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)))))))
198 (native-inputs
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)))
208
209 (define-public python-pep517-bootstrap
210 (hidden-package
211 (package
212 (name "python-pep517-bootstrap")
213 (version "0.9.1")
214 (source
215 (origin
216 (method url-fetch)
217 (uri (pypi-uri "pep517" version))
218 (sha256
219 (base32
220 "0zqidxah03qpnp6zkg3zd1kmd5f79hhdsfmlc0cldaniy80qddxf"))))
221 (build-system python-build-system)
222 (arguments
223 `(#:tests? #f)) ;to avoid circular dependencies
224 (propagated-inputs
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")
228 (description
229 "Wrappers to build Python packages using PEP 517 hooks.")
230 (license license:expat))))
231
232 (define-public python-pyparsing
233 (package
234 (name "python-pyparsing")
235 (version "3.0.6")
236 (source
237 (origin
238 (method url-fetch)
239 (uri (pypi-uri "pyparsing" version))
240 (sha256
241 (base32 "109b9r802wb472hgmxclljprh5cid0w3p6mk9alba7pg2c0frgfr"))))
242 (build-system python-build-system)
243 (outputs '("out" "doc"))
244 (arguments
245 `(#:tests? #f ;no test target
246 #:phases
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")))
254 (mkdir-p html-doc)
255 (mkdir-p examples)
256 (for-each
257 (lambda (dir tgt)
258 (map (lambda (file)
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")
265 (description
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))))))
272
273 ;;; This is the last release compatible with Python 2.
274 (define-public python-pyparsing-2.4.7
275 (package
276 (inherit python-pyparsing)
277 (version "2.4.7")
278 (source
279 (origin
280 (method url-fetch)
281 (uri (pypi-uri "pyparsing" version))
282 (sha256
283 (base32 "1hgc8qrbq1ymxbwfbjghv01fm3fbpjwpjwi0bcailxxzhf3yq0y2"))))))
284
285 (define-public python2-pyparsing
286 (package-with-python2 (strip-python2-variant python-pyparsing-2.4.7)))
287
288 (define-public python-packaging-bootstrap
289 (package
290 (name "python-packaging-bootstrap")
291 (version "21.3")
292 (source
293 (origin
294 (method url-fetch)
295 (uri (pypi-uri "packaging" version))
296 (sha256
297 (base32
298 "1sygirdrqgv4f1ckh9nhpcw1yfidrh3qjl86wq8vk6nq4wlw8iyx"))))
299 (build-system python-build-system)
300 (arguments `(#:tests? #f)) ;disabled to avoid extra dependencies
301 (propagated-inputs
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
307 information.")
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
311 ;; licenses.
312 (license (list license:asl2.0 license:bsd-2))
313 (properties `((python2-variant . ,(delay python2-packaging-bootstrap))))))
314
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
320 (source
321 (origin
322 (method url-fetch)
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"))
327 (sha256
328 (base32
329 "1y2ip3a4ykkpgnwgn85j6hkspcl0cg3mzms97f40mk57vwqq67gy")))))))
330
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
334 (package
335 (name "python-pypa-build")
336 (version "0.7.0")
337 (source (origin
338 (method url-fetch)
339 (uri (pypi-uri "build" version))
340 (sha256
341 (base32
342 "17xqija27x4my1yrnk6q2vwln60r39g2dhby9zg2l99qjgbdrahs"))))
343 (build-system python-build-system)
344 (arguments
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.
349 (lambda _
350 (substitute* "setup.cfg"
351 (("tomli>=.*")
352 "toml\n")))))))
353 (propagated-inputs
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)))
364
365 (define-public python-poetry-core
366 (package
367 (name "python-poetry-core")
368 (version "1.0.7")
369 (source
370 (origin
371 (method url-fetch)
372 (uri (pypi-uri "poetry-core" version))
373 (sha256
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")
378 (description
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)))
384
385 ;;; This package exists to bootstrap python-tomli.
386 (define-public python-flit-core-bootstrap
387 (package
388 (name "python-flit-core-bootstrap")
389 (version "3.5.1")
390 (source
391 (origin
392 (method url-fetch)
393 (uri (pypi-uri "flit" version))
394 (sha256
395 (base32 "04152qj46sqbnlrj7ch9p7svjrrlpzbk0qr39g2yr0s4f5vp6frf"))))
396 (build-system python-build-system)
397 (propagated-inputs
398 (list python-toml))
399 (arguments
400 ;; flit-core has a test suite, but it requires Pytest. Disable it so
401 ;; as to not pull pytest as an input.
402 `(#:tests? #f
403 #:phases
404 (modify-phases %standard-phases
405 (replace 'build
406 ;; flit-core requires itself to build. Luckily, a
407 ;; bootstrapping script exists, which does so using just
408 ;; the checkout sources and Python.
409 (lambda _
410 (invoke "python" "flit_core/build_dists.py")))
411 (replace 'install
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)))
426
427 (define-public python-flit-core
428 (package/inherit python-flit-core-bootstrap
429 (name "python-flit-core")
430 (propagated-inputs
431 (modify-inputs (package-propagated-inputs python-flit-core-bootstrap)
432 (replace "python-toml" python-tomli)))))