You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

819 lines
39 KiB

mailmap: Update entries for Nikita. * .mailmap: change email and name for Nikita. * Makefile.am, doc/guix.texi, etc/completion/fish/guix.fish, gnu/packages/accessibility.scm, gnu/packages/admin.scm, gnu/packages/audio.scm, gnu/packages/autotools.scm, gnu/packages/cdrom.scm, gnu/packages/check.scm, gnu/packages/cinnamon.scm, gnu/packages/compression.scm, gnu/packages/crypto.scm, gnu/packages/databases.scm, gnu/packages/django.scm, gnu/packages/dns.scm, gnu/packages/elixir.scm, gnu/packages/emacs-xyz.scm, gnu/packages/emacs.scm, gnu/packages/enlightenment.scm, gnu/packages/erlang.scm, gnu/packages/fonts.scm, gnu/packages/fontutils.scm, gnu/packages/forth.scm, gnu/packages/fvwm.scm, gnu/packages/games.scm, gnu/packages/gl.scm, gnu/packages/gnome.scm, gnu/packages/gnunet.scm, gnu/packages/gnupg.scm, gnu/packages/gtk.scm, gnu/packages/guile-wm.scm, gnu/packages/guile-xyz.scm, gnu/packages/haskell-apps.scm, gnu/packages/haskell-check.scm, gnu/packages/haskell-crypto.scm, gnu/packages/haskell-xyz.scm, gnu/packages/haskell.scm, gnu/packages/image-viewers.scm, gnu/packages/image.scm, gnu/packages/irc.scm, gnu/packages/language.scm, gnu/packages/libcanberra.scm, gnu/packages/linux.scm, gnu/packages/lisp-xyz.scm, gnu/packages/lisp.scm, gnu/packages/lolcode.scm, gnu/packages/lxde.scm, gnu/packages/lxqt.scm, gnu/packages/mail.scm, gnu/packages/markup.scm, gnu/packages/mate.scm, gnu/packages/maths.scm, gnu/packages/mc.scm, gnu/packages/messaging.scm, gnu/packages/music.scm, gnu/packages/ncurses.scm, gnu/packages/networking.scm, gnu/packages/nickle.scm, gnu/packages/openbox.scm, gnu/packages/pdf.scm, gnu/packages/perl-check.scm, gnu/packages/perl.scm, gnu/packages/python-compression.scm, gnu/packages/python-crypto.scm, gnu/packages/python-web.scm, gnu/packages/python-xyz.scm, gnu/packages/python.scm, gnu/packages/qt.scm, gnu/packages/ruby.scm, gnu/packages/rust.scm, gnu/packages/scheme.scm, gnu/packages/serialization.scm, gnu/packages/shells.scm, gnu/packages/ssh.scm, gnu/packages/suckless.scm, gnu/packages/tbb.scm, gnu/packages/telephony.scm, gnu/packages/text-editors.scm, gnu/packages/textutils.scm, gnu/packages/time.scm, gnu/packages/tls.scm, gnu/packages/tor.scm, gnu/packages/version-control.scm, gnu/packages/video.scm, gnu/packages/vim.scm, gnu/packages/web.scm, gnu/packages/wm.scm, gnu/packages/xdisorg.scm, gnu/packages/xfce.scm, gnu/packages/xml.scm, gnu/packages/xorg.scm, gnu/services/certbot.scm, gnu/services/desktop.scm, gnu/services/version-control.scm, gnu/services/web.scm, guix/import/hackage.scm, guix/licenses.scm: Likewise. Signed-off-by: Efraim Flashner <efraim@flashner.co.il>
1 year ago
3 years ago
gnu: Separate Python core packages from the rest. * gnu/packages/python.scm: Move hundreds of package definitions from here... * gnu/packages/python-xyz.scm: ...to this new module. * gnu/local.mk (GNU_SYSTEM_MODULES): Add it. * gnu/packages/ada.scm, gnu/packages/admin.scm, gnu/packages/android.scm, gnu/packages/audio.scm, gnu/packages/backup.scm, gnu/packages/benchmark.scm, gnu/packages/bioinformatics.scm, gnu/packages/bittorrent.scm, gnu/packages/calendar.scm, gnu/packages/check.scm, gnu/packages/chemistry.scm, gnu/packages/cluster.scm, gnu/packages/compression.scm, gnu/packages/connman.scm, gnu/packages/crypto.scm, gnu/packages/cups.scm, gnu/packages/databases.scm, gnu/packages/dav.scm, gnu/packages/direct-connect.scm, gnu/packages/disk.scm, gnu/packages/django.scm, gnu/packages/dlang.scm, gnu/packages/docker.scm, gnu/packages/ebook.scm, gnu/packages/elf.scm, gnu/packages/emacs.scm, gnu/packages/emulators.scm, gnu/packages/engineering.scm, gnu/packages/enlightenment.scm, gnu/packages/finance.scm, gnu/packages/fltk.scm, gnu/packages/fontutils.scm, gnu/packages/freedesktop.scm, gnu/packages/game-development.scm, gnu/packages/games.scm, gnu/packages/geo.scm, gnu/packages/gl.scm, gnu/packages/glib.scm, gnu/packages/gnome.scm, gnu/packages/gnupg.scm, gnu/packages/gnuzilla.scm, gnu/packages/graph.scm, gnu/packages/graphics.scm, gnu/packages/graphviz.scm, gnu/packages/gtk.scm, gnu/packages/ham-radio.scm, gnu/packages/image-processing.scm, gnu/packages/image-viewers.scm, gnu/packages/image.scm, gnu/packages/irc.scm, gnu/packages/jrnl.scm, gnu/packages/julia.scm, gnu/packages/kde-frameworks.scm, gnu/packages/key-mon.scm, gnu/packages/libffi.scm, gnu/packages/libreoffice.scm, gnu/packages/libusb.scm, gnu/packages/lirc.scm, gnu/packages/logging.scm, gnu/packages/machine-learning.scm, gnu/packages/mail.scm, gnu/packages/mate.scm, gnu/packages/maths.scm, gnu/packages/medical.scm, gnu/packages/messaging.scm, gnu/packages/monitoring.scm, gnu/packages/mp3.scm, gnu/packages/mpd.scm, gnu/packages/music.scm, gnu/packages/networking.scm, gnu/packages/nutrition.scm, gnu/packages/openldap.scm, gnu/packages/openstack.scm, gnu/packages/package-management.scm, gnu/packages/password-utils.scm, gnu/packages/patchutils.scm, gnu/packages/pdf.scm, gnu/packages/photo.scm, gnu/packages/polkit.scm, gnu/packages/protobuf.scm, gnu/packages/python-crypto.scm, gnu/packages/python-web.scm, gnu/packages/qt.scm, gnu/packages/rdf.scm, gnu/packages/ruby.scm, gnu/packages/search.scm, gnu/packages/selinux.scm, gnu/packages/serialization.scm, gnu/packages/shells.scm, gnu/packages/simulation.scm, gnu/packages/ssh.scm, gnu/packages/statistics.scm, gnu/packages/storage.scm, gnu/packages/sync.scm, gnu/packages/terminals.scm, gnu/packages/textutils.scm, gnu/packages/time.scm, gnu/packages/tls.scm, gnu/packages/tor.scm, gnu/packages/tryton.scm, gnu/packages/version-control.scm, gnu/packages/video.scm, gnu/packages/virtualization.scm, gnu/packages/vpn.scm, gnu/packages/web-browsers.scm, gnu/packages/web.scm, gnu/packages/wicd.scm, gnu/packages/xdisorg.scm, gnu/packages/xorg.scm: Update module references.
3 years ago
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
  3. ;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
  4. ;;; Copyright © 2013, 2014, 2015, 2016 Andreas Enge <andreas@enge.fr>
  5. ;;; Copyright © 2014, 2015 Mark H Weaver <mhw@netris.org>
  6. ;;; Copyright © 2014, 2017, 2019 Eric Bavier <bavier@member.fsf.org>
  7. ;;; Copyright © 2014, 2015 Federico Beffa <beffa@fbengineering.ch>
  8. ;;; Copyright © 2015 Omar Radwan <toxemicsquire4@gmail.com>
  9. ;;; Copyright © 2015 Pierre-Antoine Rault <par@rigelk.eu>
  10. ;;; Copyright © 2015, 2016, 2017, 2018, 2019 Ricardo Wurmus <rekado@elephly.net>
  11. ;;; Copyright © 2015, 2016 Christopher Allan Webber <cwebber@dustycloud.org>
  12. ;;; Copyright © 2015 Eric Dvorsak <eric@dvorsak.fr>
  13. ;;; Copyright © 2015, 2016 David Thompson <davet@gnu.org>
  14. ;;; Copyright © 2015, 2016, 2017 Leo Famulari <leo@famulari.name>
  15. ;;; Copyright © 2015, 2017 Ben Woodcroft <donttrustben@gmail.com>
  16. ;;; Copyright © 2015, 2016 Erik Edrosa <erik.edrosa@gmail.com>
  17. ;;; Copyright © 2015, 2016, 2017, 2018, 2019, 2020 Efraim Flashner <efraim@flashner.co.il>
  18. ;;; Copyright © 2015, 2017 Kyle Meyer <kyle@kyleam.com>
  19. ;;; Copyright © 2015, 2016 Chris Marusich <cmmarusich@gmail.com>
  20. ;;; Copyright © 2016 Danny Milosavljevic <dannym+a@scratchpost.org>
  21. ;;; Copyright © 2016 Lukas Gradl <lgradl@openmailbox.org>
  22. ;;; Copyright © 2016, 2018 Hartmut Goebel <h.goebel@crazy-compilers.com>
  23. ;;; Copyright © 2016 Daniel Pimentel <d4n1@d4n1.org>
  24. ;;; Copyright © 2016 Sou Bunnbu <iyzsong@gmail.com>
  25. ;;; Copyright © 2016, 2017 Troy Sankey <sankeytms@gmail.com>
  26. ;;; Copyright © 2016, 2017 Nikita <nikita@n0.is>
  27. ;;; Copyright © 2016 Dylan Jeffers <sapientech@sapientech@openmailbox.org>
  28. ;;; Copyright © 2016 David Craven <david@craven.ch>
  29. ;;; Copyright © 2016, 2017, 2018, 2019, 2020 Marius Bakke <mbakke@fastmail.com>
  30. ;;; Copyright © 2016, 2017 Stefan Reichör <stefan@xsteve.at>
  31. ;;; Copyright © 2016 Dylan Jeffers <sapientech@sapientech@openmailbox.org>
  32. ;;; Copyright © 2016, 2017 Alex Vong <alexvong1995@gmail.com>
  33. ;;; Copyright © 2016, 2017, 2018 Arun Isaac <arunisaac@systemreboot.net>
  34. ;;; Copyright © 2016, 2017, 2018 Julien Lepiller <julien@lepiller.eu>
  35. ;;; Copyright © 2016, 2017, 2018 Tobias Geerinckx-Rice <me@tobias.gr>
  36. ;;; Copyright © 2016, 2017 Thomas Danckaert <post@thomasdanckaert.be>
  37. ;;; Copyright © 2017 Carlo Zancanaro <carlo@zancanaro.id.au>
  38. ;;; Copyright © 2017 Frederick M. Muriithi <fredmanglis@gmail.com>
  39. ;;; Copyright © 2017, 2018 Adriano Peluso <catonano@gmail.com>
  40. ;;; Copyright © 2017 Ben Sturmfels <ben@sturm.com.au>
  41. ;;; Copyright © 2017, 2018, 2019 Mathieu Othacehe <m.othacehe@gmail.com>
  42. ;;; Copyright © 2017 José Miguel Sánchez García <jmi2k@openmailbox.org>
  43. ;;; Copyright © 2017 Roel Janssen <roel@gnu.org>
  44. ;;; Copyright © 2017, 2018 Kei Kebreau <kkebreau@posteo.net>
  45. ;;; Copyright © 2017 Rutger Helling <rhelling@mykolab.com>
  46. ;;; Copyright © 2017 Muriithi Frederick Muriuki <fredmanglis@gmail.com>
  47. ;;; Copyright © 2017 Brendan Tildesley <mail@brendan.scot>
  48. ;;; Copyright © 2018 Ethan R. Jones <ethanrjones97@gmail.com
  49. ;;; Copyright © 2018 Fis Trivial <ybbs.daans@hotmail.com>
  50. ;;; Copyright © 2018 Vijayalakshmi Vedantham <vijimay12@gmail.com>
  51. ;;; Copyright © 2018 Mathieu Lirzin <mthl@gnu.org>
  52. ;;; Copyright © 2018 Adam Massmann <massmannak@gmail.com>
  53. ;;; Copyright © 2016, 2018 Tomáš Čech <sleep_walker@gnu.org>
  54. ;;; Copyright © 2018 Nicolas Goaziou <mail@nicolasgoaziou.fr>
  55. ;;; Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com>
  56. ;;; Copyright © 2018 Clément Lassieur <clement@lassieur.org>
  57. ;;; Copyright © 2018, 2019 Maxim Cournoyer <maxim.cournoyer@gmail.com>
  58. ;;; Copyright © 2018 Luther Thompson <lutheroto@gmail.com>
  59. ;;; Copyright © 2018 Vagrant Cascadian <vagrant@debian.org>
  60. ;;; Copyright © 2019 Tanguy Le Carrour <tanguy@bioneland.org>
  61. ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
  62. ;;;
  63. ;;; This file is part of GNU Guix.
  64. ;;;
  65. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  66. ;;; under the terms of the GNU General Public License as published by
  67. ;;; the Free Software Foundation; either version 3 of the License, or (at
  68. ;;; your option) any later version.
  69. ;;;
  70. ;;; GNU Guix is distributed in the hope that it will be useful, but
  71. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  72. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  73. ;;; GNU General Public License for more details.
  74. ;;;
  75. ;;; You should have received a copy of the GNU General Public License
  76. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  77. (define-module (gnu packages python)
  78. #:use-module ((guix licenses) #:prefix license:)
  79. #:use-module (gnu packages)
  80. #:use-module (gnu packages base)
  81. #:use-module (gnu packages bash)
  82. #:use-module (gnu packages certs)
  83. #:use-module (gnu packages check)
  84. #:use-module (gnu packages compression)
  85. #:use-module (gnu packages dbm)
  86. #:use-module (gnu packages hurd)
  87. #:use-module (gnu packages libffi)
  88. #:use-module (gnu packages ncurses)
  89. #:use-module (gnu packages pkg-config)
  90. #:use-module (gnu packages python-xyz)
  91. #:use-module (gnu packages readline)
  92. #:use-module (gnu packages shells)
  93. #:use-module (gnu packages sqlite)
  94. #:use-module (gnu packages tcl)
  95. #:use-module (gnu packages tls)
  96. #:use-module (gnu packages xml)
  97. #:use-module (guix packages)
  98. #:use-module (guix download)
  99. #:use-module (guix utils)
  100. #:use-module (guix build-system gnu)
  101. #:use-module (guix build-system trivial)
  102. #:use-module (srfi srfi-1)
  103. #:use-module (srfi srfi-26))
  104. (define-public python-2.7
  105. (package
  106. (name "python2")
  107. (version "2.7.17")
  108. (source
  109. (origin
  110. (method url-fetch)
  111. (uri (string-append "https://www.python.org/ftp/python/"
  112. version "/Python-" version ".tar.xz"))
  113. (sha256
  114. (base32
  115. "0hds28cg226m8j8sr394nm9yc4gxhvlv109w0avsf2mxrlrz0hsd"))
  116. (patches (search-patches "python-2.7-search-paths.patch"
  117. "python-2-deterministic-build-info.patch"
  118. "python-2.7-site-prefixes.patch"
  119. "python-2.7-source-date-epoch.patch"
  120. "python-2.7-adjust-tests.patch"
  121. "python-cross-compile.patch"))
  122. (modules '((guix build utils)))
  123. (snippet
  124. '(begin
  125. ;; Ensure the bundled copies of these libraries are not used.
  126. (for-each delete-file-recursively
  127. '("Modules/_ctypes/libffi" "Modules/expat" "Modules/zlib"))
  128. (substitute* "Modules/Setup.dist"
  129. ;; Link Expat instead of embedding the bundled one.
  130. (("^#pyexpat.*") "pyexpat pyexpat.c -lexpat\n"))
  131. ;; Suboptimal to delete failing tests here, but if we delete them in
  132. ;; the arguments then we need to make sure to strip out that phase
  133. ;; when it gets inherited by python and python-minimal.
  134. (for-each delete-file
  135. '("Lib/test/test_compileall.py"
  136. "Lib/test/test_ctypes.py" ; fails on mips64el
  137. "Lib/test/test_distutils.py"
  138. "Lib/test/test_import.py"
  139. "Lib/test/test_shutil.py"
  140. "Lib/test/test_socket.py"
  141. "Lib/test/test_subprocess.py"))
  142. #t))))
  143. (outputs '("out"
  144. "tk")) ;tkinter; adds 50 MiB to the closure
  145. (build-system gnu-build-system)
  146. (arguments
  147. `(#:test-target "test"
  148. #:configure-flags
  149. (list "--enable-shared" ;allow embedding
  150. "--with-system-expat" ;for XML support
  151. "--with-system-ffi" ;build ctypes
  152. "--with-ensurepip=install" ;install pip and setuptools
  153. "--enable-unicode=ucs4"
  154. ;; Prevent the installed _sysconfigdata.py from retaining a reference
  155. ;; to coreutils.
  156. "INSTALL=install -c"
  157. "MKDIR_P=mkdir -p"
  158. ;; Disable runtime check failing if cross-compiling, see:
  159. ;; https://lists.yoctoproject.org/pipermail/poky/2013-June/008997.html
  160. ,@(if (%current-target-system)
  161. '("ac_cv_buggy_getaddrinfo=no"
  162. "ac_cv_file__dev_ptmx=no"
  163. "ac_cv_file__dev_ptc=no")
  164. '())
  165. (string-append "LDFLAGS=-Wl,-rpath="
  166. (assoc-ref %outputs "out") "/lib"))
  167. ;; With no -j argument tests use all available cpus, so provide one.
  168. #:make-flags
  169. (list (string-append
  170. (format #f "TESTOPTS=-j~d" (parallel-job-count))
  171. ;; Exclude the following tests as they fail
  172. ;; non-deterministically with "error: [Errno 104] Connection
  173. ;; reset by peer." Python 3 seems unaffected. A potential fix,
  174. ;; yet to be backported to Python 2, is available at:
  175. ;; https://github.com/python/cpython/commit/529525fb5a8fd9b96ab4021311a598c77588b918.
  176. " --exclude test_urllib2_localnet test_httplib"))
  177. #:modules ((ice-9 ftw) (ice-9 match)
  178. (guix build utils) (guix build gnu-build-system))
  179. #:phases
  180. (modify-phases %standard-phases
  181. (add-before
  182. 'configure 'patch-lib-shells
  183. (lambda _
  184. ;; This variable is used in setup.py to enable cross compilation
  185. ;; specific switches. As it is not set properly by configure
  186. ;; script, set it manually.
  187. ,@(if (%current-target-system)
  188. '((setenv "_PYTHON_HOST_PLATFORM" ""))
  189. '())
  190. ;; Filter for existing files, since some may not exist in all
  191. ;; versions of python that are built with this recipe.
  192. (substitute* (filter file-exists?
  193. '("Lib/subprocess.py"
  194. "Lib/popen2.py"
  195. "Lib/distutils/tests/test_spawn.py"
  196. "Lib/test/support/__init__.py"
  197. "Lib/test/test_subprocess.py"))
  198. (("/bin/sh") (which "sh")))
  199. #t))
  200. ,@(if (hurd-system?)
  201. `((add-before 'build 'patch-regen-for-hurd
  202. (lambda* (#:key inputs #:allow-other-keys)
  203. (let ((libc (assoc-ref inputs "libc")))
  204. (substitute* "Lib/plat-generic/regen"
  205. (("/usr/include/") (string-append libc "/include/")))
  206. #t))))
  207. '())
  208. (add-before 'configure 'do-not-record-configure-flags
  209. (lambda* (#:key configure-flags #:allow-other-keys)
  210. ;; Remove configure flags from the installed '_sysconfigdata.py'
  211. ;; and 'Makefile' so we don't end up keeping references to the
  212. ;; build tools.
  213. ;;
  214. ;; Preserve at least '--with-system-ffi' since otherwise the
  215. ;; thing tries to build libffi, fails, and we end up with a
  216. ;; Python that lacks ctypes.
  217. (substitute* "configure"
  218. (("^CONFIG_ARGS=.*$")
  219. (format #f "CONFIG_ARGS='~a'\n"
  220. (if (member "--with-system-ffi" configure-flags)
  221. "--with-system-ffi"
  222. ""))))
  223. #t))
  224. (add-before
  225. 'check 'pre-check
  226. (lambda _
  227. ;; 'Lib/test/test_site.py' needs a valid $HOME
  228. (setenv "HOME" (getcwd))
  229. #t))
  230. (add-after
  231. 'unpack 'set-source-file-times-to-1980
  232. ;; XXX One of the tests uses a ZIP library to pack up some of the
  233. ;; source tree, and fails with "ZIP does not support timestamps
  234. ;; before 1980". Work around this by setting the file times in the
  235. ;; source tree to sometime in early 1980.
  236. (lambda _
  237. (let ((circa-1980 (* 10 366 24 60 60)))
  238. (ftw "." (lambda (file stat flag)
  239. (utime file circa-1980 circa-1980)
  240. #t))
  241. #t)))
  242. (add-after 'install 'remove-tests
  243. ;; Remove 25 MiB of unneeded unit tests. Keep test_support.*
  244. ;; because these files are used by some libraries out there.
  245. (lambda* (#:key outputs #:allow-other-keys)
  246. (let ((out (assoc-ref outputs "out")))
  247. (match (scandir (string-append out "/lib")
  248. (lambda (name)
  249. (string-prefix? "python" name)))
  250. ((pythonX.Y)
  251. (let ((testdir (string-append out "/lib/" pythonX.Y
  252. "/test")))
  253. (with-directory-excursion testdir
  254. (for-each delete-file-recursively
  255. (scandir testdir
  256. (match-lambda
  257. ((or "." "..") #f)
  258. ("support" #f)
  259. (file
  260. (not
  261. (string-prefix? "test_support."
  262. file))))))
  263. (call-with-output-file "__init__.py" (const #t))
  264. #t)))))))
  265. (add-after 'remove-tests 'rebuild-bytecode
  266. (lambda* (#:key outputs #:allow-other-keys)
  267. (let ((out (assoc-ref outputs "out")))
  268. ;; Disable hash randomization to ensure the generated .pycs
  269. ;; are reproducible.
  270. (setenv "PYTHONHASHSEED" "0")
  271. (for-each
  272. (lambda (opt)
  273. (format #t "Compiling with optimization level: ~a\n"
  274. (if (null? opt) "none" (car opt)))
  275. (for-each (lambda (file)
  276. (apply invoke
  277. `(,,(if (%current-target-system)
  278. "python2"
  279. '(string-append out "/bin/python"))
  280. ,@opt
  281. "-m" "compileall"
  282. "-f" ; force rebuild
  283. ;; Don't build lib2to3, because it contains Python 3 code.
  284. "-x" "lib2to3/.*"
  285. ,file)))
  286. (find-files out "\\.py$")))
  287. (list '() '("-O") '("-OO")))
  288. #t)))
  289. (add-after 'install 'move-tk-inter
  290. (lambda* (#:key outputs #:allow-other-keys)
  291. ;; When Tkinter support is built move it to a separate output so
  292. ;; that the main output doesn't contain a reference to Tcl/Tk.
  293. (let ((out (assoc-ref outputs "out"))
  294. (tk (assoc-ref outputs "tk")))
  295. (when tk
  296. (match (find-files out "tkinter.*\\.so")
  297. ((tkinter.so)
  298. ;; The .so is in OUT/lib/pythonX.Y/lib-dynload, but we
  299. ;; want it under TK/lib/pythonX.Y/site-packages.
  300. (let* ((len (string-length out))
  301. (target (string-append
  302. tk "/"
  303. (string-drop
  304. (dirname (dirname tkinter.so))
  305. len)
  306. "/site-packages")))
  307. (install-file tkinter.so target)
  308. (delete-file tkinter.so)))))
  309. #t))))))
  310. (inputs
  311. `(("bzip2" ,bzip2)
  312. ("expat" ,expat)
  313. ("gdbm" ,gdbm)
  314. ("libffi" ,libffi) ; for ctypes
  315. ("sqlite" ,sqlite) ; for sqlite extension
  316. ("openssl" ,openssl)
  317. ("readline" ,readline)
  318. ("zlib" ,zlib)
  319. ("tcl" ,tcl)
  320. ("tk" ,tk))) ; for tkinter
  321. (native-inputs
  322. `(("pkg-config" ,pkg-config)
  323. ;; When cross-compiling, a native version of Python itself is needed.
  324. ,@(if (%current-target-system)
  325. `(("python2" ,this-package)
  326. ("which" ,which))
  327. '())))
  328. (native-search-paths
  329. (list (search-path-specification
  330. (variable "PYTHONPATH")
  331. (files '("lib/python2.7/site-packages")))))
  332. (home-page "https://www.python.org")
  333. (synopsis "High-level, dynamically-typed programming language")
  334. (description
  335. "Python is a remarkably powerful dynamic programming language that
  336. is used in a wide variety of application domains. Some of its key
  337. distinguishing features include: clear, readable syntax; strong
  338. introspection capabilities; intuitive object orientation; natural
  339. expression of procedural code; full modularity, supporting hierarchical
  340. packages; exception-based error handling; and very high level dynamic
  341. data types.")
  342. (properties '((cpe-name . "python")))
  343. (license license:psfl)))
  344. ;; Current 2.x version.
  345. (define-public python-2 python-2.7)
  346. (define-public python2-called-python
  347. ;; Both 2.x and 3.x used to be called "python". In commit
  348. ;; a7714d42de2c3082f3609d1e63c83d703fb39cf9 (March 2018), we renamed the
  349. ;; Python 2.x package to "python2".
  350. (package
  351. (inherit python-2)
  352. (name "python")
  353. (properties `((superseded . ,python-2)))))
  354. (define-public python-3.8
  355. (package (inherit python-2)
  356. (name "python")
  357. (version "3.8.2")
  358. (source (origin
  359. (method url-fetch)
  360. (uri (string-append "https://www.python.org/ftp/python/"
  361. version "/Python-" version ".tar.xz"))
  362. (patches (search-patches
  363. "python-3-fix-tests.patch"
  364. "python-3.8-fix-tests.patch"
  365. "python-3-deterministic-build-info.patch"
  366. "python-3-search-paths.patch"))
  367. (sha256
  368. (base32
  369. "1ps5v323cp5czfshqjmbsqw7nvrdpcbk06f62jbzaqik4gfffii6"))
  370. (modules '((guix build utils)))
  371. (snippet
  372. '(begin
  373. ;; Delete the bundled copy of libexpat.
  374. (delete-file-recursively "Modules/expat")
  375. (substitute* "Modules/Setup"
  376. ;; Link Expat instead of embedding the bundled one.
  377. (("^#pyexpat.*") "pyexpat pyexpat.c -lexpat\n"))
  378. #t))))
  379. (arguments
  380. (substitute-keyword-arguments (package-arguments python-2)
  381. ((#:make-flags _)
  382. `(list (string-append
  383. (format #f "TESTOPTS=-j~d" (parallel-job-count))
  384. ;; test_mmap fails on low-memory systems.
  385. " --exclude test_mmap"
  386. ;; test_socket may hang and eventually run out of memory
  387. ;; on some systems: <https://bugs.python.org/issue34587>.
  388. " test_socket")))
  389. ((#:phases phases)
  390. `(modify-phases ,phases
  391. ,@(if (hurd-system?)
  392. `((delete 'patch-regen-for-hurd)) ;regen was removed after 3.5.9
  393. '())
  394. ,@(if (hurd-target?)
  395. ;; The build system refuses to cross-compile for unknown targets
  396. ;; even though it works fine. Add GNU/Hurd target.
  397. ;; TODO: Make it a patch in a future rebuild cycle.
  398. '((add-before 'configure 'support-hurd-cross-compile
  399. (lambda _
  400. (substitute* "configure"
  401. (("\\*-\\*-vxworks.*" all)
  402. (string-append "*-*-gnu)\nac_sys_system=GNU\n;;\n" all)))
  403. #t)))
  404. '())
  405. (add-before 'check 'set-TZDIR
  406. (lambda* (#:key inputs native-inputs #:allow-other-keys)
  407. ;; test_email requires the Olson time zone database.
  408. (setenv "TZDIR"
  409. (string-append (assoc-ref
  410. (or native-inputs inputs) "tzdata")
  411. "/share/zoneinfo"))
  412. #t))
  413. ;; Unset SOURCE_DATE_EPOCH while running the test-suite and set it
  414. ;; again afterwards. See <https://bugs.python.org/issue34022>.
  415. (add-before 'check 'unset-SOURCE_DATE_EPOCH
  416. (lambda _ (unsetenv "SOURCE_DATE_EPOCH") #t))
  417. (add-after 'check 'reset-SOURCE_DATE_EPOCH
  418. (lambda _ (setenv "SOURCE_DATE_EPOCH" "1") #t))
  419. (replace 'rebuild-bytecode
  420. (lambda* (#:key outputs #:allow-other-keys)
  421. (let ((out (assoc-ref outputs "out")))
  422. ;; Disable hash randomization to ensure the generated .pycs
  423. ;; are reproducible.
  424. (setenv "PYTHONHASHSEED" "0")
  425. (for-each
  426. (lambda (opt)
  427. (format #t "Compiling with optimization level: ~a\n"
  428. (if (null? opt) "none" (car opt)))
  429. (for-each (lambda (file)
  430. (apply invoke
  431. `(,,(if (%current-target-system)
  432. "python3"
  433. '(string-append out
  434. "/bin/python3"))
  435. ,@opt
  436. "-m" "compileall"
  437. "-f" ; force rebuild
  438. ;; Don't build lib2to3, because it's Python 2 code.
  439. "-x" "lib2to3/.*"
  440. ,file)))
  441. (find-files out "\\.py$")))
  442. (list '() '("-O") '("-OO")))
  443. #t)))
  444. ;; XXX: Apply patch on ARM platforms only to avoid a full rebuild.
  445. ;; Remove this phase in the next rebuild cycle.
  446. ,@(let ((system (or (%current-target-system)
  447. (%current-system))))
  448. (if (any (cute string-prefix? <> system)
  449. '("arm" "aarch64"))
  450. '((add-after 'unpack 'apply-alignment-patch
  451. (lambda* (#:key native-inputs inputs #:allow-other-keys)
  452. (invoke "patch" "-p1" "--force" "--input"
  453. (assoc-ref (or native-inputs inputs)
  454. "arm-alignment.patch")))))
  455. '()))))))
  456. (native-inputs
  457. `(("tzdata" ,tzdata-for-tests)
  458. ;; Disable unaligned accesses in the sha3 module on ARM as
  459. ;; it causes a test failure when building 32-bit Python on a
  460. ;; 64-bit kernel. See <https://bugs.python.org/issue36515>.
  461. ;; TODO: make this a regular patch in the next rebuild cycle.
  462. ,@(let ((system (or (%current-target-system)
  463. (%current-system))))
  464. (if (any (cute string-prefix? <> system)
  465. '("arm" "aarch64"))
  466. `(("arm-alignment.patch" ,(search-patch "python-3-arm-alignment.patch")))
  467. '()))
  468. ,@(if (%current-target-system)
  469. `(("python3" ,this-package))
  470. '())
  471. ,@(package-native-inputs python-2)))
  472. (native-search-paths
  473. (list (search-path-specification
  474. (variable "PYTHONPATH")
  475. (files (list (string-append "lib/python"
  476. (version-major+minor version)
  477. "/site-packages"))))))))
  478. ;; Current 3.x version.
  479. (define-public python-3 python-3.8)
  480. ;; Current major version.
  481. (define-public python python-3)
  482. ;; Minimal variants of Python, mostly used to break the cycle between Tk and
  483. ;; Python (Tk -> libxcb -> Python.)
  484. (define-public python2-minimal
  485. (package/inherit python-2
  486. (name "python2-minimal")
  487. (outputs '("out"))
  488. ;; Keep zlib, which is used by 'pip' (via the 'zipimport' module), which
  489. ;; is invoked upon 'make install'. 'pip' also expects 'ctypes' and thus
  490. ;; libffi. Expat is needed for XML support which is expected by a lot
  491. ;; of libraries out there.
  492. (inputs `(("expat" ,expat)
  493. ("libffi" ,libffi)
  494. ("zlib" ,zlib)))))
  495. (define-public python-minimal
  496. (package/inherit python
  497. (name "python-minimal")
  498. (outputs '("out"))
  499. ;; Build fails due to missing ctypes without libffi.
  500. ;; OpenSSL is a mandatory dependency of Python 3.x, for urllib;
  501. ;; zlib is required by 'zipimport', used by pip. Expat is needed
  502. ;; for XML support, which is generally expected to be available.
  503. (inputs `(("expat" ,expat)
  504. ("libffi" ,libffi)
  505. ("openssl" ,openssl)
  506. ("zlib" ,zlib)))))
  507. (define-public python-debug
  508. (package/inherit python
  509. (name "python-debug")
  510. (outputs '("out" "debug"))
  511. (build-system gnu-build-system)
  512. (arguments
  513. (substitute-keyword-arguments (package-arguments python)
  514. ((#:configure-flags flags '())
  515. `(cons "--with-pydebug" ,flags))))
  516. (synopsis
  517. "High-level, dynamically-typed programming language (for debugging)")
  518. (description
  519. "This variant of Python provides an interpreter built with
  520. @code{--with-pydebug} to help develop and debug extensions. See
  521. @url{https://pythonextensionpatterns.readthedocs.io/en/latest/debugging/debug.html},
  522. for more information.")))
  523. (define* (wrap-python3 python
  524. #:optional
  525. (name (string-append (package-name python) "-wrapper")))
  526. (package/inherit python
  527. (name name)
  528. (source #f)
  529. (build-system trivial-build-system)
  530. (outputs '("out"))
  531. (inputs `(("bash" ,bash)))
  532. (propagated-inputs `(("python" ,python)))
  533. (arguments
  534. `(#:modules ((guix build utils))
  535. #:builder
  536. (begin
  537. (use-modules (guix build utils))
  538. (let ((bin (string-append (assoc-ref %outputs "out") "/bin"))
  539. (python (string-append (assoc-ref %build-inputs "python") "/bin/")))
  540. (mkdir-p bin)
  541. (for-each
  542. (lambda (old new)
  543. (symlink (string-append python old)
  544. (string-append bin "/" new)))
  545. `("python3" ,"pydoc3" ,"idle3" ,"pip3")
  546. `("python" ,"pydoc" ,"idle" ,"pip"))
  547. ;; python-config outputs search paths based upon its location,
  548. ;; use a bash wrapper to avoid changing its outputs.
  549. (let ((bash (string-append (assoc-ref %build-inputs "bash")
  550. "/bin/bash"))
  551. (old (string-append python "python3-config"))
  552. (new (string-append bin "/python-config")))
  553. (with-output-to-file new
  554. (lambda ()
  555. (format #t "#!~a~%" bash)
  556. (format #t "exec \"~a\" \"$@\"~%" old)
  557. (chmod new #o755)
  558. #t)))))))
  559. (synopsis "Wrapper for the Python 3 commands")
  560. (description
  561. "This package provides wrappers for the commands of Python@tie{}3.x such
  562. that they can be invoked under their usual name---e.g., @command{python}
  563. instead of @command{python3}.")))
  564. (define-public python-wrapper (wrap-python3 python))
  565. (define-public python-minimal-wrapper (wrap-python3 python-minimal))
  566. (define-public micropython
  567. (package
  568. (name "micropython")
  569. (version "1.12")
  570. (source
  571. (origin
  572. (method url-fetch)
  573. (uri (string-append "https://github.com/micropython/micropython/"
  574. "releases/download/v" version
  575. "/micropython-" version ".tar.gz"))
  576. (sha256
  577. (base32
  578. "1fl1dm2aay23hyqbarnv69qj7z2wljcvkwmvfwfac8yadcv05zcq"))
  579. (modules '((guix build utils)))
  580. (snippet
  581. '(begin
  582. (delete-file-recursively "ports/cc3200/FreeRTOS")
  583. (with-directory-excursion "lib"
  584. ;; TODO: Unbundle axtls and berkley-db-1.xx
  585. (for-each delete-file-recursively
  586. '("libffi" "lwip" "stm32lib" "nrfx")))
  587. #t))))
  588. (build-system gnu-build-system)
  589. (arguments
  590. `(#:phases
  591. (modify-phases %standard-phases
  592. (add-before 'build 'build-mpy-cross
  593. (lambda* (#:key make-flags #:allow-other-keys)
  594. (with-directory-excursion "mpy-cross"
  595. (apply invoke "make" make-flags))))
  596. (add-after 'build-mpy-cross 'prepare-build
  597. (lambda _
  598. (chdir "ports/unix")
  599. ;; see: https://github.com/micropython/micropython/pull/4246
  600. (substitute* "Makefile"
  601. (("-Os") "-Os -ffp-contract=off"))
  602. #t))
  603. (replace 'install-license-files
  604. ;; We don't build in the root directory so the file isn't found.
  605. (lambda* (#:key outputs #:allow-other-keys)
  606. (let* ((out (assoc-ref outputs "out"))
  607. (dest (string-append out "/share/doc/" ,name "-" ,version "/")))
  608. (install-file "../../LICENSE" dest))
  609. #t))
  610. (delete 'configure)) ; no configure
  611. #:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
  612. "V=1")
  613. #:test-target "test"))
  614. (native-inputs
  615. `(("pkg-config" ,pkg-config)
  616. ("python" ,python-wrapper)))
  617. (inputs
  618. `(("libffi" ,libffi)))
  619. (home-page "https://micropython.org/")
  620. (synopsis "Python implementation for microcontrollers and constrained systems")
  621. (description "MicroPython is a lean and efficient implementation of the
  622. Python 3 programming language that includes a small subset of the Python
  623. standard library and is optimised to run on microcontrollers and in constrained
  624. environments. MicroPython is packed full of advanced features such as an
  625. interactive prompt, arbitrary precision integers, closures, list comprehension,
  626. generators, exception handling and more. Still it is compact enough to fit and
  627. run within just 256k of code space and 16k of RAM. MicroPython aims to be as
  628. compatible with normal Python as possible to allow you to transfer code with
  629. ease from the desktop to a microcontroller or embedded system.")
  630. (license license:expat)))
  631. (define-public pypy3
  632. (package
  633. (name "pypy3")
  634. (version "7.3.1")
  635. (source (origin
  636. (method url-fetch)
  637. (uri (string-append "https://bitbucket.org/pypy/pypy/downloads/" ;
  638. "pypy3.6-v" version "-src.tar.bz2"))
  639. (sha256
  640. (base32
  641. "10zsk8jby8j6visk5mzikpb1cidvz27qq4pfpa26jv53klic6b0c"))
  642. (patches (search-patches "pypy3-7.3.1-fix-tests.patch"))))
  643. (build-system gnu-build-system)
  644. (native-inputs
  645. `(("python-2" ,python-2)
  646. ("pkg-config" ,pkg-config)
  647. ("tar" ,tar) ; Required for package.py
  648. ("python2-pycparser" ,python2-pycparser)
  649. ("python2-hypothesis" ,python2-hypothesis)
  650. ("nss-certs" ,nss-certs) ; For ssl tests
  651. ("gzip" ,gzip)))
  652. (inputs
  653. `(("libffi" ,libffi)
  654. ("zlib" ,zlib)
  655. ("ncurses" ,ncurses)
  656. ("openssl" ,openssl)
  657. ("expat" ,expat)
  658. ("bzip2" ,bzip2)
  659. ("sqlite" ,sqlite)
  660. ("gdbm" ,gdbm)
  661. ("tcl" ,tcl)
  662. ("tk" ,tk)
  663. ("glibc" ,glibc)
  664. ("bash-minimal" ,bash-minimal) ; Used as /bin/sh
  665. ("xz" ,xz))) ; liblzma
  666. (arguments
  667. `(#:tests? #f ;FIXME: Disabled for now, there are many tests failing.
  668. #:modules ((ice-9 ftw) (ice-9 match)
  669. (guix build utils) (guix build gnu-build-system))
  670. #:phases (modify-phases %standard-phases
  671. (delete 'configure)
  672. (add-after 'unpack 'patch-source
  673. (lambda* (#:key inputs outputs #:allow-other-keys)
  674. (substitute* '("rpython/rlib/clibffi.py")
  675. ;; find_library does not work for libc
  676. (("ctypes\\.util\\.find_library\\('c'\\)") "'libc.so'"))
  677. (substitute* '("lib_pypy/cffi/_pycparser/ply/cpp.py")
  678. ;; Make reproducible (XXX: unused?)
  679. (("time\\.localtime\\(\\)") "time.gmtime(0)"))
  680. (substitute* '("pypy/module/sys/version.py")
  681. ;; Make reproducible
  682. (("t\\.gmtime\\(\\)") "t.gmtime(0)"))
  683. (substitute* '("lib_pypy/_tkinter/tklib_build.py")
  684. ;; Link to versioned libtcl and libtk
  685. (("linklibs = \\['tcl', 'tk'\\]")
  686. "linklibs = ['tcl8.6', 'tk8.6']")
  687. (("incdirs = \\[\\]")
  688. (string-append "incdirs = ['"
  689. (assoc-ref inputs "tcl")
  690. "/include', '"
  691. (assoc-ref inputs "tk")
  692. "/include']")))
  693. (substitute* '("lib_pypy/_curses_build.py")
  694. ;; Find curses
  695. (("/usr/local") (assoc-ref inputs "ncurses")))
  696. (substitute* '("lib_pypy/_sqlite3_build.py")
  697. ;; Always use search paths
  698. (("sys\\.platform\\.startswith\\('freebsd'\\)") "True")
  699. ;; Find sqlite3
  700. (("/usr/local") (assoc-ref inputs "sqlite"))
  701. (("libname = 'sqlite3'")
  702. (string-append "libname = '"
  703. (assoc-ref inputs "sqlite")
  704. "/lib/libsqlite3.so.0'")))
  705. (substitute* '("lib-python/3/subprocess.py")
  706. ;; Fix shell path
  707. (("/bin/sh")
  708. (string-append (assoc-ref inputs "bash-minimal") "/bin/sh")))
  709. (substitute* '("lib-python/3/distutils/unixccompiler.py")
  710. ;; gcc-toolchain does not provide symlink cc -> gcc
  711. (("\"cc\"") "\"gcc\""))
  712. #t))
  713. (add-after
  714. 'unpack 'set-source-file-times-to-1980
  715. ;; copied from python package, required by zip testcase
  716. (lambda _
  717. (let ((circa-1980 (* 10 366 24 60 60)))
  718. (ftw "." (lambda (file stat flag)
  719. (utime file circa-1980 circa-1980)
  720. #t))
  721. #t)))
  722. (replace 'build
  723. (lambda* (#:key inputs #:allow-other-keys)
  724. (with-directory-excursion "pypy/goal"
  725. ;; Build with jit optimization.
  726. (invoke "python2"
  727. "../../rpython/bin/rpython"
  728. (string-append "--make-jobs="
  729. (number->string (parallel-job-count)))
  730. "-Ojit"
  731. "targetpypystandalone"))
  732. ;; Build c modules and package everything, so tests work.
  733. (with-directory-excursion "pypy/tool/release"
  734. (unsetenv "PYTHONPATH") ; Do not use the system’s python libs:
  735. ; AttributeError: module 'enum' has no
  736. ; attribute 'IntFlag'
  737. (invoke "python2" "package.py"
  738. "--archive-name" "pypy-dist"
  739. "--builddir" (getcwd)))))
  740. (replace 'check
  741. (lambda* (#:key tests? #:allow-other-keys)
  742. (if tests?
  743. (begin
  744. (setenv "HOME" "/tmp") ; test_with_pip tries to
  745. ; access ~/.cache/pip
  746. ;; Run library tests only (no interpreter unit
  747. ;; tests). This is what Gentoo does.
  748. (invoke
  749. "python2"
  750. "pypy/test_all.py"
  751. "--pypy=pypy/tool/release/pypy-dist/bin/pypy3"
  752. "lib-python"))
  753. (format #t "test suite not run~%"))
  754. #t))
  755. (replace 'install
  756. (lambda* (#:key inputs outputs #:allow-other-keys)
  757. (with-directory-excursion "pypy/tool/release"
  758. ;; Delete test data.
  759. (for-each
  760. (lambda (x)
  761. (delete-file-recursively (string-append
  762. "pypy-dist/lib-python/3/" x)))
  763. '("tkinter/test"
  764. "test"
  765. "sqlite3/test"
  766. "lib2to3/tests"
  767. "idlelib/idle_test"
  768. "distutils/tests"
  769. "ctypes/test"
  770. "unittest/test"))
  771. ;; Patch shebang referencing python2
  772. (substitute* '("pypy-dist/lib-python/3/cgi.py"
  773. "pypy-dist/lib-python/3/encodings/rot_13.py")
  774. (("#!.+/bin/python")
  775. (string-append "#!" (assoc-ref outputs "out") "/bin/pypy3")))
  776. (with-fluids ((%default-port-encoding "ISO-8859-1"))
  777. (substitute* '("pypy-dist/lib_pypy/_md5.py"
  778. "pypy-dist/lib_pypy/_sha1.py")
  779. (("#!.+/bin/python")
  780. (string-append "#!" (assoc-ref outputs "out") "/bin/pypy3"))))
  781. (copy-recursively "pypy-dist" (assoc-ref outputs "out")))
  782. #t)))))
  783. (home-page "https://www.pypy.org/")
  784. (synopsis "Python implementation with just-in-time compilation")
  785. (description "PyPy is a faster, alternative implementation of the Python
  786. programming language employing a just-in-time compiler. It supports most
  787. Python code natively, including C extensions.")
  788. (license (list license:expat ; pypy itself; _pytest/
  789. license:psfl ; python standard library in lib-python/
  790. license:asl2.0 ; dotviewer/font/ and some of lib-python/
  791. license:gpl3+ ; ./rpython/rlib/rvmprof/src/shared/libbacktrace/dwarf2.*
  792. license:bsd-3 ; lib_pypy/cffi/_pycparser/ply/
  793. (license:non-copyleft
  794. "http://www.unicode.org/copyright.html")))))