gnu: Add texlive-generic-xstring.
[jackhill/guix/guix.git] / gnu / packages / python-build.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2015 Ricardo Wurmus <rekado@elephly.net>
3 ;;; Copyright © 2015, 2020 Efraim Flashner <efraim@flashner.co.il>
4 ;;; Copyright © 2016 Leo Famulari <leo@famulari.name>
5 ;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
6 ;;; Copyright © 2020 Tanguy Le Carrour <tanguy@bioneland.org>
7 ;;; Copyright © 2018, 2021, 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
8 ;;; Copyright © 2021 Tobias Geerinckx-Rice <me@tobias.gr>
9 ;;; Copyright © 2021, 2022 Ricardo Wurmus <rekado@elephly.net>
10 ;;; Copyright © 2022 Garek Dyszel <garekdyszel@disroot.org>
11 ;;;
12 ;;; This file is part of GNU Guix.
13 ;;;
14 ;;; GNU Guix is free software; you can redistribute it and/or modify it
15 ;;; under the terms of the GNU General Public License as published by
16 ;;; the Free Software Foundation; either version 3 of the License, or (at
17 ;;; your option) any later version.
18 ;;;
19 ;;; GNU Guix is distributed in the hope that it will be useful, but
20 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 ;;; GNU General Public License for more details.
23 ;;;
24 ;;; You should have received a copy of the GNU General Public License
25 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
26
27 (define-module (gnu packages python-build)
28 #:use-module (gnu packages)
29 #:use-module ((guix licenses) #:prefix license:)
30 #:use-module (guix build-system python)
31 #:use-module (guix gexp)
32 #:use-module (guix download)
33 #:use-module (guix git-download)
34 #:use-module (guix packages))
35
36 ;;; Commentary:
37 ;;;
38 ;;; Python packages to build... Python packages. Since they are bound to be
39 ;;; relied on by many, their dependencies should be kept minimal, and this
40 ;;; module should not depend on other modules containing Python packages.
41 ;;;
42 ;;; Code:
43
44 (define-public python-wheel
45 (package
46 (name "python-wheel")
47 (version "0.37.0")
48 (source
49 (origin
50 (method url-fetch)
51 (uri (pypi-uri "wheel" version))
52 (sha256
53 (base32
54 "1bbga5i49rj1cwi4sjpkvfhl1f8vl9lfky2lblsy768nk4wp5vz2"))))
55 (build-system python-build-system)
56 (arguments
57 ;; FIXME: The test suite runs "python setup.py bdist_wheel", which in turn
58 ;; fails to find the newly-built bdist_wheel library, even though it is
59 ;; available on PYTHONPATH. What search path is consulted by setup.py?
60 '(#:tests? #f))
61 (home-page "https://bitbucket.org/pypa/wheel/")
62 (synopsis "Format for built Python packages")
63 (description
64 "A wheel is a ZIP-format archive with a specially formatted filename and
65 the @code{.whl} extension. It is designed to contain all the files for a PEP
66 376 compatible install in a way that is very close to the on-disk format. Many
67 packages will be properly installed with only the @code{Unpack} step and the
68 unpacked archive preserves enough information to @code{Spread} (copy data and
69 scripts to their final locations) at any later time. Wheel files can be
70 installed with a newer @code{pip} or with wheel's own command line utility.")
71 (license license:expat)))
72
73 ;;; XXX: Not really at home, but this seems the best place to prevent circular
74 ;;; module dependencies.
75 (define-public python-toml
76 (package
77 (name "python-toml")
78 (version "0.10.2")
79 (source
80 (origin
81 (method url-fetch)
82 (uri (pypi-uri "toml" version))
83 (sha256
84 (base32 "13z6rff86bzdpl094x0vmfvls779931xj90dlbs9kpfm138s3gdk"))))
85 (build-system python-build-system)
86 (arguments
87 `(#:tests? #f)) ;no tests suite in release
88 (home-page "https://github.com/uiri/toml")
89 (synopsis "Library for TOML")
90 (description
91 "@code{toml} is a library for parsing and creating Tom's Obvious, Minimal
92 Language (TOML) configuration files.")
93 (license license:expat)))
94
95 (define-public python-tomli-w
96 (package
97 (name "python-tomli-w")
98 (version "1.0.0")
99 (source
100 (origin
101 (method url-fetch)
102 (uri (pypi-uri "tomli_w" version))
103 (sha256
104 (base32 "1fg13bfq5qy1ym4x77815nhxh1xpfs0drhn9r9464cz00m1l6qzl"))))
105 (build-system python-build-system)
106 (arguments
107 (list
108 #:tests? #f ;to avoid extra dependencies
109 #:phases
110 #~(modify-phases %standard-phases
111 ;; XXX: PEP 517 manual build copied from python-isort.
112 (replace 'build
113 (lambda _
114 (invoke "python" "-m" "build" "--wheel" "--no-isolation" ".")))
115 (replace 'install
116 (lambda _
117 (let ((whl (car (find-files "dist" "\\.whl$"))))
118 (invoke "pip" "--no-cache-dir" "--no-input"
119 "install" "--no-deps" "--prefix" #$output whl)))))))
120 (native-inputs (list python-pypa-build python-flit-core))
121 (home-page "https://github.com/hukkin/tomli-w")
122 (synopsis "Minimal TOML writer")
123 (description "Tomli-W is a Python library for writing TOML. It is a
124 write-only counterpart to Tomli, which is a read-only TOML parser.")
125 (license license:expat)))
126
127 (define-public python-pytoml
128 (package
129 (name "python-pytoml")
130 (version "0.1.21")
131 (source
132 (origin
133 (method url-fetch)
134 (uri (pypi-uri "pytoml" version))
135 (sha256
136 (base32
137 "1rv1byiw82k7mj6aprcrqi2vdabs801y97xhfnrz7kxds34ggv4f"))))
138 (build-system python-build-system)
139 (home-page "https://github.com/avakar/pytoml")
140 (synopsis "Parser for TOML")
141 (description "This package provides a Python parser for TOML-0.4.0.")
142 (license license:expat)))
143
144 (define-public python-six-bootstrap
145 (package
146 (name "python-six-bootstrap")
147 (version "1.16.0")
148 (source
149 (origin
150 (method url-fetch)
151 (uri (pypi-uri "six" version))
152 (sha256
153 (base32
154 "09n9qih9rpj95q3r4a40li7hk6swma11syvgwdc68qm1fxsc6q8y"))))
155 (build-system python-build-system)
156 (arguments `(#:tests? #f)) ;to avoid pytest dependency
157 (home-page "https://pypi.org/project/six/")
158 (synopsis "Python 2 and 3 compatibility utilities")
159 (description
160 "Six is a Python 2 and 3 compatibility library. It provides utility
161 functions for smoothing over the differences between the Python versions with
162 the goal of writing Python code that is compatible on both Python versions.
163 Six supports every Python version since 2.5. It is contained in only one
164 Python file, so it can be easily copied into your project.")
165 (license license:x11)))
166
167 (define-public python-tomli
168 (package
169 (name "python-tomli")
170 (version "2.0.0")
171 (source
172 (origin
173 (method url-fetch)
174 (uri (pypi-uri "tomli" version))
175 (sha256
176 (base32 "1q8lrh9ypa6zpgbc5f7z23p7phzblp4vpxdrpfr1wajhb17w74n2"))))
177 (build-system python-build-system)
178 (arguments
179 `(#:tests? #f ;disabled to avoid extra dependencies
180 #:phases
181 (modify-phases %standard-phases
182 (replace 'build
183 (lambda _
184 (setenv "PYTHONPATH" (string-append (getcwd) ":"
185 (getenv "GUIX_PYTHONPATH")))
186 (invoke "python" "-m" "build" "--wheel" "--no-isolation"
187 "--skip-dependency-check")))
188 (replace 'install
189 (lambda* (#:key outputs #:allow-other-keys)
190 (let ((out (assoc-ref outputs "out"))
191 (whl (car (find-files "dist" "\\.whl$"))))
192 (invoke "pip" "--no-cache-dir" "--no-input"
193 "install" "--no-deps" "--prefix" out whl)))))))
194 (native-inputs
195 `(("python-flit-core-bootstrap" ,python-flit-core-bootstrap)
196 ("python-pypa-build" ,python-pypa-build)
197 ("python-six", python-six-bootstrap)))
198 (home-page "https://github.com/hukkin/tomli")
199 (synopsis "Small and fast TOML parser")
200 (description "Tomli is a minimal TOML parser that is fully compatible with
201 @url{https://toml.io/en/v1.0.0,TOML v1.0.0}. It is about 2.4 times as fast as
202 @code{python-toml}.")
203 (license license:expat)))
204
205 (define-public python-pep517-bootstrap
206 (hidden-package
207 (package
208 (name "python-pep517-bootstrap")
209 (version "0.9.1")
210 (source
211 (origin
212 (method url-fetch)
213 (uri (pypi-uri "pep517" version))
214 (sha256
215 (base32
216 "0zqidxah03qpnp6zkg3zd1kmd5f79hhdsfmlc0cldaniy80qddxf"))))
217 (build-system python-build-system)
218 (arguments
219 `(#:tests? #f)) ;to avoid circular dependencies
220 (propagated-inputs
221 (list python-toml python-wheel))
222 (home-page "https://github.com/pypa/pep517")
223 (synopsis "Wrappers to build Python packages using PEP 517 hooks")
224 (description
225 "Wrappers to build Python packages using PEP 517 hooks.")
226 (license license:expat))))
227
228 (define-public python-pyparsing
229 (package
230 (name "python-pyparsing")
231 (version "3.0.6")
232 (source
233 (origin
234 (method url-fetch)
235 (uri (pypi-uri "pyparsing" version))
236 (sha256
237 (base32 "109b9r802wb472hgmxclljprh5cid0w3p6mk9alba7pg2c0frgfr"))))
238 (build-system python-build-system)
239 (outputs '("out" "doc"))
240 (arguments
241 `(#:tests? #f ;no test target
242 #:phases
243 (modify-phases %standard-phases
244 (add-after 'install 'install-doc
245 (lambda* (#:key outputs #:allow-other-keys)
246 (let* ((doc (string-append (assoc-ref outputs "doc")
247 "/share/doc/" ,name "-" ,version))
248 (html-doc (string-append doc "/html"))
249 (examples (string-append doc "/examples")))
250 (mkdir-p html-doc)
251 (mkdir-p examples)
252 (for-each
253 (lambda (dir tgt)
254 (map (lambda (file)
255 (install-file file tgt))
256 (find-files dir ".*")))
257 (list "docs" "htmldoc" "examples")
258 (list doc html-doc examples))))))))
259 (home-page "https://github.com/pyparsing/pyparsing")
260 (synopsis "Python parsing class library")
261 (description
262 "The pyparsing module is an alternative approach to creating and
263 executing simple grammars, vs. the traditional lex/yacc approach, or the use
264 of regular expressions. The pyparsing module provides a library of classes
265 that client code uses to construct the grammar directly in Python code.")
266 (license license:expat)))
267
268 ;;; This is the last release compatible with Python 2.
269 (define-public python-pyparsing-2.4.7
270 (package
271 (inherit python-pyparsing)
272 (version "2.4.7")
273 (source
274 (origin
275 (method url-fetch)
276 (uri (pypi-uri "pyparsing" version))
277 (sha256
278 (base32 "1hgc8qrbq1ymxbwfbjghv01fm3fbpjwpjwi0bcailxxzhf3yq0y2"))))))
279
280 (define-public python-packaging-bootstrap
281 (package
282 (name "python-packaging-bootstrap")
283 (version "21.3")
284 (source
285 (origin
286 (method url-fetch)
287 (uri (pypi-uri "packaging" version))
288 (sha256
289 (base32
290 "1sygirdrqgv4f1ckh9nhpcw1yfidrh3qjl86wq8vk6nq4wlw8iyx"))))
291 (build-system python-build-system)
292 (arguments `(#:tests? #f)) ;disabled to avoid extra dependencies
293 (propagated-inputs
294 (list python-pyparsing python-six-bootstrap))
295 (home-page "https://github.com/pypa/packaging")
296 (synopsis "Core utilities for Python packages")
297 (description "Packaging is a Python module for dealing with Python packages.
298 It offers an interface for working with package versions, names, and dependency
299 information.")
300 ;; From 'LICENSE': This software is made available under the terms of
301 ;; *either* of the licenses found in LICENSE.APACHE or LICENSE.BSD.
302 ;; Contributions to this software is made under the terms of *both* these
303 ;; licenses.
304 (license (list license:asl2.0 license:bsd-2))))
305
306 ;;; The name 'python-pypa-build' is chosen rather than 'python-build' to avoid
307 ;;; a name clash with python-build from (guix build-system python).
308 (define-public python-pypa-build
309 (package
310 (name "python-pypa-build")
311 (version "0.7.0")
312 (source (origin
313 (method url-fetch)
314 (uri (pypi-uri "build" version))
315 (sha256
316 (base32
317 "17xqija27x4my1yrnk6q2vwln60r39g2dhby9zg2l99qjgbdrahs"))))
318 (build-system python-build-system)
319 (arguments
320 `(#:tests? #f ;to tests in the PyPI release
321 #:phases (modify-phases %standard-phases
322 (add-after 'unpack 'use-toml-instead-of-tomli
323 ;; Using toml instead of tomli eases bootstrapping.
324 (lambda _
325 (substitute* "setup.cfg"
326 (("tomli>=.*")
327 "toml\n")))))))
328 (propagated-inputs
329 `(("python-packaging" ,python-packaging-bootstrap)
330 ("python-pep517", python-pep517-bootstrap)
331 ("python-toml" ,python-toml)))
332 (home-page "https://pypa-build.readthedocs.io/en/latest/")
333 (synopsis "Simple Python PEP 517 package builder")
334 (description "The @command{build} command invokes the PEP 517 hooks to
335 build a distribution package. It is a simple build tool and does not perform
336 any dependency management. It aims to keep dependencies to a minimum, in
337 order to make bootstrapping easier.")
338 (license license:expat)))
339
340 (define-public python-poetry-core
341 (package
342 (name "python-poetry-core")
343 (version "1.0.7")
344 (source
345 (origin
346 (method url-fetch)
347 (uri (pypi-uri "poetry-core" version))
348 (sha256
349 (base32 "01n2rbsvks7snrq3m1d08r3xz9q2715ajb62fdb6rvqnb9sirhcq"))))
350 (build-system python-build-system)
351 (home-page "https://github.com/python-poetry/poetry-core")
352 (synopsis "Poetry PEP 517 build back-end")
353 (description
354 "The @code{poetry-core} module provides a PEP 517 build back-end
355 implementation developed for Poetry. This project is intended to be
356 a light weight, fully compliant, self-contained package allowing PEP 517
357 compatible build front-ends to build Poetry managed projects.")
358 (license license:expat)))
359
360 ;;; This package exists to bootstrap python-tomli.
361 (define-public python-flit-core-bootstrap
362 (package
363 (name "python-flit-core-bootstrap")
364 (version "3.5.1")
365 (source
366 (origin
367 (method url-fetch)
368 (uri (pypi-uri "flit" version))
369 (sha256
370 (base32 "04152qj46sqbnlrj7ch9p7svjrrlpzbk0qr39g2yr0s4f5vp6frf"))))
371 (build-system python-build-system)
372 (propagated-inputs
373 (list python-toml))
374 (arguments
375 ;; flit-core has a test suite, but it requires Pytest. Disable it so
376 ;; as to not pull pytest as an input.
377 `(#:tests? #f
378 #:phases
379 (modify-phases %standard-phases
380 (replace 'build
381 ;; flit-core requires itself to build. Luckily, a
382 ;; bootstrapping script exists, which does so using just
383 ;; the checkout sources and Python.
384 (lambda _
385 (invoke "python" "flit_core/build_dists.py")))
386 (replace 'install
387 (lambda* (#:key inputs outputs #:allow-other-keys)
388 (let ((out (assoc-ref outputs "out"))
389 (whl (car (find-files "." "\\.whl$"))))
390 (invoke "pip" "--no-cache-dir" "--no-input"
391 "install" "--no-deps" "--prefix" out whl))))
392 ;; The sanity-check phase fails because flit depends on tomli at
393 ;; run-time, but this core variant avoids it to avoid a cycle.
394 (delete 'sanity-check))))
395 (home-page "https://github.com/takluyver/flit")
396 (synopsis "Core package of the Flit Python build system")
397 (description "This package provides @code{flit-core}, a PEP 517 build
398 backend for packages using Flit. The only public interface is the API
399 specified by PEP 517, @code{flit_core.buildapi}.")
400 (license license:bsd-3)))
401
402 (define-public python-flit-core
403 (package/inherit python-flit-core-bootstrap
404 (name "python-flit-core")
405 (propagated-inputs
406 (modify-inputs (package-propagated-inputs python-flit-core-bootstrap)
407 (replace "python-toml" python-tomli)))))
408
409 (define-public python-flit-scm
410 (package
411 (name "python-flit-scm")
412 (version "1.6.2")
413 (source (origin
414 (method url-fetch)
415 (uri (pypi-uri "flit_scm" version))
416 (sha256
417 (base32
418 "0p3lj2g1643m2dm14kihvfb6gn6jviglhm3dzdpn2c8zpqs17svg"))))
419 (build-system python-build-system)
420 (arguments
421 (list
422 #:tests? #f ;no test suite
423 #:phases
424 #~(modify-phases %standard-phases
425 (add-after 'unpack 'relax-setuptools-scm-version
426 (lambda _
427 (substitute* "pyproject.toml"
428 (("setuptools_scm~=6.4")
429 "setuptools_scm>=6.3"))))
430 ;; XXX: PEP 517 manual build/install procedures copied from
431 ;; python-isort.
432 (replace 'build
433 (lambda _
434 ;; ZIP does not support timestamps before 1980.
435 (setenv "SOURCE_DATE_EPOCH" "315532800")
436 (invoke "python" "-m" "build" "--wheel" "--no-isolation" ".")))
437 (replace 'install
438 (lambda* (#:key outputs #:allow-other-keys)
439 (let ((whl (car (find-files "dist" "\\.whl$"))))
440 (invoke "pip" "--no-cache-dir" "--no-input"
441 "install" "--no-deps" "--prefix" #$output whl)))))))
442 (native-inputs
443 (list python-pypa-build
444 python-flit-core
445 python-setuptools-scm
446 python-tomli))
447 (propagated-inputs
448 (list python-flit-core
449 python-setuptools-scm
450 python-tomli))
451 (home-page "https://gitlab.com/WillDaSilva/flit_scm")
452 (synopsis "PEP 518 build backend combining flit_core and setuptools_scm")
453 (description "This package provides a PEP 518 build backend that uses
454 @code{setuptools_scm} to generate a version file from your version control
455 system, then @code{flit_core} to build the package.")
456 (license license:expat)))
457
458 (define-public python-setuptools-scm
459 (package
460 (name "python-setuptools-scm")
461 (version "6.3.2")
462 (source (origin
463 (method url-fetch)
464 (uri (pypi-uri "setuptools_scm" version))
465 (sha256
466 (base32 "1wm0i27siyy1yqr9rv7lqvb65agay9051yi8jzmi8dgb3q4ai6m4"))))
467 (build-system python-build-system)
468 (propagated-inputs
469 `(("python-packaging",python-packaging-bootstrap)
470 ("python-tomli" ,python-tomli)))
471 (home-page "https://github.com/pypa/setuptools_scm/")
472 (synopsis "Manage Python package versions in SCM metadata")
473 (description
474 "Setuptools_scm handles managing your Python package versions in
475 @dfn{software configuration management} (SCM) metadata instead of declaring
476 them as the version argument or in a SCM managed file.")
477 (license license:expat)))
478
479 (define-public python-editables
480 (package
481 (name "python-editables")
482 (version "0.3")
483 (source (origin
484 (method git-fetch)
485 (uri (git-reference
486 (url "https://github.com/pfmoore/editables")
487 (commit version)))
488 (file-name (git-file-name name version))
489 (sha256
490 (base32
491 "1gbfkgzmrmbd4ycshm09fr2wd4f1n9gq7s567jgkavhfkn7s2pn1"))))
492 (build-system python-build-system)
493 (home-page "https://github.com/pfmoore/editables")
494 (synopsis "Editable installations")
495 (description "This library supports the building of wheels which, when
496 installed, will expose packages in a local directory on @code{sys.path} in
497 ``editable mode''. In other words, changes to the package source will be
498 reflected in the package visible to Python, without needing a reinstall.")
499 (license license:expat)))