projects/guix·blob java-team · refs

409 lines · 18.7 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2021 Lars-Dominik Braun <[email protected]>
3;;; Copyright © 2021 Ludovic Courtès <[email protected]>
4;;; Copyright © 2021, 2022, 2025 Maxim Cournoyer <[email protected]>
5;;; Copyright © 2021 Leo Famulari <[email protected]>
6;;; Copyright © 2025 Laura Kirsch <[email protected]>
7;;;
8;;; This file is part of GNU Guix.
9;;;
10;;; GNU Guix is free software; you can redistribute it and/or modify it
11;;; under the terms of the GNU General Public License as published by
12;;; the Free Software Foundation; either version 3 of the License, or (at
13;;; your option) any later version.
14;;;
15;;; GNU Guix is distributed in the hope that it will be useful, but
16;;; WITHOUT ANY WARRANTY; without even the implied warranty of
17;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18;;; GNU General Public License for more details.
19;;;
20;;; You should have received a copy of the GNU General Public License
21;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
22
23(define-module (gnu packages pypy)
24 #:use-module ((guix licenses) #:prefix license:)
25 #:use-module (gnu packages base)
26 #:use-module (gnu packages nss)
27 #:use-module (gnu packages compression)
28 #:use-module (gnu packages crypto)
29 #:use-module (gnu packages dbm)
30 #:use-module (gnu packages libffi)
31 #:use-module (gnu packages ncurses)
32 #:use-module (gnu packages pkg-config)
33 #:use-module (gnu packages python)
34 #:use-module (gnu packages python-build)
35 #:use-module (gnu packages sqlite)
36 #:use-module (gnu packages tcl)
37 #:use-module (gnu packages tls)
38 #:use-module (gnu packages xml)
39 #:use-module (guix gexp)
40 #:use-module (guix packages)
41 #:use-module (guix download)
42 #:use-module (guix utils)
43 #:use-module (guix build-system gnu)
44 #:use-module ((guix build-system python) #:select (package-with-python2))
45 #:use-module (guix build-system pyproject))
46
47(define-public python2-pycparser
48 (let ((base (package
49 (version "2.18")
50 (name "python-pycparser")
51 (source
52 (origin
53 (method url-fetch)
54 (uri (pypi-uri "pycparser" version))
55 (sha256
56 (base32
57 "09mjyw82ibqzl449g7swy8bfxnfpmas0815d2rkdjlcqw81wma4r"))))
58 (build-system pyproject-build-system)
59 (arguments
60 (list
61 #:tests? #f
62 #:phases
63 #~(modify-phases %standard-phases
64 (replace 'build
65 (lambda _
66 (invoke "python" "setup.py" "build")))
67 (replace 'install
68 (lambda _
69 (invoke "python" "./setup.py" "install"
70 (string-append "--prefix=" #$output)
71 "--no-compile")
72 (invoke "python" "-m" "compileall" #$output))))))
73 (home-page "https://github.com/eliben/pycparser")
74 (synopsis "C parser in Python")
75 (description
76 "Pycparser is a complete parser of the C language, written in
77pure Python using the PLY parsing library. It parses C code into an AST and
78can serve as a front-end for C compilers or analysis tools.")
79 (license license:bsd-3))))
80 (package
81 (inherit (package-with-python2 base))
82 (native-inputs (list python-setuptools)))))
83
84(define-public python2-cffi
85 (let ((base (package
86 (name "python-cffi")
87 (version "1.15.1")
88 (source
89 (origin
90 (method url-fetch)
91 (uri (pypi-uri "cffi" version))
92 (sha256
93 (base32 "1y9lr651svbzf1m03s4lqbnbv2byx8f6f0ml7hjm24vvlfwvy06l"))))
94 (build-system pyproject-build-system)
95 (arguments
96 (list
97 #:tests? #f
98 #:phases
99 #~(modify-phases %standard-phases
100 (replace 'build
101 (lambda _
102 (invoke "python" "setup.py" "build")))
103 (replace 'install
104 (lambda _
105 (let ((site (string-append #$output
106 "/lib/python2.7/site-packages/")))
107 (mkdir-p site)
108 (setenv "PYTHONPATH" site))
109 (invoke "python" "./setup.py" "install"
110 (string-append "--prefix=" #$output)
111 "--no-compile"))))))
112 (native-inputs '())
113 (inputs (modify-inputs (package-inputs python-cffi)
114 (append libxcrypt)))
115 (propagated-inputs (list python2-pycparser))
116 (home-page "https://cffi.readthedocs.io/")
117 (synopsis "Foreign function interface for Python")
118 (description "Foreign Function Interface for Python calling C code.")
119 (license license:expat))))
120 (package
121 (inherit (package-with-python2 base))
122 (native-inputs (list pkg-config python-setuptools)))))
123
124;;; This Python 2 alternative implementation is useful for allowing faster
125;;; iterations on the development of Pypy 3.
126(define-public pypy2
127 (package
128 (name "pypy2")
129 (version "7.3.20")
130 (source (origin
131 (method url-fetch)
132 (uri (string-append "https://downloads.python.org/pypy/"
133 "pypy2.7-v" version "-src.tar.bz2"))
134 (sha256
135 (base32
136 "0qiyd9bajxyzh4j5swk14iwyh4b7pn38sg3j721zfysz8jc895dz"))))
137 (build-system gnu-build-system)
138 (arguments
139 (list
140 #:modules '((ice-9 ftw) (ice-9 match)
141 (guix build utils) (guix build gnu-build-system))
142 ;; The stdlib tests do not all pass, this is known and tracked upstream
143 ;; on their buildbot instance, for example at:
144 ;; <https://buildbot.pypy.org/summary?branch=py3.11>. That's also true
145 ;; for Pypy 3. The tests are also disabled to avoid having to package
146 ;; extra Python 2 dependencies like python2-hypothesis.
147 #:tests? #f
148 ;; XXX: ELF file 'pypy.debug' makes 'validate-needed-in-runpath' throw:
149 ;; <https://issues.guix.gnu.org/57653>.
150 #:validate-runpath? #f
151 #:phases
152 #~(modify-phases %standard-phases
153 (delete 'configure)
154 (add-after 'unpack 'patch-source
155 (lambda* (#:key inputs #:allow-other-keys)
156 (substitute* '("rpython/rlib/clibffi.py")
157 ;; find_library does not work for libc
158 (("ctypes\\.util\\.find_library\\('c'\\)") "'libc.so'"))
159 (substitute* '("lib_pypy/cffi/_pycparser/ply/cpp.py")
160 ;; Make reproducible (XXX: unused?)
161 (("time\\.localtime\\(\\)") "time.gmtime(0)"))
162 (substitute* '("pypy/module/sys/version.py")
163 ;; Make reproducible
164 (("t\\.gmtime\\(\\)") "t.gmtime(0)"))
165 (substitute* '("lib_pypy/_tkinter/tklib_build.py")
166 ;; Link to versioned libtcl and libtk
167 (("linklibs = \\['tcl', 'tk'\\]")
168 "linklibs = ['tcl8.6', 'tk8.6']")
169 (("incdirs = \\[\\]")
170 (string-append
171 "incdirs = ['"
172 #$(this-package-input "tcl") "/include', '"
173 #$(this-package-input "tk") "/include']")))
174 (substitute* '("lib_pypy/_curses_build.py")
175 ;; Find curses
176 (("/usr/local")
177 #$(this-package-input "ncurses")))
178 (substitute* '("lib_pypy/dbm.py")
179 ;; Use gdbm compat library, so we don’t need to pull
180 ;; in bdb.
181 (("ctypes.util.find_library\\('db'\\)")
182 (format #f "~s" (search-input-file
183 inputs "lib/libgdbm_compat.so"))))
184 (substitute* '("lib_pypy/_sqlite3_build.py")
185 ;; Always use search paths
186 (("sys\\.platform\\.startswith\\('freebsd'\\)") "True")
187 ;; Find sqlite3
188 (("/usr/local") (assoc-ref inputs "sqlite"))
189 (("libname = 'sqlite3'")
190 (format #f "libname = ~s"
191 (search-input-file inputs "lib/libsqlite3.so.0"))))
192 (substitute* '("lib-python/2.7/subprocess.py")
193 ;; Fix shell path
194 (("/bin/sh")
195 (search-input-file inputs "/bin/sh")))
196 (substitute* '("lib-python/2.7/distutils/unixccompiler.py")
197 ;; gcc-toolchain does not provide symlink cc -> gcc
198 (("\"cc\"") (format #f "~s" #$(cc-for-target))))
199 (substitute* "lib-python/2.7/distutils/sysconfig_pypy.py"
200 (("\"cc ")
201 (string-append "\"" #$(cc-for-target) " ")))))
202 (add-after 'unpack 'use-libffi.so
203 (lambda _
204 (substitute* "rpython/rlib/clibffi.py"
205 (("\"libffi\\.a\"")
206 "\"libffi.so\""))))
207 (add-after 'unpack 'set-source-file-times-to-1980
208 ;; copied from python package, required by zip testcase
209 (lambda _
210 (let ((circa-1980 (* 10 366 24 60 60)))
211 (ftw "." (lambda (file stat flag)
212 (utime file circa-1980 circa-1980)
213 #t)))))
214 (replace 'build
215 (lambda _
216 (setenv "CC" #$(cc-for-target))
217 (with-directory-excursion "pypy/goal"
218 ;; Build with jit optimization.
219 (invoke "python2"
220 "../../rpython/bin/rpython"
221 (string-append "--cc=" #$(cc-for-target))
222 (string-append "--make-jobs="
223 (number->string (parallel-job-count)))
224 "-Ojit"
225 "targetpypystandalone"
226 "--allworkingmodules"))
227 ;; Build c modules and package everything, so tests work.
228 (with-directory-excursion "pypy/tool/release"
229 (invoke "python2" "package.py"
230 "--archive-name" "pypy-dist"
231 "--builddir" (getcwd)))))
232 (replace 'install
233 (lambda* (#:key inputs outputs #:allow-other-keys)
234 (let* ((bin-pypy2 (string-append #$output "/bin/pypy2"))
235 (shebang-match-python "#!.+/bin/python")
236 (shebang-pypy2 (string-append "#!" bin-pypy2))
237 (dist-dir "pypy/tool/release/pypy-dist"))
238 (with-directory-excursion dist-dir
239 ;; Delete test data.
240 (for-each
241 (lambda (x)
242 (delete-file-recursively (string-append
243 "lib-python/2.7/" x)))
244 '("lib-tk/test"
245 "test"
246 "lib2to3/tests"
247 "idlelib/idle_test"
248 "distutils/tests"
249 "ctypes/test"
250 "unittest/test"))
251 ;; Patch shebang referencing python.
252 (substitute* '("lib-python/2.7/cgi.py"
253 "lib-python/2.7/encodings/rot_13.py")
254 ((shebang-match-python) shebang-pypy2)))
255 (copy-recursively dist-dir #$output)))))))
256 (native-inputs
257 (list nss-certs ; For ssl tests
258 pkg-config
259 python-2
260 python2-cffi))
261 (inputs
262 (list bzip2
263 expat
264 gdbm
265 libffi
266 ncurses
267 openssl
268 sqlite
269 tcl
270 tk
271 zlib))
272 (home-page "https://www.pypy.org/")
273 (synopsis "Python implementation with just-in-time compilation")
274 (description "PyPy is a faster, alternative implementation of the Python
275programming language employing a just-in-time compiler. It supports most
276Python code natively, including C extensions.")
277 (license (list license:expat ; pypy itself; _pytest/
278 license:psfl ; python standard library in lib-python/
279 license:asl2.0 ; dotviewer/font/ and some of lib-python/
280 license:gpl3+ ; ./rpython/rlib/rvmprof/src/shared/libbacktrace/dwarf2.*
281 license:bsd-3 ; lib_pypy/cffi/_pycparser/ply/
282 (license:non-copyleft
283 "http://www.unicode.org/copyright.html")))))
284
285(define-public pypy
286 (package
287 (inherit pypy2)
288 (name "pypy")
289 (version "7.3.20")
290 (source (origin
291 (method url-fetch)
292 (uri (string-append "https://downloads.python.org/pypy/"
293 "pypy3.11-v" version "-src.tar.bz2"))
294 (sha256
295 (base32
296 "1yq6n888fxfdqid29q3w8bn7ii800bjkf44w82kjwgh0c2kxv1kp"))))
297 (arguments
298 (substitute-keyword-arguments arguments
299 ((#:phases phases)
300 #~(modify-phases #$phases
301 (replace 'patch-source
302 ;; Overridden from pypy2 because some file names have changed.
303 (lambda* (#:key inputs #:allow-other-keys)
304 (substitute* '("rpython/rlib/clibffi.py")
305 ;; find_library does not work for libc
306 (("ctypes\\.util\\.find_library\\('c'\\)") "'libc.so'"))
307 (substitute* '("lib_pypy/cffi/_pycparser/ply/cpp.py")
308 ;; Make reproducible (XXX: unused?)
309 (("time\\.localtime\\(\\)") "time.gmtime(0)"))
310 (substitute* '("pypy/module/sys/version.py")
311 ;; Make reproducible
312 (("t\\.gmtime\\(\\)") "t.gmtime(0)"))
313 (substitute* '("lib_pypy/_tkinter/tklib_build.py")
314 ;; Link to versioned libtcl and libtk
315 (("linklibs = \\['tcl', 'tk'\\]")
316 "linklibs = ['tcl8.6', 'tk8.6']")
317 (("incdirs = \\[\\]")
318 (string-append
319 "incdirs = ['"
320 #$(this-package-input "tcl") "/include', '"
321 #$(this-package-input "tk") "/include']")))
322 (substitute* '("lib_pypy/_curses_build.py")
323 ;; Find curses
324 (("/usr/local")
325 #$(this-package-input "ncurses")))
326 (substitute* '("lib_pypy/_dbm.py")
327 ;; Use gdbm compat library, so we don’t need to pull
328 ;; in bdb.
329 (("ctypes.util.find_library\\('db'\\)")
330 (format #f "~s" (search-input-file
331 inputs "lib/libgdbm_compat.so"))))
332 (substitute* '("lib_pypy/_sqlite3_build.py")
333 ;; Always use search paths
334 (("sys\\.platform\\.startswith\\('freebsd'\\)") "True")
335 ;; Find sqlite3
336 (("/usr/local") (assoc-ref inputs "sqlite"))
337 (("libname = 'sqlite3'")
338 (format #f "libname = ~s"
339 (search-input-file inputs "lib/libsqlite3.so.0"))))
340 (substitute* '("lib-python/3/subprocess.py")
341 ;; Fix shell path
342 (("/bin/sh")
343 (search-input-file inputs "/bin/sh")))
344 (substitute* '("lib-python/3/distutils/unixccompiler.py")
345 ;; gcc-toolchain does not provide symlink cc -> gcc
346 (("\"cc\"") (format #f "~s" #$(cc-for-target))))))
347 (replace 'build
348 (lambda _
349 (with-directory-excursion "pypy/goal"
350 ;; Build with jit optimization.
351 (invoke "pypy2"
352 "../../rpython/bin/rpython"
353 (string-append "--cc=" #$(cc-for-target))
354 (string-append "--make-jobs="
355 (number->string (parallel-job-count)))
356 "-Ojit"
357 "targetpypystandalone"
358 "--allworkingmodules"))
359 ;; Build c modules and package everything, so tests work.
360 (with-directory-excursion "pypy/tool/release"
361 (invoke "pypy2" "package.py"
362 "--archive-name" "pypy-dist"
363 "--builddir" (getcwd)))))
364 (replace 'check
365 (lambda* (#:key tests? #:allow-other-keys)
366 (if tests?
367 (begin
368 (setenv "HOME" "/tmp") ; test_with_pip tries to
369 ; access ~/.cache/pip
370 ;; Run library tests only (no interpreter unit tests).
371 ;; This is what Gentoo does.
372 (invoke "python" "pypy/test_all.py"
373 "--pypy=pypy/tool/release/pypy-dist/bin/pypy3"
374 "lib-python"))
375 (format #t "test suite not run~%"))))
376 (replace 'install
377 (lambda* (#:key inputs outputs #:allow-other-keys)
378 (let* ((bin-pypy3 (string-append #$output "/bin/pypy3"))
379 (shebang-match-python "#!.+/bin/python")
380 (shebang-pypy3 (string-append "#!" bin-pypy3))
381 (dist-dir "pypy/tool/release/pypy-dist"))
382 (with-directory-excursion dist-dir
383 ;; Delete test data.
384 (for-each
385 (lambda (x)
386 (delete-file-recursively (string-append
387 "lib/pypy3.11/" x)))
388 '("tkinter/test"
389 "test"
390 "lib2to3/tests"
391 "idlelib/idle_test"
392 "distutils/tests"
393 "ctypes/test"
394 "unittest/test"))
395 ;; Patch shebang referencing python.
396 (substitute* '("lib/pypy3.11/cgi.py"
397 "lib/pypy3.11/encodings/rot_13.py")
398 ((shebang-match-python) shebang-pypy3))
399 (with-fluids ((%default-port-encoding "ISO-8859-1"))
400 (substitute* '("lib/pypy3.11/_md5.py"
401 "lib/pypy3.11/_sha1.py")
402 ((shebang-match-python) shebang-pypy3))))
403 (copy-recursively dist-dir #$output))))))))
404 (native-inputs
405 (modify-inputs native-inputs
406 (replace "python2" pypy2)))
407 (inputs
408 (modify-inputs inputs
409 (append xz)))))