import: pypi: Honor the 'upstream-name' package property.
authorXinglu Chen <public@yoctocell.xyz>
Mon, 27 Sep 2021 20:11:20 +0000 (22:11 +0200)
committerLudovic Courtès <ludo@gnu.org>
Thu, 30 Sep 2021 21:44:49 +0000 (23:44 +0200)
commit7b75f90c5b0da896c486cae23d19d43e2a03bb56
tree0e663a0bc9765fb84b68e3e3c20349244771da97
parente29c3e1856b8d05cf98d652207df981ae7197d3a
import: pypi: Honor the 'upstream-name' package property.

Previously, when a PyPI package had a “-” followed by one or more digits in
its name, e.g., “AV-98”, the importer would interpret “98” as the version of
the package and thus mistake the “AV-98” package for the “av” package on PyPI.

  $ ./pre-inst-env guix refresh av-98
  following redirection to `https://pypi.org/pypi/av/json'...
  /home/yoctocell/src/guix/gnu/packages/web-browsers.scm:914:13: av-98 would be upgraded from 1.0.1 to 8.0.3

Setting the ‘upstream-name’ property to “AV-98” would solve the problem.

  $ ./pre-inst-env guix refresh av-98
  /home/yoctocell/src/guix/gnu/packages/web-browsers.scm:914:13: 1.0.1 is already the latest version of av-98

* guix/import/pypi.scm (guix-package->pypi-name): Honor ‘upstream-name’
property.
(make-pypi-sexp): Set ‘upstream-name’ property when appropriate.
* tests/pypi.scm (test-json): Rename to ...
(test-json-1): ... this.
(test-json-2): New variable
("guix-package->pypi-name, honor 'upstream-name'"): New test.
("pypi->guix-package, package name contains \"-\" followed by digits"):
Likewise.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
guix/import/pypi.scm
tests/pypi.scm