123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913 |
- (define-module (gnu packages python)
- #:use-module ((guix licenses) #:prefix license:)
- #:use-module (gnu packages)
- #:use-module (gnu packages base)
- #:use-module (gnu packages bash)
- #:use-module (gnu packages certs)
- #:use-module (gnu packages check)
- #:use-module (gnu packages compression)
- #:use-module (gnu packages dbm)
- #:use-module (gnu packages hurd)
- #:use-module (gnu packages libffi)
- #:use-module (gnu packages ncurses)
- #:use-module (gnu packages pkg-config)
- #:use-module (gnu packages python-xyz)
- #:use-module (gnu packages readline)
- #:use-module (gnu packages shells)
- #:use-module (gnu packages sqlite)
- #:use-module (gnu packages tcl)
- #:use-module (gnu packages tls)
- #:use-module (gnu packages xml)
- #:use-module (guix gexp)
- #:use-module (guix packages)
- #:use-module (guix download)
- #:use-module (guix utils)
- #:use-module (guix build-system gnu)
- #:use-module (guix build-system trivial)
- #:use-module (srfi srfi-1)
- #:use-module (srfi srfi-26)
- #:export (customize-site
- guix-pythonpath-search-path))
- (define* (customize-site version)
- "Generate a install-sitecustomize.py phase, using VERSION."
- `(lambda* (#:key native-inputs inputs outputs #:allow-other-keys)
- (let* ((out (assoc-ref outputs "out"))
- (site-packages (string-append
- out "/lib/python"
- ,(version-major+minor version)
- "/site-packages"))
- (sitecustomize.py (assoc-ref (or native-inputs inputs)
- "sitecustomize.py"))
- (dest (string-append site-packages "/sitecustomize.py")))
- (mkdir-p site-packages)
- (copy-file sitecustomize.py dest)
-
-
- (chmod dest #o644))))
- (define (guix-pythonpath-search-path version)
- "Generate a GUIX_PYTHONPATH search path specification, using VERSION."
- (search-path-specification (variable "GUIX_PYTHONPATH")
- (files (list (string-append
- "lib/python"
- (version-major+minor version)
- "/site-packages")))))
- (define-public python-2.7
- (package
- (name "python2")
- (version "2.7.18")
- (source
- (origin
- (method url-fetch)
- (uri (string-append "https://www.python.org/ftp/python/"
- version "/Python-" version ".tar.xz"))
- (sha256
- (base32
- "0hzgxl94hnflis0d6m4szjx0b52gah7wpmcg5g00q7am6xwhwb5n"))
- (patches (search-patches "python-2.7-search-paths.patch"
- "python-2-deterministic-build-info.patch"
- "python-2.7-site-prefixes.patch"
- "python-2.7-source-date-epoch.patch"
- "python-2.7-adjust-tests.patch"
- "python-cross-compile.patch"
- "python-2.7-CVE-2021-3177.patch"
- "python-2.7-no-static-lib.patch"))
- (modules '((guix build utils)))
- (snippet
- '(begin
-
- (for-each delete-file-recursively
- '("Modules/_ctypes/libffi" "Modules/expat" "Modules/zlib"))
- (substitute* "Modules/Setup.dist"
-
- (("^#pyexpat.*") "pyexpat pyexpat.c -lexpat\n"))
-
-
-
- (for-each delete-file
- '("Lib/test/test_compileall.py"
- "Lib/test/test_ctypes.py"
- "Lib/test/test_distutils.py"
- "Lib/test/test_import.py"
- "Lib/test/test_shutil.py"
- "Lib/test/test_socket.py"
- "Lib/test/test_subprocess.py"))))))
- (outputs '("out"
- "tk"
- "idle"))
- (build-system gnu-build-system)
- (arguments
- `(#:test-target "test"
- #:configure-flags
- (list "--enable-shared"
- "--with-system-expat"
- "--with-system-ffi"
- "--with-ensurepip=install"
- "--with-computed-gotos"
- "--enable-unicode=ucs4"
-
-
-
-
-
-
- "INSTALL=install -c"
- "MKDIR_P=mkdir -p"
-
-
- ,@(if (%current-target-system)
- '("ac_cv_buggy_getaddrinfo=no"
- "ac_cv_file__dev_ptmx=no"
- "ac_cv_file__dev_ptc=no")
- '())
-
-
-
- "CFLAGS=-fno-semantic-interposition"
- (string-append "LDFLAGS=-Wl,-rpath="
- (assoc-ref %outputs "out") "/lib"
- " -fno-semantic-interposition"))
-
- #:make-flags
- (list (string-append
- (format #f "TESTOPTS=-j~d" (parallel-job-count))
-
-
-
-
-
- " --exclude test_urllib2_localnet test_httplib"))
- #:modules ((ice-9 ftw) (ice-9 match)
- (guix build utils) (guix build gnu-build-system))
- #:phases
- (modify-phases %standard-phases
- (add-before
- 'configure 'patch-lib-shells
- (lambda _
-
-
-
- ,@(if (%current-target-system)
- '((setenv "_PYTHON_HOST_PLATFORM" ""))
- '())
-
-
- (substitute* (filter file-exists?
- '("Lib/subprocess.py"
- "Lib/popen2.py"
- "Lib/distutils/tests/test_spawn.py"
- "Lib/test/support/__init__.py"
- "Lib/test/test_subprocess.py"))
- (("/bin/sh") (which "sh")))))
- ,@(if (hurd-system?)
- `((add-before 'build 'patch-regen-for-hurd
- (lambda* (#:key inputs #:allow-other-keys)
- (let ((libc (assoc-ref inputs "libc")))
- (substitute* "Lib/plat-generic/regen"
- (("/usr/include/") (string-append libc "/include/")))))))
- '())
- (add-before 'configure 'do-not-record-configure-flags
- (lambda* (#:key configure-flags #:allow-other-keys)
-
-
-
-
-
-
-
- (substitute* "configure"
- (("^CONFIG_ARGS=.*$")
- (format #f "CONFIG_ARGS='~a'\n"
- (if (member "--with-system-ffi" configure-flags)
- "--with-system-ffi"
- ""))))))
- (add-before 'check 'pre-check
- (lambda _
-
- (setenv "HOME" (getcwd))))
- (add-after 'unpack 'set-source-file-times-to-1980
-
-
-
-
- (lambda _
- (let ((circa-1980 (* 10 366 24 60 60)))
- (ftw "." (lambda (file stat flag)
- (utime file circa-1980 circa-1980)
- #t)))))
- (add-after 'install 'remove-tests
-
-
- (lambda* (#:key outputs #:allow-other-keys)
- (let ((out (assoc-ref outputs "out")))
- (match (scandir (string-append out "/lib")
- (lambda (name)
- (string-prefix? "python" name)))
- ((pythonX.Y)
- (let ((testdir (string-append out "/lib/" pythonX.Y
- "/test")))
- (with-directory-excursion testdir
- (for-each delete-file-recursively
- (scandir testdir
- (match-lambda
- ((or "." "..") #f)
- ("support" #f)
- (file
- (not
- (string-prefix? "test_support."
- file))))))
- (call-with-output-file "__init__.py" (const #t))))
- (let ((libdir (string-append out "/lib/" pythonX.Y)))
- (for-each
- (lambda (directory)
- (let ((dir (string-append libdir "/" directory)))
- (when (file-exists? dir)
- (delete-file-recursively dir))))
- '("email/test" "ctypes/test" "unittest/test" "tkinter/test"
- "sqlite3/test" "bsddb/test" "lib-tk/test" "json/tests"
- "distutils/tests"))))))))
- (add-after 'remove-tests 'move-tk-inter
- (lambda* (#:key outputs #:allow-other-keys)
-
-
- (let ((out (assoc-ref outputs "out"))
- (tk (assoc-ref outputs "tk")))
- (when tk
- (match (find-files out "tkinter.*\\.so")
- ((tkinter.so)
-
-
- (let* ((len (string-length out))
- (target (string-append
- tk "/"
- (string-drop
- (dirname (dirname tkinter.so))
- len)
- "/site-packages")))
- (install-file tkinter.so target)
- (delete-file tkinter.so))))))))
- (add-after 'move-tk-inter 'move-idle
- (lambda* (#:key outputs #:allow-other-keys)
-
-
- (let ((out (assoc-ref outputs "out"))
- (idle (assoc-ref outputs "idle")))
- (when idle
- (for-each
- (lambda (file)
- (let ((target (string-append idle "/bin/" (basename file))))
- (install-file file (dirname target))
- (delete-file file)))
- (find-files (string-append out "/bin") "^idle"))
- (match (find-files out "^idlelib$" #:directories? #t)
- ((idlelib)
- (let* ((len (string-length out))
- (target (string-append idle "/"
- (string-drop idlelib len)
- "/site-packages")))
- (mkdir-p (dirname target))
- (rename-file idlelib target))))))))
- (add-after 'move-idle 'rebuild-bytecode
- (lambda* (#:key outputs #:allow-other-keys)
- (let ((out (assoc-ref outputs "out")))
-
-
- (setenv "PYTHONHASHSEED" "0")
- (for-each
- (lambda (output)
- (for-each (lambda (opt)
- (format #t "Compiling with optimization level: ~a\n"
- (if (null? opt) "none" (car opt)))
- (apply invoke
- `(,,(if (%current-target-system)
- "python2"
- '(string-append out "/bin/python"))
- ,@opt
- "-m" "compileall"
- "-f"
-
-
- "-x" "lib2to3/.*"
- ,output)))
-
-
-
- (list '() '("-OO"))))
- (map cdr outputs)))))
- (add-after 'install 'install-sitecustomize.py
- ,(customize-site version)))))
- (inputs
- (list bzip2
- expat
- gdbm
- libffi
- sqlite
- openssl
- readline
- zlib
- tcl
- tk))
- (native-inputs
- `(("pkg-config" ,pkg-config)
- ("sitecustomize.py" ,(local-file (search-auxiliary-file
- "python/sitecustomize.py")))
-
- ,@(if (%current-target-system)
- `(("python2" ,this-package)
- ("which" ,which))
- '())))
- (native-search-paths
- (list (guix-pythonpath-search-path version)))
- (home-page "https://www.python.org")
- (synopsis "High-level, dynamically-typed programming language")
- (description
- "Python is a remarkably powerful dynamic programming language that
- is used in a wide variety of application domains. Some of its key
- distinguishing features include: clear, readable syntax; strong
- introspection capabilities; intuitive object orientation; natural
- expression of procedural code; full modularity, supporting hierarchical
- packages; exception-based error handling; and very high level dynamic
- data types.")
- (properties '((cpe-name . "python")))
- (license license:psfl)))
- (define-public python-2 python-2.7)
- (define-public python2-called-python
-
-
-
- (package/inherit python-2
- (name "python")
- (properties `((superseded . ,python-2)))))
- (define-public python-3.9
- (package
- (inherit python-2)
- (name "python")
- (version "3.9.9")
- (source (origin
- (method url-fetch)
- (uri (string-append "https://www.python.org/ftp/python/"
- version "/Python-" version ".tar.xz"))
- (patches (search-patches
- "python-3-arm-alignment.patch"
- "python-3-deterministic-build-info.patch"
- "python-3-fix-tests.patch"
- "python-3-hurd-configure.patch"
- "python-3-search-paths.patch"
- "python-3-no-static-lib.patch"))
- (sha256
- (base32
- "09vd7g71i11iz5ydqghwc8kaxr0vgji94hhwwnj77h3kll28r0h6"))
- (modules '((guix build utils)))
- (snippet
- '(begin
-
- (delete-file-recursively "Modules/expat")
- (substitute* "Modules/Setup"
-
- (("^#pyexpat.*") "pyexpat pyexpat.c -lexpat\n"))
-
- (for-each delete-file
- (find-files "Lib/distutils/command" "\\.exe$"))))))
- (arguments
- (substitute-keyword-arguments (package-arguments python-2)
- ((#:make-flags _)
- `(list (string-append
- (format #f "TESTOPTS=-j~d" (parallel-job-count))
-
- " --exclude test_mmap test_socket"
- ,@(if (hurd-target?)
- '(" test_posix"
- " test_time"
- " test_pty"
- " test_shutil"
- " test_tempfile"
-
- " test_asyncio"
- " test_os"
-
- " test_openpty"
- " test_selectors"
-
- " test_compileall"
- " test_poll"
- " test_subprocess"
- " test_asyncore"
- " test_threadsignals"
- " test_eintr"
- " test_io"
- " test_logging"
- " test_signal"
- " test_threading"
- " test_flags"
- " test_bidirectional_pty"
- " test_create_unix_connection"
- " test_unix_sock_client_ops"
- " test_open_unix_connection"
- " test_open_unix_connection_error"
- " test_read_pty_output"
- " test_write_pty")
- '()))))
- ((#:phases phases)
- `(modify-phases ,phases
- ,@(if (hurd-system?)
- `((delete 'patch-regen-for-hurd))
- '())
- (add-after 'unpack 'remove-windows-binaries
- (lambda _
-
- (for-each
- (lambda (whl)
- (let ((dir "whl-content")
- (circa-1980 (* 10 366 24 60 60)))
- (mkdir-p dir)
- (with-directory-excursion dir
- (let ((whl (string-append "../" whl)))
- (invoke "unzip" whl)
- (for-each delete-file
- (find-files "." "\\.exe$"))
- (delete-file whl)
-
-
- (ftw "." (lambda (file stat flag)
- (utime file circa-1980 circa-1980)
- #t))
- (apply invoke "zip" "-X" whl
- (find-files "." #:directories? #t))))
- (delete-file-recursively dir)))
- (find-files "Lib/ensurepip" "\\.whl$"))))
- (add-before 'check 'set-TZDIR
- (lambda* (#:key inputs native-inputs #:allow-other-keys)
-
- (setenv "TZDIR"
- (string-append (assoc-ref
- (or native-inputs inputs) "tzdata")
- "/share/zoneinfo"))))
- (replace 'rebuild-bytecode
- (lambda* (#:key outputs #:allow-other-keys)
- (let ((out (assoc-ref outputs "out")))
-
-
- (setenv "PYTHONHASHSEED" "0")
- (for-each (lambda (output)
-
-
-
-
- (for-each (lambda (pyc)
- (delete-file pyc))
- (find-files output "\\.pyc$"))
- (apply invoke
- `(,,(if (%current-target-system)
- "python3"
- '(string-append out
- "/bin/python3"))
- "-m" "compileall"
- "-o" "0" "-o" "1" "-o" "2"
- "-f"
- "--invalidation-mode=unchecked-hash"
-
-
- "-x" "lib2to3/.*"
- ,output)))
- (map cdr outputs)))))
- (replace 'install-sitecustomize.py
- ,(customize-site version))))))
- (native-inputs
- `(("tzdata" ,tzdata-for-tests)
- ("unzip" ,unzip)
- ("zip" ,(@ (gnu packages compression) zip))
- ,@(if (%current-target-system)
- `(("python3" ,this-package))
- '())
- ,@(package-native-inputs python-2)))
- (native-search-paths
- (list (guix-pythonpath-search-path version)
-
-
- (search-path-specification
- (variable "PYTHONTZPATH")
- (files (list "share/zoneinfo")))))))
- (define-public python-3 python-3.9)
- (define-public python python-3)
- (define-public python2-minimal
- (package/inherit python-2
- (name "python2-minimal")
- (outputs '("out"))
-
-
-
-
- (inputs `(("expat" ,expat)
- ("libffi" ,libffi)
- ("zlib" ,zlib)))))
- (define-public python-minimal
- (package/inherit python
- (name "python-minimal")
- (outputs '("out"))
-
-
-
-
- (inputs `(("expat" ,expat)
- ("libffi" ,libffi)
- ("openssl" ,openssl)
- ("zlib" ,zlib)))))
- (define-public python-debug
- (package/inherit python
- (name "python-debug")
- (outputs '("out" "debug"))
- (build-system gnu-build-system)
- (arguments
- (substitute-keyword-arguments (package-arguments python)
- ((#:configure-flags flags '())
- `(cons "--with-pydebug" ,flags))))
- (synopsis
- "High-level, dynamically-typed programming language (for debugging)")
- (description
- "This variant of Python provides an interpreter built with
- @code{--with-pydebug} to help develop and debug extensions. See
- @url{https://pythonextensionpatterns.readthedocs.io/en/latest/debugging/debug.html},
- for more information.")))
- (define* (wrap-python3 python
- #:optional
- (name (string-append (package-name python) "-wrapper")))
- (package/inherit python
- (name name)
- (source #f)
- (build-system trivial-build-system)
- (outputs '("out"))
- (inputs `(("bash" ,bash)))
- (propagated-inputs `(("python" ,python)))
- (arguments
- `(#:modules ((guix build utils))
- #:builder
- (begin
- (use-modules (guix build utils))
- (let ((bin (string-append (assoc-ref %outputs "out") "/bin"))
- (python (string-append (assoc-ref %build-inputs "python") "/bin/")))
- (mkdir-p bin)
- (for-each
- (lambda (old new)
- (symlink (string-append python old)
- (string-append bin "/" new)))
- `("python3" ,"pydoc3" ,"pip3")
- `("python" ,"pydoc" ,"pip"))
-
-
- (let ((bash (string-append (assoc-ref %build-inputs "bash")
- "/bin/bash"))
- (old (string-append python "python3-config"))
- (new (string-append bin "/python-config")))
- (with-output-to-file new
- (lambda ()
- (format #t "#!~a~%" bash)
- (format #t "exec \"~a\" \"$@\"~%" old)
- (chmod new #o755))))))))
- (synopsis "Wrapper for the Python 3 commands")
- (description
- "This package provides wrappers for the commands of Python@tie{}3.x such
- that they can be invoked under their usual name---e.g., @command{python}
- instead of @command{python3} or @command{pip} instead of @command{pip3}.
- To function properly, this package should not be installed together with the
- @command{python} package.")))
- (define-public python-wrapper (wrap-python3 python))
- (define-public python-minimal-wrapper (wrap-python3 python-minimal))
- (define-public micropython
- (package
- (name "micropython")
- (version "1.15")
- (source
- (origin
- (method url-fetch)
- (uri (string-append "https://github.com/micropython/micropython/"
- "releases/download/v" version
- "/micropython-" version ".tar.xz"))
- (sha256
- (base32 "04sfrfcljhfps340l4wh5ffwkhw1ydraday8nv92nv7gmnrj1l2j"))
- (modules '((guix build utils)))
- (snippet
- '(begin
- (delete-file-recursively "ports/cc3200/FreeRTOS")
- (with-directory-excursion "lib"
-
- (for-each delete-file-recursively
- '("libffi" "lwip" "stm32lib" "nrfx")))
- #t))))
- (build-system gnu-build-system)
- (arguments
- `(#:phases
- (modify-phases %standard-phases
- (add-before 'build 'build-mpy-cross
- (lambda* (#:key make-flags #:allow-other-keys)
- (with-directory-excursion "mpy-cross"
- (apply invoke "make" make-flags))))
- (add-after 'build-mpy-cross 'prepare-build
- (lambda _
- (chdir "ports/unix")
-
- (substitute* "Makefile"
- (("-Os") "-Os -ffp-contract=off"))
- #t))
- (replace 'install-license-files
-
- (lambda* (#:key outputs #:allow-other-keys)
- (let* ((out (assoc-ref outputs "out"))
- (dest (string-append out "/share/doc/" ,name "-" ,version "/")))
- (install-file "../../LICENSE" dest))
- #t))
- (delete 'configure))
- #:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
- "V=1")
- #:test-target "test"))
- (native-inputs
- `(("pkg-config" ,pkg-config)
- ("python" ,python-wrapper)))
- (inputs
- (list libffi))
- (home-page "https://micropython.org/")
- (synopsis "Python implementation for microcontrollers and constrained systems")
- (description "MicroPython is a lean and efficient implementation of the
- Python 3 programming language that includes a small subset of the Python
- standard library and is optimised to run on microcontrollers and in constrained
- environments. MicroPython is packed full of advanced features such as an
- interactive prompt, arbitrary precision integers, closures, list comprehension,
- generators, exception handling and more. Still it is compact enough to fit and
- run within just 256k of code space and 16k of RAM. MicroPython aims to be as
- compatible with normal Python as possible to allow you to transfer code with
- ease from the desktop to a microcontroller or embedded system.")
- (license license:expat)))
- (define-public pypy3
- (package
- (name "pypy3")
- (version "7.3.5")
- (source (origin
- (method url-fetch)
- (uri (string-append "https://downloads.python.org/pypy/"
- "pypy3.7-v" version "-src.tar.bz2"))
- (sha256
- (base32
- "18lrdmpcczlbk3cfarkgwqdmilrybz56i1dafk8dkjlyk90gw86r"))))
- (build-system gnu-build-system)
- (native-inputs
- `(("python-2" ,python-2)
- ("pkg-config" ,pkg-config)
- ("tar" ,tar)
- ("python2-pycparser" ,python2-pycparser)
- ("python2-hypothesis" ,python2-hypothesis)
- ("nss-certs" ,nss-certs)
- ("gzip" ,gzip)))
- (inputs
- (list libffi
- zlib
- ncurses
- openssl
- expat
- bzip2
- sqlite
- gdbm
- tcl
- tk
- glibc
- xz))
- (arguments
- `(#:tests? #f
- #:modules ((ice-9 ftw) (ice-9 match)
- (guix build utils) (guix build gnu-build-system))
- #:disallowed-references (,nss-certs)
- #:phases (modify-phases %standard-phases
- (delete 'configure)
- (add-after 'unpack 'patch-source
- (lambda* (#:key inputs outputs #:allow-other-keys)
- (substitute* '("rpython/rlib/clibffi.py")
-
- (("ctypes\\.util\\.find_library\\('c'\\)") "'libc.so'"))
- (substitute* '("lib_pypy/cffi/_pycparser/ply/cpp.py")
-
- (("time\\.localtime\\(\\)") "time.gmtime(0)"))
- (substitute* '("pypy/module/sys/version.py")
-
- (("t\\.gmtime\\(\\)") "t.gmtime(0)"))
- (substitute* '("lib_pypy/_tkinter/tklib_build.py")
-
- (("linklibs = \\['tcl', 'tk'\\]")
- "linklibs = ['tcl8.6', 'tk8.6']")
- (("incdirs = \\[\\]")
- (string-append "incdirs = ['"
- (assoc-ref inputs "tcl")
- "/include', '"
- (assoc-ref inputs "tk")
- "/include']")))
- (substitute* '("lib_pypy/_curses_build.py")
-
- (("/usr/local") (assoc-ref inputs "ncurses")))
- (substitute* '("lib_pypy/_dbm.py")
-
-
- (("ctypes.util.find_library\\('db'\\)")
- (format #f "'~a/lib/libgdbm_compat.so'"
- (assoc-ref inputs "gdbm"))))
- (substitute* '("lib_pypy/_sqlite3_build.py")
-
- (("sys\\.platform\\.startswith\\('freebsd'\\)") "True")
-
- (("/usr/local") (assoc-ref inputs "sqlite"))
- (("libname = 'sqlite3'")
- (string-append "libname = '"
- (assoc-ref inputs "sqlite")
- "/lib/libsqlite3.so.0'")))
- (substitute* '("lib-python/3/subprocess.py")
-
- (("/bin/sh")
- (search-input-file inputs "/bin/sh")))
- (substitute* '("lib-python/3/distutils/unixccompiler.py")
-
- (("\"cc\"") "\"gcc\""))))
- (add-after
- 'unpack 'set-source-file-times-to-1980
-
- (lambda _
- (let ((circa-1980 (* 10 366 24 60 60)))
- (ftw "." (lambda (file stat flag)
- (utime file circa-1980 circa-1980)
- #t)))))
- (replace 'build
- (lambda* (#:key inputs #:allow-other-keys)
- (with-directory-excursion "pypy/goal"
-
- (invoke "python2"
- "../../rpython/bin/rpython"
- (string-append "--make-jobs="
- (number->string (parallel-job-count)))
- "-Ojit"
- "targetpypystandalone"
- "--allworkingmodules"))
-
- (with-directory-excursion "pypy/tool/release"
- (invoke "python2" "package.py"
- "--archive-name" "pypy-dist"
- "--builddir" (getcwd)))))
- (replace 'check
- (lambda* (#:key tests? #:allow-other-keys)
- (if tests?
- (begin
- (setenv "HOME" "/tmp")
-
-
-
- (invoke
- "python2"
- "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* ((out (assoc-ref outputs "out"))
- (bin-pypy3 (string-append out "/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
-
- (for-each
- (lambda (x)
- (delete-file-recursively (string-append
- "lib-python/3/" x)))
- '("tkinter/test"
- "test"
- "sqlite3/test"
- "lib2to3/tests"
- "idlelib/idle_test"
- "distutils/tests"
- "ctypes/test"
- "unittest/test"))
-
- (substitute* '("lib-python/3/cgi.py"
- "lib-python/3/encodings/rot_13.py")
- ((shebang-match-python) shebang-pypy3))
- (with-fluids ((%default-port-encoding "ISO-8859-1"))
- (substitute* '("lib_pypy/_md5.py"
- "lib_pypy/_sha1.py")
- ((shebang-match-python) shebang-pypy3))))
- (copy-recursively dist-dir out)))))))
- (home-page "https://www.pypy.org/")
- (synopsis "Python implementation with just-in-time compilation")
- (description "PyPy is a faster, alternative implementation of the Python
- programming language employing a just-in-time compiler. It supports most
- Python code natively, including C extensions.")
- (license (list license:expat
- license:psfl
- license:asl2.0
- license:gpl3+
- license:bsd-3
- (license:non-copyleft
- "http://www.unicode.org/copyright.html")))))
|