Advertisement
Guest User

guix install-from-file patch-path troubles

a guest
Aug 10th, 2021
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.77 KB | None | 0 0
  1. ;; guix package --install-from-file=/home/samuel/git/guix/gnu/packages/python-3.6.4.scm
  2. (use-modules
  3. (guix)
  4. (guix build-system gnu)
  5. (guix licenses)
  6. (gnu packages)
  7. (gnu packages python)
  8. (gnu packages adns)
  9. (gnu packages attr)
  10. (gnu packages backup)
  11. (gnu packages bash)
  12. (gnu packages check)
  13. (gnu packages compression)
  14. (gnu packages databases)
  15. (gnu packages file)
  16. (gnu packages gcc)
  17. (gnu packages gl)
  18. (gnu packages glib)
  19. (gnu packages libevent)
  20. (gnu packages libffi)
  21. (gnu packages linux)
  22. (gnu packages man)
  23. (gnu packages pcre)
  24. (gnu packages perl)
  25. (gnu packages python-crypto)
  26. (gnu packages readline)
  27. (gnu packages sdl)
  28. (gnu packages shells)
  29. (gnu packages ssh)
  30. (gnu packages statistics)
  31. (gnu packages texinfo)
  32. (gnu packages time)
  33. (gnu packages version-control)
  34. (guix packages)
  35. (guix download)
  36. (guix git-download)
  37. (guix utils)
  38. (guix build-system gnu)
  39. (guix build-system cmake)
  40. (guix build-system python)
  41. (guix build-system trivial)
  42. (srfi srfi-1))
  43.  
  44. (package
  45. (inherit python-2)
  46. (name "python-3.6.4")
  47. (version "3.6.4")
  48. (source (origin
  49. (method url-fetch)
  50. (uri (string-append "https://www.python.org/ftp/python/"
  51. version "/Python-" version ".tar.xz"))
  52. (patches (search-patches
  53. "python-fix-tests.patch"
  54. "python-3-fix-tests.patch"
  55. "python-3-deterministic-build-info.patch"
  56. "python-3-search-paths.patch"))
  57. (patch-flags '("-p0"))
  58. (sha256
  59. (base32
  60. "1fna7g8jxzl4kd2pqmmqhva5724c5m920x3fsrpsgskaylmr76qm"))
  61. (snippet
  62. '(begin
  63. (for-each delete-file
  64. '("Lib/ctypes/test/test_structures.py" ; fails on aarch64
  65. "Lib/ctypes/test/test_win32.py" ; fails on aarch64
  66. "Lib/test/test_fcntl.py")) ; fails on aarch64
  67. #t))))
  68. (arguments
  69. (substitute-keyword-arguments (package-arguments python-2)
  70. ((#:tests? _) #t)
  71. ((#:phases phases)
  72. `(modify-phases ,phases
  73. (add-after 'unpack 'patch-timestamp-for-pyc-files
  74. (lambda _
  75. ;; We set DETERMINISTIC_BUILD to only override the mtime when
  76. ;; building with Guix, lest we break auto-compilation in
  77. ;; environments.
  78. (setenv "DETERMINISTIC_BUILD" "1")
  79. (substitute* "Lib/py_compile.py"
  80. (("source_stats\\['mtime'\\]")
  81. "(1 if 'DETERMINISTIC_BUILD' in os.environ else source_stats['mtime'])"))
  82.  
  83. ;; Use deterministic hashes for strings, bytes, and datetime
  84. ;; objects.
  85. (setenv "PYTHONHASHSEED" "0")
  86.  
  87. ;; Reset mtime when validating bytecode header.
  88. (substitute* "Lib/importlib/_bootstrap_external.py"
  89. (("source_mtime = int\\(source_stats\\['mtime'\\]\\)")
  90. "source_mtime = 1"))
  91. #t))
  92. ;; These tests fail because of our change to the bytecode
  93. ;; validation. They fail because expected exceptions do not get
  94. ;; thrown. This seems to be no problem.
  95. (add-after 'unpack 'disable-broken-bytecode-tests
  96. (lambda _
  97. (substitute* "Lib/test/test_importlib/source/test_file_loader.py"
  98. (("test_bad_marshal")
  99. "disable_test_bad_marshal")
  100. (("test_no_marshal")
  101. "disable_test_no_marshal")
  102. (("test_non_code_marshal")
  103. "disable_test_non_code_marshal"))
  104. #t))
  105. ;; Unset DETERMINISTIC_BUILD to allow for tests that check that
  106. ;; stale pyc files are rebuilt.
  107. (add-before 'check 'allow-non-deterministic-compilation
  108. (lambda _ (unsetenv "DETERMINISTIC_BUILD") #t))
  109. ;; We need to rebuild all pyc files for three different
  110. ;; optimization levels to replace all files that were not built
  111. ;; deterministically.
  112.  
  113. ;; FIXME: Without this phase we have close to 2000 files that
  114. ;; differ across different builds of this package. With this phase
  115. ;; there are about 500 files left that differ.
  116. (add-after 'install 'rebuild-bytecode
  117. (lambda* (#:key outputs #:allow-other-keys)
  118. (setenv "DETERMINISTIC_BUILD" "1")
  119. (let ((out (assoc-ref outputs "out")))
  120. (for-each
  121. (lambda (opt)
  122. (format #t "Compiling with optimization level: ~a\n"
  123. (if (null? opt) "none" (car opt)))
  124. (for-each (lambda (file)
  125. (apply invoke
  126. `(,(string-append out "/bin/python3")
  127. ,@opt
  128. "-m" "compileall"
  129. "-f" ; force rebuild
  130. ;; Don't build lib2to3, because it's Python 2 code.
  131. ;; Also don't build obviously broken test code.
  132. "-x" "(lib2to3|test/bad.*)"
  133. ,file)))
  134. (find-files out "\\.py$")))
  135. (list '() '("-O") '("-OO"))))))))))
  136. (native-search-paths
  137. (list (search-path-specification
  138. (variable "PYTHONPATH")
  139. (files (list (string-append "lib/python"
  140. (version-major+minor version)
  141. "/site-packages")))))))
  142.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement