summaryrefslogtreecommitdiff
path: root/gnu/packages/pypy.scm
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/packages/pypy.scm')
-rw-r--r--gnu/packages/pypy.scm215
1 files changed, 168 insertions, 47 deletions
diff --git a/gnu/packages/pypy.scm b/gnu/packages/pypy.scm
index 90986ac096..5309cf38f1 100644
--- a/gnu/packages/pypy.scm
+++ b/gnu/packages/pypy.scm
@@ -1,8 +1,9 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2021 Lars-Dominik Braun <lars@6xq.net>
;;; Copyright © 2021 Ludovic Courtès <ludo@gnu.org>
-;;; Copyright © 2021, 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2021, 2022, 2025 Maxim Cournoyer <maxim@guixotic.coop>
;;; Copyright © 2021 Leo Famulari <leo@famulari.name>
+;;; Copyright © 2025 Laura Kirsch <laurakirsch240406@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -22,7 +23,7 @@
(define-module (gnu packages pypy)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (gnu packages base)
- #:use-module (gnu packages certs)
+ #:use-module (gnu packages nss)
#:use-module (gnu packages compression)
#:use-module (gnu packages dbm)
#:use-module (gnu packages libffi)
@@ -37,31 +38,36 @@
#:use-module (guix gexp)
#:use-module (guix packages)
#:use-module (guix download)
+ #:use-module (guix utils)
#:use-module (guix build-system gnu))
-(define-public pypy
+;;; This Python 2 alternative implementation is useful for allowing faster
+;;; iterations on the development of Pypy 3.
+(define-public pypy2
(package
- (name "pypy")
- (version "7.3.17")
+ (name "pypy2")
+ (version "7.3.20")
(source (origin
(method url-fetch)
(uri (string-append "https://downloads.python.org/pypy/"
- "pypy3.10-v" version "-src.tar.bz2"))
+ "pypy2.7-v" version "-src.tar.bz2"))
(sha256
(base32
- "1xsbn9mbxi2kai4gg1nz6n6cbqsq60qh65f5l6ld7ip9g32lpmva"))))
+ "0qiyd9bajxyzh4j5swk14iwyh4b7pn38sg3j721zfysz8jc895dz"))))
(build-system gnu-build-system)
(arguments
(list
- #:tests? #f ;FIXME: 43 out of 364 tests are failing
-
+ #:modules '((ice-9 ftw) (ice-9 match)
+ (guix build utils) (guix build gnu-build-system))
+ ;; The stdlib tests do not all pass, this is known and tracked upstream
+ ;; on their buildbot instance, for example at:
+ ;; <https://buildbot.pypy.org/summary?branch=py3.11>. That's also true
+ ;; for Pypy 3. The tests are also disabled to avoid having to package
+ ;; extra Python 2 dependencies like python2-hypothesis.
+ #:tests? #f
;; XXX: ELF file 'pypy.debug' makes 'validate-needed-in-runpath' throw:
;; <https://issues.guix.gnu.org/57653>.
#:validate-runpath? #f
-
- #:modules '((ice-9 ftw) (ice-9 match)
- (guix build utils) (guix build gnu-build-system))
- #:disallowed-references (list nss-certs)
#:phases
#~(modify-phases %standard-phases
(delete 'configure)
@@ -89,7 +95,7 @@
;; Find curses
(("/usr/local")
#$(this-package-input "ncurses")))
- (substitute* '("lib_pypy/_dbm.py")
+ (substitute* '("lib_pypy/dbm.py")
;; Use gdbm compat library, so we don’t need to pull
;; in bdb.
(("ctypes.util.find_library\\('db'\\)")
@@ -103,13 +109,21 @@
(("libname = 'sqlite3'")
(format #f "libname = ~s"
(search-input-file inputs "lib/libsqlite3.so.0"))))
- (substitute* '("lib-python/3/subprocess.py")
+ (substitute* '("lib-python/2.7/subprocess.py")
;; Fix shell path
(("/bin/sh")
(search-input-file inputs "/bin/sh")))
- (substitute* '("lib-python/3/distutils/unixccompiler.py")
+ (substitute* '("lib-python/2.7/distutils/unixccompiler.py")
;; gcc-toolchain does not provide symlink cc -> gcc
- (("\"cc\"") "\"gcc\""))))
+ (("\"cc\"") (format #f "~s" #$(cc-for-target))))
+ (substitute* "lib-python/2.7/distutils/sysconfig_pypy.py"
+ (("\"cc ")
+ (string-append "\"" #$(cc-for-target) " ")))))
+ (add-after 'unpack 'use-libffi.so
+ (lambda _
+ (substitute* "rpython/rlib/clibffi.py"
+ (("\"libffi\\.a\"")
+ "\"libffi.so\""))))
(add-after 'unpack 'set-source-file-times-to-1980
;; copied from python package, required by zip testcase
(lambda _
@@ -119,10 +133,12 @@
#t)))))
(replace 'build
(lambda _
+ (setenv "CC" #$(cc-for-target))
(with-directory-excursion "pypy/goal"
;; Build with jit optimization.
(invoke "python2"
"../../rpython/bin/rpython"
+ (string-append "--cc=" #$(cc-for-target))
(string-append "--make-jobs="
(number->string (parallel-job-count)))
"-Ojit"
@@ -133,66 +149,45 @@
(invoke "python2" "package.py"
"--archive-name" "pypy-dist"
"--builddir" (getcwd)))))
- (replace 'check
- (lambda* (#:key tests? #:allow-other-keys)
- (if tests?
- (begin
- (setenv "HOME" "/tmp") ; test_with_pip tries to
- ; access ~/.cache/pip
- ;; Run library tests only (no interpreter unit tests).
- ;; This is what Gentoo does.
- (invoke "python" "pypy/test_all.py"
- "--pypy=pypy/tool/release/pypy-dist/bin/pypy3"
- "lib-python"))
- (format #t "test suite not run~%"))))
(replace 'install
(lambda* (#:key inputs outputs #:allow-other-keys)
- (let* ((bin-pypy3 (string-append #$output "/bin/pypy3"))
+ (let* ((bin-pypy2 (string-append #$output "/bin/pypy2"))
(shebang-match-python "#!.+/bin/python")
- (shebang-pypy3 (string-append "#!" bin-pypy3))
+ (shebang-pypy2 (string-append "#!" bin-pypy2))
(dist-dir "pypy/tool/release/pypy-dist"))
(with-directory-excursion dist-dir
;; Delete test data.
(for-each
(lambda (x)
(delete-file-recursively (string-append
- "lib/pypy3.10/" x)))
- '("tkinter/test"
+ "lib-python/2.7/" x)))
+ '("lib-tk/test"
"test"
- "sqlite3/test"
"lib2to3/tests"
"idlelib/idle_test"
"distutils/tests"
"ctypes/test"
"unittest/test"))
;; Patch shebang referencing python.
- (substitute* '("lib/pypy3.10/cgi.py"
- "lib/pypy3.10/encodings/rot_13.py")
- ((shebang-match-python) shebang-pypy3))
- (with-fluids ((%default-port-encoding "ISO-8859-1"))
- (substitute* '("lib/pypy3.10/_md5.py"
- "lib/pypy3.10/_sha1.py")
- ((shebang-match-python) shebang-pypy3))))
+ (substitute* '("lib-python/2.7/cgi.py"
+ "lib-python/2.7/encodings/rot_13.py")
+ ((shebang-match-python) shebang-pypy2)))
(copy-recursively dist-dir #$output)))))))
(native-inputs
- (list gzip
- nss-certs ; For ssl tests
+ (list nss-certs ; For ssl tests
pkg-config
python-2
- python2-pycparser
- tar)) ; Required for package.py
+ python2-cffi))
(inputs
(list bzip2
expat
gdbm
- glibc
libffi
ncurses
openssl
sqlite
tcl
tk
- xz
zlib))
(home-page "https://www.pypy.org/")
(synopsis "Python implementation with just-in-time compilation")
@@ -207,5 +202,131 @@ Python code natively, including C extensions.")
(license:non-copyleft
"http://www.unicode.org/copyright.html")))))
+(define-public pypy
+ (package
+ (inherit pypy2)
+ (name "pypy")
+ (version "7.3.20")
+ (source (origin
+ (method url-fetch)
+ (uri (string-append "https://downloads.python.org/pypy/"
+ "pypy3.11-v" version "-src.tar.bz2"))
+ (sha256
+ (base32
+ "1yq6n888fxfdqid29q3w8bn7ii800bjkf44w82kjwgh0c2kxv1kp"))))
+ (arguments
+ (substitute-keyword-arguments (package-arguments pypy2)
+ ((#:phases phases)
+ #~(modify-phases #$phases
+ (replace 'patch-source
+ ;; Overridden from pypy2 because some file names have changed.
+ (lambda* (#:key inputs #:allow-other-keys)
+ (substitute* '("rpython/rlib/clibffi.py")
+ ;; find_library does not work for libc
+ (("ctypes\\.util\\.find_library\\('c'\\)") "'libc.so'"))
+ (substitute* '("lib_pypy/cffi/_pycparser/ply/cpp.py")
+ ;; Make reproducible (XXX: unused?)
+ (("time\\.localtime\\(\\)") "time.gmtime(0)"))
+ (substitute* '("pypy/module/sys/version.py")
+ ;; Make reproducible
+ (("t\\.gmtime\\(\\)") "t.gmtime(0)"))
+ (substitute* '("lib_pypy/_tkinter/tklib_build.py")
+ ;; Link to versioned libtcl and libtk
+ (("linklibs = \\['tcl', 'tk'\\]")
+ "linklibs = ['tcl8.6', 'tk8.6']")
+ (("incdirs = \\[\\]")
+ (string-append
+ "incdirs = ['"
+ #$(this-package-input "tcl") "/include', '"
+ #$(this-package-input "tk") "/include']")))
+ (substitute* '("lib_pypy/_curses_build.py")
+ ;; Find curses
+ (("/usr/local")
+ #$(this-package-input "ncurses")))
+ (substitute* '("lib_pypy/_dbm.py")
+ ;; Use gdbm compat library, so we don’t need to pull
+ ;; in bdb.
+ (("ctypes.util.find_library\\('db'\\)")
+ (format #f "~s" (search-input-file
+ inputs "lib/libgdbm_compat.so"))))
+ (substitute* '("lib_pypy/_sqlite3_build.py")
+ ;; Always use search paths
+ (("sys\\.platform\\.startswith\\('freebsd'\\)") "True")
+ ;; Find sqlite3
+ (("/usr/local") (assoc-ref inputs "sqlite"))
+ (("libname = 'sqlite3'")
+ (format #f "libname = ~s"
+ (search-input-file inputs "lib/libsqlite3.so.0"))))
+ (substitute* '("lib-python/3/subprocess.py")
+ ;; Fix shell path
+ (("/bin/sh")
+ (search-input-file inputs "/bin/sh")))
+ (substitute* '("lib-python/3/distutils/unixccompiler.py")
+ ;; gcc-toolchain does not provide symlink cc -> gcc
+ (("\"cc\"") (format #f "~s" #$(cc-for-target))))))
+ (replace 'build
+ (lambda _
+ (with-directory-excursion "pypy/goal"
+ ;; Build with jit optimization.
+ (invoke "pypy2"
+ "../../rpython/bin/rpython"
+ (string-append "--cc=" #$(cc-for-target))
+ (string-append "--make-jobs="
+ (number->string (parallel-job-count)))
+ "-Ojit"
+ "targetpypystandalone"
+ "--allworkingmodules"))
+ ;; Build c modules and package everything, so tests work.
+ (with-directory-excursion "pypy/tool/release"
+ (invoke "pypy2" "package.py"
+ "--archive-name" "pypy-dist"
+ "--builddir" (getcwd)))))
+ (replace 'check
+ (lambda* (#:key tests? #:allow-other-keys)
+ (if tests?
+ (begin
+ (setenv "HOME" "/tmp") ; test_with_pip tries to
+ ; access ~/.cache/pip
+ ;; Run library tests only (no interpreter unit tests).
+ ;; This is what Gentoo does.
+ (invoke "python" "pypy/test_all.py"
+ "--pypy=pypy/tool/release/pypy-dist/bin/pypy3"
+ "lib-python"))
+ (format #t "test suite not run~%"))))
+ (replace 'install
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ (let* ((bin-pypy3 (string-append #$output "/bin/pypy3"))
+ (shebang-match-python "#!.+/bin/python")
+ (shebang-pypy3 (string-append "#!" bin-pypy3))
+ (dist-dir "pypy/tool/release/pypy-dist"))
+ (with-directory-excursion dist-dir
+ ;; Delete test data.
+ (for-each
+ (lambda (x)
+ (delete-file-recursively (string-append
+ "lib/pypy3.11/" x)))
+ '("tkinter/test"
+ "test"
+ "lib2to3/tests"
+ "idlelib/idle_test"
+ "distutils/tests"
+ "ctypes/test"
+ "unittest/test"))
+ ;; Patch shebang referencing python.
+ (substitute* '("lib/pypy3.11/cgi.py"
+ "lib/pypy3.11/encodings/rot_13.py")
+ ((shebang-match-python) shebang-pypy3))
+ (with-fluids ((%default-port-encoding "ISO-8859-1"))
+ (substitute* '("lib/pypy3.11/_md5.py"
+ "lib/pypy3.11/_sha1.py")
+ ((shebang-match-python) shebang-pypy3))))
+ (copy-recursively dist-dir #$output))))))))
+ (native-inputs
+ (modify-inputs (package-native-inputs pypy2)
+ (replace "python2" pypy2)))
+ (inputs
+ (modify-inputs (package-inputs pypy2)
+ (append xz)))))
+
(define-public pypy3
(deprecated-package "pypy3" pypy))