[PATCH 0/5] Python logic programming packages

  • Done
  • quality assurance status badge
Details
3 participants
  • Ludovic Courtès
  • Maxime Devos
  • Ryan Prior
Owner
unassigned
Submitted by
Ryan Prior
Severity
normal
R
R
Ryan Prior wrote on 27 Sep 2021 04:17
(address . guix-patches@gnu.org)
20210927021752.30671-1-rprior@protonmail.com
Hi Guix! Here's a series of patches for software I use for logic programming in Python.

Ryan Prior (5):
gnu: Add python-multipledispatch.
gnu: Add python-logical-unification.
gnu: Add python-cons.
gnu: Add python-etuples.
gnu: Add python-minikanren.

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

--
2.33.0
R
R
Ryan Prior wrote on 27 Sep 2021 04:20
[PATCH 1/5] gnu: Add python-multipledispatch.
(address . 50836@debbugs.gnu.org)
20210927022011.30839-1-rprior@protonmail.com
* gnu/packages/python-xyz.scm (python-multipledispatch): New variable.
---
gnu/packages/python-xyz.scm | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)

Toggle diff (31 lines)
diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index a34c444a87..c833c95b5a 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -26584,6 +26584,26 @@ objects in the combined source, and how they define or use each other. The
graph can be output for rendering by GraphViz or yEd.")
(license license:gpl2)))

+(define-public python-multipledispatch
+ (package
+ (name "python-multipledispatch")
+ (version "0.6.0")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (pypi-uri "multipledispatch" version))
+ (sha256
+ (base32
+ "1slblghfjg9fdi9zpd7gmrkvfbv20nrdgnrymcnbky8bzm8i9ax7"))))
+ (build-system python-build-system)
+ (propagated-inputs `(("six" ,python-six)))
+ (home-page
+ "http://github.com/mrocklin/multipledispatch/")
+ (synopsis "Multiple dispatch for Python based on pattern matching")
+ (description "This library provides an efficient mechanism for overloading
+function implementations based on the types of the arguments.")
+ (license license:bsd-3)))
+
(define-public date2name
(let ((commit "6c8f37277e8ec82aa50f90b8921422be30c4e798")
(revision "1"))
--
2.33.0
R
R
Ryan Prior wrote on 27 Sep 2021 04:20
[PATCH 2/5] gnu: Add python-logical-unification.
(address . 50836@debbugs.gnu.org)
20210927022011.30839-2-rprior@protonmail.com
gnu/packages/python-xyz.scm (python-logical-unification): New variable.
---
gnu/packages/python-xyz.scm | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)

Toggle diff (33 lines)
diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index c833c95b5a..bc5ab67e6b 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -26604,6 +26604,28 @@ graph can be output for rendering by GraphViz or yEd.")
function implementations based on the types of the arguments.")
(license license:bsd-3)))

+(define-public python-logical-unification
+ (package
+ (name "python-logical-unification")
+ (version "0.4.3")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (pypi-uri "logical-unification" version))
+ (sha256
+ (base32
+ "0j57953hi7kg2rl0163vzjzsvzdyjimnklhx6idf5vaqqf1d3p1j"))))
+ (build-system python-build-system)
+ (propagated-inputs
+ `(("multipledispatch" ,python-multipledispatch)
+ ("toolz" ,python-toolz)))
+ (home-page
+ "http://github.com/pythological/unification/")
+ (synopsis "Logical unification in Python for solving symbolic expressions")
+ (description "This library provides algorithms and data types for solving
+symbolic expressions in pure Python using the technique of logical unification.")
+ (license license:bsd-3)))
+
(define-public date2name
(let ((commit "6c8f37277e8ec82aa50f90b8921422be30c4e798")
(revision "1"))
--
2.33.0
R
R
Ryan Prior wrote on 27 Sep 2021 04:20
[PATCH 4/5] gnu: Add python-etuples.
(address . 50836@debbugs.gnu.org)
20210927022011.30839-4-rprior@protonmail.com
gnu/packages/python-xyz.scm (python-etuples): New variable.
---
gnu/packages/python-xyz.scm | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)

Toggle diff (35 lines)
diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index 1f6388d2bc..0b002c42dc 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -26653,6 +26653,30 @@ symbolic expressions in pure Python using the technique of logical unification."
cons cells in Python.")
(license license:lgpl3+)))

+(define-public python-etuples
+ (package
+ (name "python-etuples")
+ (version "0.3.3")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (pypi-uri "etuples" version))
+ (sha256
+ (base32
+ "0jhfyp177v37rl0i7wqfx7q6s5qkz027hl283d1x8d0vm3w0zqc8"))))
+ (build-system python-build-system)
+ (propagated-inputs
+ `(("python-cons" ,python-cons)
+ ("python-multipledispatch"
+ ,python-multipledispatch)))
+ (home-page
+ "http://github.com/pythological/etuples")
+ (synopsis
+ "S-expressions in Python")
+ (description
+ "This library implements eval'able S-expression in Python using tuple-like objects.")
+ (license license:asl2.0)))
+
(define-public date2name
(let ((commit "6c8f37277e8ec82aa50f90b8921422be30c4e798")
(revision "1"))
--
2.33.0
R
R
Ryan Prior wrote on 27 Sep 2021 04:20
[PATCH 5/5] gnu: Add python-minikanren.
(address . 50836@debbugs.gnu.org)
20210927022011.30839-5-rprior@protonmail.com
gnu/packages/python-xyz.scm (python-minikanren): New variable.
---
gnu/packages/python-xyz.scm | 46 +++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)

Toggle diff (57 lines)
diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index 0b002c42dc..4437de6374 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -26677,6 +26677,52 @@ cons cells in Python.")
"This library implements eval'able S-expression in Python using tuple-like objects.")
(license license:asl2.0)))

+(define-public python-minikanren
+ (package
+ (name "python-minikanren")
+ (version "1.0.1")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/pythological/kanren")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "0g7wfj5hxalwz7k1301nsjqhjpzsif1bj6wjm2x2kavlm2ypv9jc"))))
+ (build-system python-build-system)
+ (arguments
+ '(#:phases (modify-phases %standard-phases
+ (replace 'check
+ (lambda* (#:key tests? #:allow-other-keys)
+ (when tests?
+ (invoke "python" "-m" "pytest" "-v" "tests/" "kanren/"))
+ #t)))))
+ (native-inputs
+ `(("python-coveralls" ,python-coveralls)
+ ("python-pydocstyle" ,python-pydocstyle)
+ ("python-pytest@6.2.4" ,python-pytest)
+ ("python-pytest-cov@2.8.1" ,python-pytest-cov)
+ ("python-pylint@2.5.3" ,python-pylint)
+ ("python-black@20.8b1" ,python-black)
+ ("python-sympy@1.7.1" ,python-sympy)
+ ("python-versioneer@0.19" ,python-versioneer)
+ ("python-coverage@5.2.1" ,python-coverage)
+ ("python-pre-commit@2.10.0" ,python-pre-commit)))
+ (propagated-inputs
+ `(("toolz@0.11.1" ,python-toolz)
+ ("cons" ,python-cons)
+ ("multipledispatch" ,python-multipledispatch)
+ ("etuples" ,python-etuples)
+ ("logical-unification" ,python-logical-unification)))
+ (home-page "https://github.com/pythological/kanren")
+ (synopsis "Relational logic programming in pure Python")
+ (description
+ "The minikanren library provides an algorithmic core for computer algebra
+systems in Python.")
+ (license license:bsd-3)))
+
+
(define-public date2name
(let ((commit "6c8f37277e8ec82aa50f90b8921422be30c4e798")
(revision "1"))
--
2.33.0
R
R
Ryan Prior wrote on 27 Sep 2021 04:20
[PATCH 3/5] gnu: Add python-cons.
(address . 50836@debbugs.gnu.org)
20210927022011.30839-3-rprior@protonmail.com
gnu/packages/python-xyz.scm (python-cons): New variable.
---
gnu/packages/python-xyz.scm | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)

Toggle diff (38 lines)
diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index bc5ab67e6b..1f6388d2bc 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -26626,6 +26626,33 @@ function implementations based on the types of the arguments.")
symbolic expressions in pure Python using the technique of logical unification.")
(license license:bsd-3)))

+(define-public python-cons
+ (package
+ (name "python-cons")
+ (version "0.4.2")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (pypi-uri "cons" version))
+ (sha256
+ (base32
+ "0w9giq196wps7mbm47c4shdzs5yvwvqajqzkim2p92i51sm5qgvm"))))
+ (build-system python-build-system)
+ (native-inputs
+ `(("pytest@6.2.4" ,python-pytest-6)
+ ("toml@0.10.2" ,python-toml)))
+ (propagated-inputs
+ `(("python-logical-unification"
+ ,python-logical-unification)))
+ (home-page
+ "https://github.com/pythological/python-cons")
+ (synopsis
+ "Cons cell data structures and related algorithms for Python")
+ (description
+ "This library implements algorithms and data structures for Lisp-style
+cons cells in Python.")
+ (license license:lgpl3+)))
+
(define-public date2name
(let ((commit "6c8f37277e8ec82aa50f90b8921422be30c4e798")
(revision "1"))
--
2.33.0
M
M
Maxime Devos wrote on 27 Sep 2021 12:28
Re: [bug#50836] [PATCH 1/5] gnu: Add python-multipledispatch.
a7efb45960a63c7c5dbaac0a2c7458d2e4ba9e41.camel@telenet.be
Ryan Prior via Guix-patches via schreef op ma 27-09-2021 om 02:20 [+0000]:
Toggle quote (27 lines)
> * gnu/packages/python-xyz.scm (python-multipledispatch): New variable.
> ---
> gnu/packages/python-xyz.scm | 20 ++++++++++++++++++++
> 1 file changed, 20 insertions(+)
>
> diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
> index a34c444a87..c833c95b5a 100644
> --- a/gnu/packages/python-xyz.scm
> +++ b/gnu/packages/python-xyz.scm
> @@ -26584,6 +26584,26 @@ objects in the combined source, and how they define or use each other. The
> graph can be output for rendering by GraphViz or yEd.")
> (license license:gpl2)))
>
> +(define-public python-multipledispatch
> + (package
> + (name "python-multipledispatch")
> + (version "0.6.0")
> + (source
> + (origin
> + (method url-fetch)
> + (uri (pypi-uri "multipledispatch" version))
> + (sha256
> + (base32
> + "1slblghfjg9fdi9zpd7gmrkvfbv20nrdgnrymcnbky8bzm8i9ax7"))))
> + (build-system python-build-system)
> + (propagated-inputs `(("six" ,python-six)))

The convention is to use the package name of the input package as input
label ("python-six" instead of "six" in this case). This is important for
the "guix style" in https://issues.guix.gnu.org/49169, which, when it will
be in master, allows writing this package definition as

(define-public python-multipledispatch
(package
(name "python-multipledispatch")
...
(propagated-inputs (list python-six))
...))

(The long-term goal appears to be to remove input labels completely.)

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYVGcxxccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7qJ/AP9C6FvXsbNtvjIyGQ6tdEypzcbL
S8xT2wPhCl4bEDkxLwEA5a5oQ2Puffd9KuH4mZAW5rMWMwafTJ0jnmev32rgzw8=
=19Xd
-----END PGP SIGNATURE-----


L
L
Ludovic Courtès wrote on 15 Nov 2021 14:42
Re: bug#50836: [PATCH 0/5] Python logic programming packages
(name . Ryan Prior)(address . rprior@protonmail.com)(address . 50836-done@debbugs.gnu.org)
87a6i55ycw.fsf@gnu.org
Hi,

Ryan Prior <rprior@protonmail.com> skribis:

Toggle quote (6 lines)
> gnu: Add python-multipledispatch.
> gnu: Add python-logical-unification.
> gnu: Add python-cons.
> gnu: Add python-etuples.
> gnu: Add python-minikanren.

I adjusted input labels as Maxime suggested, addressed minor issues
reported by ‘guix lint’, and committed the whole thing.

I didn’t know miniKanren (and ‘cons’ :-)) had been ported to Python,
sweet!

Thanks,
Ludo’.
Closed
?