Commit graph

13 commits

Author SHA1 Message Date
Nicolas Graves
2d45de1bc4
build-system/pyproject: Handle wheel not found exception.
The current error is very uninformative, use a proper exception to
give more information when this happens:
`In procedure map: Wrong type argument: #f`

After this patch:
`In procedure raise-exception:
ERROR:
  1. &no-wheels-found`

* guix/build/pyproject-build-system.scm (&no-wheels-found): Add exception.
(install): Handle exception.

Change-Id: Ie72d3b50dfededb2d598162672cdb4321c42b632
Signed-off-by: Sharlatan Hellseher <sharlatanus@gmail.com>
2025-09-25 09:35:34 +01:00
Nicolas Graves
977caf32ef
build-system/pyproject: Avoid PEP427 substitution on binary files.
In some rare cases, the dest-path can be an elf-file, which are
unreadable by substitute*, leading to an error instead of just
continuing which makes more sense in this case.

* guix/build-system/pyproject.scm (check): Guard substitution attempt
with basic readability guarantees.

Signed-off-by: Sharlatan Hellseher <sharlatanus@gmail.com>
2025-09-25 09:35:34 +01:00
Nicolas Graves
9a40c5145d
build-system/pyproject: Add stestr, unittest and custom options.
* guix/build-system/pyproject.scm (check): Add stestr, unittest and
custom test-backends.

Change-Id: I2d44b3b8dd928ab844b4479fb073afff845e13ee
Signed-off-by: Sharlatan Hellseher <sharlatanus@gmail.com>
2025-09-25 09:35:34 +01:00
Nicolas Graves
74a1e9d543
build-system/pyproject: Use copy-recursively instead of merge-dirs.
Using rename-file, the destination had to be empty otherwise it would error
out.  This has been fixed by the use of copy-recursively, really merging them.
Changing this makes merge-directories mostly a duplicate of
copy-recursively, thus fully switch to copy-recursively.

* guix/build/pyproject-build-system.scm (install)
<python-hashbang>: Remove it, used only once.
<merge-directories>: Remove it, replace its calls by copy-recursively
and delete-file-recursively.

Signed-off-by: Sharlatan Hellseher <sharlatanus@gmail.com>
2025-09-25 09:35:34 +01:00
Nicolas Graves
e927a071cd
build-system/pyproject: Add python test-backend.
* guix/build/pyproject-build-system(check): Add python test-backend.

This will help in cases where a simple `python -m module args` call has
to be made instead of fully replacing the 'check phase, e.g. unittest
or django. This is never enabled unless #:test-backend 'python is set,
so it doesn't break anything.

As an example, the following snippet...

(arguments
  (list #:phases #~(modify-phases %standard-phases
                     (replace 'check
                       (lambda* (#:key tests? #:allow-other-keys)
                         (when tests?
                           (invoke "python" "-m" "unittest"
                                   "diff_match_patch.tests")))))))

...can be transformed like this:

(arguments
  '(#:test-backend 'python
    #:test-flags (list "-m" "unittest" "diff_match_patch.tests")))

Change-Id: I4919a3e01d64864e3c328609fbcce7df5b3dfe51
Signed-off-by: Sharlatan Hellseher <sharlatanus@gmail.com>
2025-09-25 09:35:33 +01:00
Maxim Cournoyer
7b65bc85cd
build/pyproject: Fix indentation.
* guix/build/pyproject-build-system.scm: Re-indent file with Emacs.

Change-Id: Ie8a119ce9cf4beccffde93674adb98dc07462ea7
Signed-off-by: Sharlatan Hellseher <sharlatanus@gmail.com>
2025-09-25 09:35:33 +01:00
Maxim Cournoyer
f3f42af8ae
build/pyproject: Resolve import warning.
* guix/build/pyproject-build-system.scm: Hide the 'delete' symbol from
the imported (guix build utils) module to avoid a naming clash warning.

Change-Id: I48f97bf29b5282de1440c68d533c8300d4d11362
Signed-off-by: Sharlatan Hellseher <sharlatanus@gmail.com>
2025-09-25 09:35:33 +01:00
Maxim Cournoyer
1d0493e58d
build/pyproject: Update PEP 427 reference URL in comment.
* guix/build/pyproject-build-system.scm (install): Update reference URL.

Change-Id: Icf5dcc7254c33e8e466773ee66a2fd5648d583da
Signed-off-by: Sharlatan Hellseher <sharlatanus@gmail.com>
2025-09-25 09:35:33 +01:00
Maxim Cournoyer
beb6357463
build/pyproject: Really merge directories in install phase.
Using rename-file, the destination had to be empty otherwise it would
error out.  By using copy-recursively, a directory can be copied onto a
pre-existing directory, really merging them.  This problem manifested
itself attempting to build the python-pyre package.

Solving #596.

* guix/build/pyproject-build-system.scm (install)
<merge-directories>: Use copy-recursively instead of rename-file.

Change-Id: Iceb8609a86f29b17e5fbe6a9629339d0bc26e11f
Signed-off-by: Sharlatan Hellseher <sharlatanus@gmail.com>
2025-09-25 09:35:33 +01:00
Lars-Dominik Braun
efbce9a69a
build-system/pyproject: Use TOML parser.
More reliable than regular expressions.

* guix/build-system/pyproject.scm (%pyproject-build-system-modules): Add (guix build toml).
(pyproject-build): Add argument #:backend-path.
* guix/build/pyproject-build-system.scm (build): Add support for
auto-detected and override backend-path.
* gnu/packages/python-build.scm (python-tomli)[arguments]: Remove
'add-self-to-path, because it is not necessary any more.
(python-poetry-core): Same.
(python-hatchling): Same.
(python-pdm-backend): Same.
2024-12-13 20:15:42 +00:00
Marius Bakke
e944734ef9
build-system/pyproject: Always run tests verbosely for supported backends.
* guix/build-system/pyproject.scm (pyproject-build): Default to '() instead of
 #false for TEST-FLAGS.
* guix/build/pyproject-build-system.scm (check): Unconditionally enable
verbose test flags.
* doc/guix.texi (Build Systems): Document this change.
* gnu/packages/fontutils.scm (python-glyphslib)[arguments]: Remove verbosity
from #:test-flags.
* gnu/packages/pdf.scm (python-pydyf, weasyprint)[arguments]: Likewise.
* gnu/packages/python-web.scm (python-openapi-spec-validator)[arguments]: Likewise.
* gnu/packages/python-xyz.scm (python-path, python-tempora)[arguments]: Likewise.
2022-10-27 21:30:03 +02:00
Marius Bakke
6ef998d54e
build-system/pyproject: Adjust indentation.
* guix/build/pyproject-build-system.scm: Adjust indentation.
2022-10-27 21:30:03 +02:00
Lars-Dominik Braun
400a7a4c80
build-system: Add pyproject-build-system.
This is an experimental build system based on python-build-system
that implements PEP 517-compliant builds.

* doc/guix.texi (Build Systems): Add pyproject-build-system section.
* doc/contributing.texi (Python Modules): Mention pyproject.toml and the
PYTHON-TOOLCHAIN package, as well as differences to python-build-system.
* guix/build-system/pyproject.scm,
guix/build/pyproject-build-system.scm,
gnu/packages/aux-files/python/sanity-check-next.py,
gnu/packages/python-commencement.scm: New files.
* Makefile.am (MODULES): Register the new build systems.
* gnu/local.mk (GNU_SYSTEM_MODULES): Add python-commencement.scm.
* gnu/packages/python.scm (python-sans-pip, python-sans-pip-wrapper): New
variables.

Co-authored-by: Marius Bakke <marius@gnu.org>
2022-10-27 19:43:06 +02:00