diff mbox series

[bug#35598,v2] gnu: Add python-mesa.

Message ID ba771d68c45543fbd8c65e9bba7a012f85bd2fc2.1685308811.git.jlicht@fsfe.org
State New
Headers show
Series [bug#35598,v2] gnu: Add python-mesa. | expand

Commit Message

Jelle Licht May 28, 2023, 9:21 p.m. UTC
From: Calvin Pritchard <calvin.pritchard@asu.edu>

* gnu/packages/python-xyz.scm (python-mesa). New variable.

Co-authored-by: Jelle Licht <jlicht@fsfe.net>

---

Changes in v2:
- Drop all dependency patches, as those packages now exist
- Use pyproject-build-system
- Reworked to modern packaging standards
- Update mesage package version to 1.2.1.

 gnu/packages/python-xyz.scm | 63 +++++++++++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)


base-commit: 9845e408e533f5834a13f294ca1ddc1dc7e248fd
diff mbox series

Patch

diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index f7e3f6f538..be89df2fa1 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -2305,6 +2305,69 @@  (define-public python-license-expression
 conventions and aliases in the same expression.")
     (license license:gpl2+)))
 
+(define-public python-mesa
+  (package
+    (name "python-mesa")
+    (version "1.2.1")
+    (source (origin
+              (method url-fetch)
+              (uri (pypi-uri "Mesa" version))
+              (sha256
+               (base32
+                "01504d2bgfwsg92942k34fi7adq5n9r1fw4sn5kx0sm70jwq1628"))))
+    (build-system pyproject-build-system)
+    (arguments
+     (list
+      #:modules '((guix build pyproject-build-system)
+                  (guix build utils)
+                  (ice-9 match)
+                  (srfi srfi-1))
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'unpack 'patch-cookiecutter
+            (lambda* (#:key inputs #:allow-other-keys)
+              (substitute* "mesa/main.py"
+                (("\"cookiecutter\"")
+                 (string-append "\""
+                                (search-input-file inputs "/bin/cookiecutter")
+                                "\"")))))
+          (add-after 'build 'set-HOME
+            ;;  Some tests write to $HOME.
+            (lambda _ (setenv "HOME" "/tmp")))
+          (replace 'compile-bytecode
+            (lambda* (#:key inputs outputs #:allow-other-keys)
+              (let* ((site-dir (site-packages inputs outputs))
+                     (python (assoc-ref inputs "python"))
+                     (major-minor (map string->number
+                                       (take (string-split (python-version python)
+                                                           #\.)
+                                             2)))
+                     (<3.7? (match major-minor
+                              ((major minor)
+                               (or (< major 3)
+                                   (and (= major 3)
+                                        (< minor 7)))))))
+                (unless <3.7?
+                  ;; The cookiecutter-mesa directory contains project templates that
+                  ;; should not be compiled.
+                  (invoke "python" "-m" "compileall"
+                          "-x" "cookiecutter-mesa"
+                          "--invalidation-mode=unchecked-hash" site-dir))))))))
+    (propagated-inputs (list python-click
+                             python-networkx
+                             python-numpy
+                             python-pandas
+                             python-tornado
+                             python-tqdm))
+    (inputs (list python-cookiecutter))
+    (native-inputs (list python-coverage python-pytest python-pytest-cov))
+    (home-page "https://github.com/projectmesa/mesa")
+    (synopsis "Agent-based modeling (ABM) in Python")
+    (description "Mesa is an agent-based modeling framework in Python.  It contains
+core components to implement spatial models, schedule agents and visualize model
+runs.")
+    (license license:asl2.0)))
+
 (define-public python-wand
   (package
     (name "python-wand")