[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
316/361: gnu: python-cffi: Improve package style.
From: |
guix-commits |
Subject: |
316/361: gnu: python-cffi: Improve package style. |
Date: |
Thu, 21 Nov 2024 06:29:42 -0500 (EST) |
sharlatan pushed a commit to branch python-team
in repository guix.
commit 041410811f2049ac359e6353b79d334e3f00d4a0
Author: Sharlatan Hellseher <sharlatanus@gmail.com>
AuthorDate: Sun Nov 10 20:40:32 2024 +0000
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
---
gnu/packages/libffi.scm | 110 ++++++++++++++++++++++++++----------------------
1 file changed, 59 insertions(+), 51 deletions(-)
diff --git a/gnu/packages/libffi.scm b/gnu/packages/libffi.scm
index 87e7f83e20..dd439eac56 100644
--- a/gnu/packages/libffi.scm
+++ b/gnu/packages/libffi.scm
@@ -8,6 +8,7 @@
;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2019, 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2020 John Doe <dftxbs3e@free.fr>
+;;; Copyright © 2024 Sharlatan Hellseher <sharlatanus@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -35,11 +36,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
@@ -97,60 +100,65 @@ conversions for values passed between the two languages.")
(version "1.17.1")
(source
(origin
- (method url-fetch)
- (uri (pypi-uri "cffi" version))
- (sha256
- (base32 "0918qn4yfjfgcy7i4imfy9q1cvl3svmm06anakflig1jdh0wcf8w"))))
- (build-system python-build-system)
+ (method url-fetch)
+ (uri (pypi-uri "cffi" version))
+ (sha256
+ (base32 "0918qn4yfjfgcy7i4imfy9q1cvl3svmm06anakflig1jdh0wcf8w"))))
+ (build-system pyproject-build-system)
+ (arguments
+ (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?
+ (substitute* "testing/embedding/test_basic.py"
+ (("c = distutils\\.ccompiler\\.new_compiler\\(\\)")
+ (string-append "c = distutils.ccompiler.new_compiler();"
+ "c.set_executables(compiler='gcc',"
+ "compiler_so='gcc',linker_exe='gcc',"
+ "linker_so='gcc -shared')")))
+ (substitute* "testing/cffi0/test_ownlib.py"
+ (("\"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
+ ;; using find_library or the like with their name fail when the
+ ;; resolved .so object is a linker script rather than an ELF
+ ;; binary (this is a limitation of the ctype library of Python).
+ (let ((libm (search-input-file inputs "lib/libm.so.6"))
+ (libc (search-input-file inputs "lib/libc.so.6")))
+ (substitute* '("testing/cffi0/test_function.py"
+ "testing/cffi0/test_parsing.py"
+ "testing/cffi0/test_unicode_literals.py"
+ "testing/cffi0/test_zdistutils.py"
+ "testing/cffi1/test_recompiler.py")
+ (("lib_m = ['\"]{1}m['\"]{1}")
+ (format #f "lib_m = '~a'" libm)))
+ (substitute* '("testing/cffi0/test_verify.py"
+ "testing/cffi1/test_verify1.py")
+ (("lib_m = \\[['\"]{1}m['\"]{1}\\]")
+ (format #f "lib_m = ['~a']" libm)))
+ (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))
- (native-inputs
- (list pkg-config python-pytest))
- (arguments
- `(#:phases
- (modify-phases %standard-phases
- (replace 'check
- (lambda _
- ;; XXX The "normal" approach of setting CC and friends does
- ;; not work here. Is this the correct way of doing things?
- (substitute* "testing/embedding/test_basic.py"
- (("c = distutils\\.ccompiler\\.new_compiler\\(\\)")
- (string-append "c = distutils.ccompiler.new_compiler();"
- "c.set_executables(compiler='gcc',"
- "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"))))
- (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
- ;; using find_library or the like with their name fail when the
- ;; resolved .so object is a linker script rather than an ELF
- ;; binary (this is a limitation of the ctype library of Python).
- (let ((libm (search-input-file inputs "lib/libm.so.6"))
- (libc (search-input-file inputs "lib/libc.so.6")))
- (substitute* '("testing/cffi0/test_function.py"
- "testing/cffi0/test_parsing.py"
- "testing/cffi0/test_unicode_literals.py"
- "testing/cffi0/test_zdistutils.py"
- "testing/cffi1/test_recompiler.py")
- (("lib_m = ['\"]{1}m['\"]{1}")
- (format #f "lib_m = '~a'" libm)))
- (substitute* '("testing/cffi0/test_verify.py"
- "testing/cffi1/test_verify1.py")
- (("lib_m = \\[['\"]{1}m['\"]{1}\\]")
- (format #f "lib_m = ['~a']" libm)))
- (substitute* "src/c/test_c.py"
- (("find_and_load_library\\(['\"]{1}c['\"]{1}")
- (format #f "find_and_load_library('~a'" libc)))))))))
(home-page "https://cffi.readthedocs.io/")
(synopsis "Foreign function interface for Python")
(description "Foreign Function Interface for Python calling C code.")
- 245/361: gnu: nikola: Fix build., (continued)
- 245/361: gnu: nikola: Fix build., guix-commits, 2024/11/21
- 257/361: gnu: python-defusedxml: Update to 0.7.1., guix-commits, 2024/11/21
- 260/361: gnu: ytcc: Fix build., guix-commits, 2024/11/21
- 249/361: gnu: python-cucumber-tag-expressions: Update to 6.1.1., guix-commits, 2024/11/21
- 267/361: gnu: python-unyt: Adjust inputs., guix-commits, 2024/11/21
- 264/361: gnu: hangups: Fix build., guix-commits, 2024/11/21
- 298/361: gnu: python-exceptiongroup: Move to python-build., guix-commits, 2024/11/21
- 274/361: gnu: python-cplot: Adjust inputs., guix-commits, 2024/11/21
- 301/361: gnu: Remove python-pytest-next., guix-commits, 2024/11/21
- 324/361: gnu: python-tomli: Update to 2.1.0., guix-commits, 2024/11/21
- 316/361: gnu: python-cffi: Improve package style.,
guix-commits <=
- 306/361: gnu: python-pytest-timeout: Update to 2.3.1., guix-commits, 2024/11/21
- 307/361: gnu: python-pytest-forked: Disable tests., guix-commits, 2024/11/21
- 326/361: gnu: python-packaging-bootstrap: Update to 24.2., guix-commits, 2024/11/21
- 333/361: gnu: python-mypy: Update to 1.13.0., guix-commits, 2024/11/21
- 329/361: gnu: python-cython-3: Update to 3.0.11., guix-commits, 2024/11/21
- 332/361: gnu: python-jsonschema: Update to 4.23.0., guix-commits, 2024/11/21
- 349/361: gnu: python-flask: Update to 3.1.0., guix-commits, 2024/11/21
- 214/361: gnu: python-certauth: Move to pyproject-build-system., guix-commits, 2024/11/21
- 236/361: gnu: python-lightning-utilities: Adjust inputs., guix-commits, 2024/11/21
- 266/361: gnu: python-nose-exclude: Adjust iputs., guix-commits, 2024/11/21