guix-env.scm 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. ;;; GNU MediaGoblin -- federated, autonomous media hosting
  2. ;;; Copyright © 2015, 2016 David Thompson <davet@gnu.org>
  3. ;;; Copyright © 2016 Christopher Allan Webber <cwebber@dustycloud.org>
  4. ;;; Copyright © 2019 Ben Sturmfels <ben@sturm.com.au>
  5. ;;;
  6. ;;; This program is free software: you can redistribute it and/or modify
  7. ;;; it under the terms of the GNU General Public License as published by
  8. ;;; the Free Software Foundation, either version 3 of the License, or
  9. ;;; (at your option) any later version.
  10. ;;;
  11. ;;; This program is distributed in the hope that it will be useful,
  12. ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. ;;; GNU General Public License for more details.
  15. ;;;
  16. ;;; ========================================
  17. ;;;
  18. ;;; ... This file is also part of GNU MediaGoblin, but we're leaving it
  19. ;;; under GPLv3 for easy merge back and forth between Guix proper. It
  20. ;;; also borrows some code directly from Guix.
  21. ;;;
  22. ;;; ========================================
  23. ;;;
  24. ;;; With `guix environment' you can use guix as kind of a universal
  25. ;;; virtualenv, except a universal virtualenv with magical time traveling
  26. ;;; properties and also, not just for Python.
  27. ;;;
  28. ;;; Ok, here's how to use this thing! First, install Guix.
  29. ;;; Then do:
  30. ;;; guix environment -l guix-env.scm --pure
  31. ;;;
  32. ;;; While using --pure is a robust way to ensure that other environment
  33. ;;; variables don't cause unexpected behaviour, it may trip up aspects of your
  34. ;;; development tools, such as removing reference to $EDITOR. Feel free to
  35. ;;; remove the --pure.
  36. ;;;
  37. ;;; You'll need to run the above command every time you close your terminal or
  38. ;;; restart your system, so a handy way to save having to remember is to install
  39. ;;; "direnv" an then create a ".envrc" file in your current directory containing
  40. ;;; the following and then run "direnv allow" when prompted:
  41. ;;; use guix -l guix-env.scm
  42. ;;;
  43. ;;; To set things up for the first time, you'll also need to run:
  44. ;;; git submodule init
  45. ;;; git submodule update
  46. ;;; ./bootstrap.sh
  47. ;;; ./configure --with-python3 --without-virtualenv
  48. ;;; make
  49. ;;; python3 -m venv --system-site-packages . && bin/python setup.py develop --no-deps
  50. ;;; bin/python -m pip install --force-reinstall PasteScript # workaround
  51. ;;; bin/python -m pip install 'werkzeug<1.0.0' # workaround (also disabled below)
  52. ;;; bin/python -m pip install 'email-validator' # email-validator
  53. ;;;
  54. ;;; ... wait whaaat, what's that venv line?! I thought you said this
  55. ;;; was a reasonable virtualenv replacement! Well it is and it will
  56. ;;; be, but there's a catch, and the catch is that Guix doesn't know
  57. ;;; about this directory and "setup.py dist" is technically necessary
  58. ;;; for certain things to run, so we have a virtualenv with nothing
  59. ;;; in it but this project itself.
  60. ;;;
  61. ;;; The devtools/update_extlib.sh script won't run on Guix due to missing
  62. ;;; "/usr/bin/env", so then run:
  63. ;;; node node_modules/.bin/bower install
  64. ;;; ./devtools/update_extlib.sh
  65. ;;; bin/gmg dbupdate
  66. ;;; bin/gmg adduser --username admin --password a --email admin@example.com
  67. ;;; ./lazyserver.sh <-- won't work
  68. ;;; CELERY_ALWAYS_EAGER=true ./bin/paster serve paste.ini --reload
  69. ;;;
  70. ;;; WORKAROUND: I have an incompatible newer Werkzeug installed in my profile,
  71. ;;; so to run MediaGoblin I need to:
  72. ;;;
  73. ;;; PYTHONPATH=lib/python3.8/site-packages:$PYTHONPATH CELERY_ALWAYS_EAGER=true ./bin/paster serve paste-vanilla.ini --reload
  74. ;;;
  75. ;;; So anyway, now you can do:
  76. ;;; PYTHONPATH="${PYTHONPATH}:$(pwd)" ./runtests.sh
  77. ;;; or:
  78. ;;; bin/python -m pytest ./mediagoblin/tests --boxed
  79. ;;;
  80. ;;; Now notably this is goofier looking than running a virtualenv,
  81. ;;; but soon I'll do something truly evil (I hope) that will make
  82. ;;; the virtualenv and path-hacking stuff unnecessary.
  83. ;;;
  84. ;;; Have fun!
  85. ;;;
  86. ;;; Known issues:
  87. ;;; - currently fails to upload h264 source video: "GStreamer: missing H.264 decoder"
  88. ;;
  89. ;; TODO: Add PDF support.
  90. (use-modules (ice-9 match)
  91. (srfi srfi-1)
  92. (guix packages)
  93. (guix licenses)
  94. (guix download)
  95. (guix git-download)
  96. (guix build-system gnu)
  97. (guix build-system python)
  98. (gnu packages)
  99. (gnu packages autotools)
  100. (gnu packages base)
  101. (gnu packages certs)
  102. (gnu packages check)
  103. (gnu packages databases)
  104. (gnu packages python)
  105. (gnu packages python-crypto)
  106. (gnu packages python-web)
  107. (gnu packages python-xyz)
  108. (gnu packages sphinx)
  109. (gnu packages gstreamer)
  110. (gnu packages glib)
  111. (gnu packages rsync)
  112. (gnu packages ssh)
  113. (gnu packages time)
  114. (gnu packages video)
  115. (gnu packages version-control)
  116. (gnu packages xml)
  117. ((guix licenses) #:select (expat zlib) #:prefix license:))
  118. ;; =================================================================
  119. ;; These packages are on their way into Guix proper but haven't made
  120. ;; it in yet... or they're old versions of packages we're pinning
  121. ;; ourselves to...
  122. ;; =================================================================
  123. (define python-pytest-forked
  124. (package
  125. (name "python-pytest-forked")
  126. (version "1.0.2")
  127. (source
  128. (origin
  129. (method url-fetch)
  130. (uri (pypi-uri "pytest-forked" version))
  131. (sha256
  132. (base32
  133. "0f4y1jhcg70xhm220pdb8r24n01knhn749aqlr14vmgbsb7allnk"))))
  134. (build-system python-build-system)
  135. (propagated-inputs
  136. `(("python-pytest" ,python-pytest)
  137. ("python-setuptools-scm" ,python-setuptools-scm)))
  138. (home-page
  139. "https://github.com/pytest-dev/pytest-forked")
  140. (synopsis
  141. "run tests in isolated forked subprocesses")
  142. (description
  143. "run tests in isolated forked subprocesses")
  144. (license license:expat)))
  145. ;; =================================================================
  146. (define mediagoblin
  147. (package
  148. (name "mediagoblin")
  149. (version "0.8.1")
  150. (source
  151. (origin
  152. (method url-fetch)
  153. (uri (pypi-uri "mediagoblin" version))
  154. (sha256
  155. (base32
  156. "0p2gj4z351166d1zqmmd8wc9bzb69w0fjm8qq1fs8dw2yhcg2wwv"))))
  157. (build-system python-build-system)
  158. (arguments
  159. ;; Complains about missing gunicorn. Not sure where that comes from.
  160. '(#:tests? #f))
  161. (native-inputs
  162. `(("python-pytest" ,python-pytest)
  163. ("nss-certs" ,nss-certs)))
  164. (propagated-inputs
  165. `(("python-alembic" ,python-alembic)
  166. ("python-pytest-xdist" ,python-pytest-xdist)
  167. ("python-pytest-forked" ,python-pytest-forked)
  168. ("python-celery" ,python-celery)
  169. ("python-kombu" ,python-kombu)
  170. ("python-webtest" ,python-webtest)
  171. ("python-pastedeploy" ,python-pastedeploy)
  172. ("python-paste" ,python-paste)
  173. ("python-pastescript" ,python-pastescript)
  174. ("python-translitcodec" ,python-translitcodec)
  175. ("python-babel" ,python-babel)
  176. ("python-configobj" ,python-configobj)
  177. ("python-dateutil" ,python-dateutil)
  178. ("python-itsdangerous" ,python-itsdangerous)
  179. ("python-jinja2" ,python-jinja2)
  180. ("python-jsonschema" ,python-jsonschema)
  181. ("python-lxml" ,python-lxml)
  182. ("python-markdown" ,python-markdown)
  183. ("python-oauthlib" ,python-oauthlib)
  184. ("python-pillow" ,python-pillow)
  185. ("python-py-bcrypt" ,python-py-bcrypt)
  186. ("python-pyld" ,python-pyld)
  187. ("python-pytz" ,python-pytz)
  188. ("python-requests" ,python-requests)
  189. ("python-setuptools" ,python-setuptools)
  190. ("python-six" ,python-six)
  191. ("python-sphinx" ,python-sphinx)
  192. ("python-docutils" ,python-docutils)
  193. ("python-sqlalchemy" ,python-sqlalchemy)
  194. ("python-unidecode" ,python-unidecode)
  195. ;; ("python-werkzeug" ,python-werkzeug) ; Broken due to missing werkzeug.contrib.atom in 1.0.0.
  196. ("python-exif-read" ,python-exif-read)
  197. ("python-wtforms" ,python-wtforms)))
  198. (home-page "http://mediagoblin.org/")
  199. (synopsis "Web application for media publishing")
  200. (description "MediaGoblin is a web application for publishing all kinds of
  201. media.")
  202. (license agpl3+)))
  203. (package
  204. (inherit mediagoblin)
  205. (name "mediagoblin-hackenv")
  206. (version "git")
  207. (inputs
  208. `(;;; audio/video stuff
  209. ("openh264" ,openh264)
  210. ("gstreamer" ,gstreamer)
  211. ("gst-libav" ,gst-plugins-base)
  212. ("gst-plugins-base" ,gst-plugins-base)
  213. ("gst-plugins-good" ,gst-plugins-good)
  214. ("gst-plugins-bad" ,gst-plugins-bad)
  215. ("gst-plugins-ugly" ,gst-plugins-ugly)
  216. ("gobject-introspection" ,gobject-introspection)
  217. ;; useful to have!
  218. ("coreutils" ,coreutils)
  219. ;; used by runtests.sh!
  220. ("which" ,which)
  221. ("git" ,git)
  222. ("automake" ,automake)
  223. ("autoconf" ,autoconf)
  224. ,@(package-inputs mediagoblin)))
  225. (propagated-inputs
  226. `(("python" ,python)
  227. ("python-virtualenv" ,python-virtualenv)
  228. ("python-pygobject" ,python-pygobject)
  229. ("python-gst" ,python-gst)
  230. ;; Needs python-gst in order for all tests to pass
  231. ("python-numpy" ,python-numpy) ; this pulls in texlive...
  232. ; and texlive-texmf is very large...
  233. ("python-chardet", python-chardet)
  234. ("python-psycopg2" ,python-psycopg2)
  235. ;; For developing
  236. ("openssh" ,openssh)
  237. ("git" ,git)
  238. ("rsync" ,rsync)
  239. ,@(package-propagated-inputs mediagoblin))))