gnu: python-cffi: Improve package style.

* gnu/packages/libffi.scm: Add python-build and pyproject
modules. Select just pypi-uri symbol from python module.
(python-cffi): Fix indenation and adjust order of fileds.
[build-system]: Swap to pyproject-build-system.
[arguments]<test-flags>: Move tests directories and deselcect options
here.
<phases>: Use default 'check phase. Add 'set-gcc phase.
[native-inputs]: Add python-setuptools and python-wheel.

Change-Id: I0baa120ac86ef1c1e90cf44a4d439d874b8920b5
This commit is contained in:
Sharlatan Hellseher 2024-11-10 20:40:32 +00:00
parent 45b51c7ed7
commit 5c3e101ef4
No known key found for this signature in database
GPG key ID: 76D727BFF62CD2B5

View file

@ -9,6 +9,7 @@
;;; Copyright © 2019, 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2020 John Doe <dftxbs3e@free.fr>
;;; Copyright © 2024 Janneke Nieuwenhuizen <janneke@gnu.org>
;;; Copyright © 2024 Sharlatan Hellseher <sharlatanus@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@ -36,11 +37,13 @@
#:use-module (gnu packages check)
#:use-module (gnu packages pkg-config)
#:use-module (gnu packages python)
#:use-module (gnu packages python-build)
#:use-module (gnu packages python-xyz)
#:use-module (gnu packages ruby)
#:use-module (gnu packages sphinx)
#:use-module (guix build-system gnu)
#:use-module (guix build-system python)
#:use-module (guix build-system pyproject)
#:use-module ((guix build-system python) #:select (pypi-uri))
#:use-module (guix build-system ruby))
(define-public libffi
@ -107,17 +110,19 @@ conversions for values passed between the two languages.")
(uri (pypi-uri "cffi" version))
(sha256
(base32 "0918qn4yfjfgcy7i4imfy9q1cvl3svmm06anakflig1jdh0wcf8w"))))
(build-system python-build-system)
(inputs
(list libffi))
(propagated-inputs ; required at run-time
(list python-pycparser))
(native-inputs
(list pkg-config python-pytest))
(build-system pyproject-build-system)
(arguments
`(#:phases
(modify-phases %standard-phases
(replace 'check
(list
#:test-flags
#~(list "src/c/" "testing/"
;; Disable tests that fail (harmlessly) with glibc 2.34 and
;; later, see
;; <https://foss.heptapod.net/pypy/cffi/-/issues/528>.
"--deselect=testing/cffi0/test_ffi_backend.py::TestFFI::test_dlopen_handle"
"--deselect=testing/cffi1/test_re_python.py::test_dlopen_handle")
#:phases
#~(modify-phases %standard-phases
(add-after 'unpack 'set-gcc
(lambda _
;; XXX The "normal" approach of setting CC and friends does
;; not work here. Is this the correct way of doing things?
@ -128,13 +133,7 @@ conversions for values passed between the two languages.")
"compiler_so='gcc',linker_exe='gcc',"
"linker_so='gcc -shared')")))
(substitute* "testing/cffi0/test_ownlib.py"
(("\"cc testownlib") "\"gcc testownlib"))
(invoke "pytest" "-v" "src/c/" "testing/"
;; Disable tests that fail (harmlessly) with glibc
;; 2.34 and later:
;; https://foss.heptapod.net/pypy/cffi/-/issues/528
"-k" (string-append "not TestFFI.test_dlopen_handle "
"and not test_dlopen_handle"))))
(("\"cc testownlib") "\"gcc testownlib"))))
(add-before 'check 'patch-paths-of-dynamically-loaded-libraries
(lambda* (#:key inputs #:allow-other-keys)
;; Shared libraries should be referred by their absolute path as
@ -157,6 +156,15 @@ conversions for values passed between the two languages.")
(substitute* "src/c/test_c.py"
(("find_and_load_library\\(['\"]{1}c['\"]{1}")
(format #f "find_and_load_library('~a'" libc)))))))))
(native-inputs
(list pkg-config
python-pytest
python-setuptools
python-wheel))
(inputs
(list libffi))
(propagated-inputs ; required at run-time
(list python-pycparser))
(home-page "https://cffi.readthedocs.io/")
(synopsis "Foreign function interface for Python")
(description "Foreign Function Interface for Python calling C code.")