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>
12 ;;; This file is part of GNU Guix.
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.
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.
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/>.
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))
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.
44 (define-public python-wheel
51 (uri (pypi-uri "wheel" version))
54 "1bbga5i49rj1cwi4sjpkvfhl1f8vl9lfky2lblsy768nk4wp5vz2"))))
55 (build-system python-build-system)
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?
61 (home-page "https://bitbucket.org/pypa/wheel/")
62 (synopsis "Format for built Python packages")
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)))
73 ;;; XXX: Not really at home, but this seems the best place to prevent circular
74 ;;; module dependencies.
75 (define-public python-toml
82 (uri (pypi-uri "toml" version))
84 (base32 "13z6rff86bzdpl094x0vmfvls779931xj90dlbs9kpfm138s3gdk"))))
85 (build-system python-build-system)
87 `(#:tests? #f)) ;no tests suite in release
88 (home-page "https://github.com/uiri/toml")
89 (synopsis "Library for TOML")
91 "@code{toml} is a library for parsing and creating Tom's Obvious, Minimal
92 Language (TOML) configuration files.")
93 (license license:expat)))
95 (define-public python-tomli-w
97 (name "python-tomli-w")
102 (uri (pypi-uri "tomli_w" version))
104 (base32 "1fg13bfq5qy1ym4x77815nhxh1xpfs0drhn9r9464cz00m1l6qzl"))))
105 (build-system python-build-system)
108 #:tests? #f ;to avoid extra dependencies
110 #~(modify-phases %standard-phases
111 ;; XXX: PEP 517 manual build copied from python-isort.
114 (invoke "python" "-m" "build" "--wheel" "--no-isolation" ".")))
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)))
127 (define-public python-pytoml
129 (name "python-pytoml")
134 (uri (pypi-uri "pytoml" version))
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)))
144 (define-public python-six-bootstrap
146 (name "python-six-bootstrap")
151 (uri (pypi-uri "six" version))
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")
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)))
167 (define-public python-tomli
169 (name "python-tomli")
174 (uri (pypi-uri "tomli" version))
176 (base32 "1q8lrh9ypa6zpgbc5f7z23p7phzblp4vpxdrpfr1wajhb17w74n2"))))
177 (build-system python-build-system)
179 `(#:tests? #f ;disabled to avoid extra dependencies
181 (modify-phases %standard-phases
184 (setenv "PYTHONPATH" (string-append (getcwd) ":"
185 (getenv "GUIX_PYTHONPATH")))
186 (invoke "python" "-m" "build" "--wheel" "--no-isolation"
187 "--skip-dependency-check")))
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)))))))
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)))
205 (define-public python-pep517-bootstrap
208 (name "python-pep517-bootstrap")
213 (uri (pypi-uri "pep517" version))
216 "0zqidxah03qpnp6zkg3zd1kmd5f79hhdsfmlc0cldaniy80qddxf"))))
217 (build-system python-build-system)
219 `(#:tests? #f)) ;to avoid circular dependencies
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")
225 "Wrappers to build Python packages using PEP 517 hooks.")
226 (license license:expat))))
228 (define-public python-pyparsing
230 (name "python-pyparsing")
235 (uri (pypi-uri "pyparsing" version))
237 (base32 "109b9r802wb472hgmxclljprh5cid0w3p6mk9alba7pg2c0frgfr"))))
238 (build-system python-build-system)
239 (outputs '("out" "doc"))
241 `(#:tests? #f ;no test target
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")))
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")
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)))
268 ;;; This is the last release compatible with Python 2.
269 (define-public python-pyparsing-2.4.7
271 (inherit python-pyparsing)
276 (uri (pypi-uri "pyparsing" version))
278 (base32 "1hgc8qrbq1ymxbwfbjghv01fm3fbpjwpjwi0bcailxxzhf3yq0y2"))))))
280 (define-public python-packaging-bootstrap
282 (name "python-packaging-bootstrap")
287 (uri (pypi-uri "packaging" version))
290 "1sygirdrqgv4f1ckh9nhpcw1yfidrh3qjl86wq8vk6nq4wlw8iyx"))))
291 (build-system python-build-system)
292 (arguments `(#:tests? #f)) ;disabled to avoid extra dependencies
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
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
304 (license (list license:asl2.0 license:bsd-2))))
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
310 (name "python-pypa-build")
314 (uri (pypi-uri "build" version))
317 "17xqija27x4my1yrnk6q2vwln60r39g2dhby9zg2l99qjgbdrahs"))))
318 (build-system python-build-system)
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.
325 (substitute* "setup.cfg"
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)))
340 (define-public python-poetry-core
342 (name "python-poetry-core")
347 (uri (pypi-uri "poetry-core" version))
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")
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)))
360 ;;; This package exists to bootstrap python-tomli.
361 (define-public python-flit-core-bootstrap
363 (name "python-flit-core-bootstrap")
368 (uri (pypi-uri "flit" version))
370 (base32 "04152qj46sqbnlrj7ch9p7svjrrlpzbk0qr39g2yr0s4f5vp6frf"))))
371 (build-system python-build-system)
375 ;; flit-core has a test suite, but it requires Pytest. Disable it so
376 ;; as to not pull pytest as an input.
379 (modify-phases %standard-phases
381 ;; flit-core requires itself to build. Luckily, a
382 ;; bootstrapping script exists, which does so using just
383 ;; the checkout sources and Python.
385 (invoke "python" "flit_core/build_dists.py")))
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)))
402 (define-public python-flit-core
403 (package/inherit python-flit-core-bootstrap
404 (name "python-flit-core")
406 (modify-inputs (package-propagated-inputs python-flit-core-bootstrap)
407 (replace "python-toml" python-tomli)))))
409 (define-public python-flit-scm
411 (name "python-flit-scm")
415 (uri (pypi-uri "flit_scm" version))
418 "0p3lj2g1643m2dm14kihvfb6gn6jviglhm3dzdpn2c8zpqs17svg"))))
419 (build-system python-build-system)
422 #:tests? #f ;no test suite
424 #~(modify-phases %standard-phases
425 (add-after 'unpack 'relax-setuptools-scm-version
427 (substitute* "pyproject.toml"
428 (("setuptools_scm~=6.4")
429 "setuptools_scm>=6.3"))))
430 ;; XXX: PEP 517 manual build/install procedures copied from
434 ;; ZIP does not support timestamps before 1980.
435 (setenv "SOURCE_DATE_EPOCH" "315532800")
436 (invoke "python" "-m" "build" "--wheel" "--no-isolation" ".")))
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)))))))
443 (list python-pypa-build
445 python-setuptools-scm
448 (list python-flit-core
449 python-setuptools-scm
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)))
458 (define-public python-setuptools-scm
460 (name "python-setuptools-scm")
464 (uri (pypi-uri "setuptools_scm" version))
466 (base32 "1wm0i27siyy1yqr9rv7lqvb65agay9051yi8jzmi8dgb3q4ai6m4"))))
467 (build-system python-build-system)
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")
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)))
479 (define-public python-editables
481 (name "python-editables")
486 (url "https://github.com/pfmoore/editables")
488 (file-name (git-file-name name version))
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)))