diff mbox series

[bug#68147] gnu: Add python-snappy.

Message ID 87mstr3gac.fsf@troyfigiel.com
State New
Headers show
Series [bug#68147] gnu: Add python-snappy. | expand

Commit Message

Troy Figiel Dec. 30, 2023, 1:46 p.m. UTC
* gnu/packages/python-compression.scm (python-snappy): New variable.

Change-Id: I0142f49745104db8458c0becf222eb4088c9ee58
---
 gnu/packages/python-compression.scm | 31 +++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)


base-commit: f24b14767d362a84e6469682b4fe303b50f4b589

Comments

Troy Figiel Dec. 30, 2023, 2:51 p.m. UTC | #1
Interestingly, both `python-snappy' and `snappy' are available on PyPI
(https://pypi.org/project/snappy/). These are two completely distinct
packages and in this issue I only package `python-snappy'.

If I understand the Python naming rules, if someone were to package
`snappy' in the future, both would be associated to the `python-snappy'
variable in Guix. What would be the best approach to handle this
potential naming collision?

Best wishes,

Troy
Tomas Volf Dec. 30, 2023, 5:21 p.m. UTC | #2
On 2023-12-30 15:51:29 +0100, Troy Figiel wrote:
> Interestingly, both `python-snappy' and `snappy' are available on PyPI
> (https://pypi.org/project/snappy/). These are two completely distinct
> packages and in this issue I only package `python-snappy'.
>
> If I understand the Python naming rules, if someone were to package
> `snappy' in the future, both would be associated to the `python-snappy'
> variable in Guix. What would be the best approach to handle this
> potential naming collision?

As far as I can tell, names of PyPI packages in guix are basically formed by
adding `python-' prefix to the PyPI name.  So here the correct name would be
`python-python-snappy'.  I agree that it looks... weird, however it does prevent
the collision.

It will prevent any user confusion, while adhering to a pattern that is already
elsewhere, so I think it is worth it.

Have a nice day,
Tomas Volf

--
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.
Troy Figiel Jan. 6, 2024, 3:38 p.m. UTC | #3
Hi Tomas,

I like your approach, I was thinking in the same direction. Having a
slightly more convoluted name would be preferable over having to change
the API later on.

I will submit a new patch with a comment regarding its name. Snappy
seems to be a desired namespace :)

Best wishes,

Troy

Tomas Volf <~@wolfsden.cz> writes:

> On 2023-12-30 15:51:29 +0100, Troy Figiel wrote:
>> Interestingly, both `python-snappy' and `snappy' are available on PyPI
>> (https://pypi.org/project/snappy/). These are two completely distinct
>> packages and in this issue I only package `python-snappy'.
>>
>> If I understand the Python naming rules, if someone were to package
>> `snappy' in the future, both would be associated to the `python-snappy'
>> variable in Guix. What would be the best approach to handle this
>> potential naming collision?
>
> As far as I can tell, names of PyPI packages in guix are basically formed by
> adding `python-' prefix to the PyPI name.  So here the correct name would be
> `python-python-snappy'.  I agree that it looks... weird, however it does prevent
> the collision.
>
> It will prevent any user confusion, while adhering to a pattern that is already
> elsewhere, so I think it is worth it.
>
> Have a nice day,
> Tomas Volf
>
> --
> There are only two hard things in Computer Science:
> cache invalidation, naming things and off-by-one errors.
>
<#secure method=pgpmime mode=sign>
diff mbox series

Patch

diff --git a/gnu/packages/python-compression.scm b/gnu/packages/python-compression.scm
index bc96bc05d3..364f741392 100644
--- a/gnu/packages/python-compression.scm
+++ b/gnu/packages/python-compression.scm
@@ -7,6 +7,7 @@ 
 ;;; Copyright © 2020 Nicolas Goaziou <mail@nicolasgoaziou.fr>
 ;;; Copyright © 2020, 2022, 2023 Marius Bakke <marius@gnu.org>
 ;;; Copyright © 2021 Brendan Tildesley <mail@brendan.scot>
+;;; Copyright © 2023 Troy Figiel <troy@troyfigiel.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -416,6 +417,36 @@  (define-public python-lzstring
     (description "Lz-string is a string compressor library for Python.")
     (license license:expat)))
 
+(define-public python-snappy
+  (package
+    (name "python-snappy")
+    (version "0.6.1")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (pypi-uri "python-snappy" version))
+       (sha256
+        (base32 "0amv12w0ybn6n1lk36x70a3l8bdjv4mn7iflb59wqsi00smhg8dn"))))
+    (build-system python-build-system)
+    (arguments
+     '(#:phases (modify-phases %standard-phases
+                  (replace 'check
+                    (lambda* (#:key tests? #:allow-other-keys)
+                      (when tests?
+                        (invoke "pytest" "-vv" "-k"
+                                ;; CFFI is only supported for PyPy builds.
+                                (string-append "not test_snappy_cffi_enum "
+                                               "and not test_snappy_all_cffi"))))))))
+    (inputs (list snappy))
+    (native-inputs (list python-pytest))
+    (home-page "https://github.com/andrix/python-snappy")
+    (synopsis "Python bindings for the Snappy compression library")
+    (description
+     "@code{python-snappy} provides bindings to the Snappy library
+and can be used to compress and decompress files and streams.  It can also be
+used directly from the command line.")
+    (license license:bsd-3)))
+
 (define-public bitshuffle
   (package
     (name "bitshuffle")