Subject: Re: ‘guix import pypi’misses package dependencies

From: Leo Prikler <[email-masked]>
Date: Tue, 22 Jun 2021 10:34:26 +0200

Am Dienstag, den 22.06.2021, 09:20 +0200 schrieb Ludovic Courtès:
> Hi!
> 
> ‘guix import pypi -r django-import-export’ does not include all the
> inputs:
> 
> --8<---------------cut here---------------start------------->8---
> $ guix build -L /tmp/mods python-django-import-export
> 
> [...]
> 
> starting phase `build'
> running "python setup.py" with command "build" and parameters ()
> Download error on https://pypi.org/simple/setuptools_scm/: [Errno -2]
> Name or service not known -- Some packages may not be found!
> Download error on https://pypi.org/simple/setuptools-scm/: [Errno -2]
> Name or service not known -- Some packages may not be found!
> Couldn't find index page for 'setuptools_scm' (maybe misspelled?)
> Download error on https://pypi.org/simple/: [Errno -2] Name or
> service not known -- Some packages may not be found!
> No local packages or working download links found for setuptools_scm
> Traceback (most recent call last):
>   File "<string>", line 1, in <module>
>   File "setup.py", line 5, in <module>
>     setup(
>   File "/gnu/store/9w9jvy3bgjg4qaqmrij01nbppiccqr7c-python-
> 3.8.2/lib/python3.8/site-packages/setuptools/__init__.py", line 144,
> in setup
>     _install_setup_requires(attrs)
>   File "/gnu/store/9w9jvy3bgjg4qaqmrij01nbppiccqr7c-python-
> 3.8.2/lib/python3.8/site-packages/setuptools/__init__.py", line 139,
> in _install_setup_requires
>     dist.fetch_build_eggs(dist.setup_requires)
>   File "/gnu/store/9w9jvy3bgjg4qaqmrij01nbppiccqr7c-python-
> 3.8.2/lib/python3.8/site-packages/setuptools/dist.py", line 716, in
> fetch_build_eggs
>     resolved_dists = pkg_resources.working_set.resolve(
>   File "/gnu/store/9w9jvy3bgjg4qaqmrij01nbppiccqr7c-python-
> 3.8.2/lib/python3.8/site-packages/pkg_resources/__init__.py", line
> 780, in resolve
>     dist = best[req.key] = env.best_match(
>   File "/gnu/store/9w9jvy3bgjg4qaqmrij01nbppiccqr7c-python-
> 3.8.2/lib/python3.8/site-packages/pkg_resources/__init__.py", line
> 1065, in best_match
>     return self.obtain(req, installer)
>   File "/gnu/store/9w9jvy3bgjg4qaqmrij01nbppiccqr7c-python-
> 3.8.2/lib/python3.8/site-packages/pkg_resources/__init__.py", line
> 1077, in obtain
>     return installer(requirement)
>   File "/gnu/store/9w9jvy3bgjg4qaqmrij01nbppiccqr7c-python-
> 3.8.2/lib/python3.8/site-packages/setuptools/dist.py", line 786, in
> fetch_build_egg
>     return cmd.easy_install(req)
>   File "/gnu/store/9w9jvy3bgjg4qaqmrij01nbppiccqr7c-python-
> 3.8.2/lib/python3.8/site-
> packages/setuptools/command/easy_install.py", line 673, in
> easy_install
>     raise DistutilsError(msg)
> distutils.errors.DistutilsError: Could not find suitable distribution
> for Requirement.parse('setuptools_scm')
> command "python" "-c" "import setuptools,
> tokenize;__file__='setup.py';f=getattr(tokenize, 'open',
> open)(__file__);code=f.read().replace('\\r\\n',
> '\\n');f.close();exec(compile(code, __file__, 'exec'))" "build"
> failed with status 1
> builder for `/gnu/store/74ph75dfy1i9hrx9n327j32ma2zv4hhd-python-
> tablib-3.0.0.drv' failed with exit code 1
> build of /gnu/store/74ph75dfy1i9hrx9n327j32ma2zv4hhd-python-tablib-
> 3.0.0.drv failed
> View build log at
> '/var/log/guix/drvs/74/ph75dfy1i9hrx9n327j32ma2zv4hhd-python-tablib-
> 3.0.0.drv.bz2'.
> cannot build derivation `/gnu/store/6xk0jk0qnjsazqgjihmpafsx3wfmxjf0-
> python-django-import-export-2.5.0.drv': 1 dependencies couldn't be
> built
> guix build: error: build of
> `/gnu/store/6xk0jk0qnjsazqgjihmpafsx3wfmxjf0-python-django-import-
> export-2.5.0.drv' failed
> $ cat /tmp/mods/django.scm
> (define-module (django)
>   #:use-module (guix)
>   #:use-module (guix build-system python)
>   #:use-module (gnu packages python)
>   #:use-module (gnu packages python-xyz)
>   #:use-module (gnu packages django)
>   #:use-module ((guix licenses) #:prefix license:))
> 
> (define-public python-tablib
>   (package
>     (name "python-tablib")
>     (version "3.0.0")
>     (source
>       (origin
>         (method url-fetch)
>         (uri (pypi-uri "tablib" version))
>         (sha256
>           (base32
>             "03f1z6jq6rf67gwhbm9ma4rydm8h447a5nh5lcs5l8jg8l4aqg7q")))
> )
>     (build-system python-build-system)
>     (home-page "https://tablib.readthedocs.io")
>     (synopsis
>       "Format agnostic tabular data library (XLS, JSON, YAML, CSV)")
>     (description
>       "Format agnostic tabular data library (XLS, JSON, YAML, CSV)")
>     (license license:expat)))
> 
> (define-public python-django-import-export
>   (package
>     (name "python-django-import-export")
>     (version "2.5.0")
>     (source
>       (origin
>         (method url-fetch)
>         (uri (pypi-uri "django-import-export" version))
>         (sha256
>           (base32
>             "0j0gsj18bkkmbn262qj2syla80vncvqn49bllwxvcgw0zhxh1763")))
> )
>     (build-system python-build-system)
>     (propagated-inputs
>       `(("python-diff-match-patch"
>          ,python-diff-match-patch)
>         ("python-django" ,python-django)
>         ("python-tablib" ,python-tablib)))
>     (home-page
>       "https://github.com/django-import-export/django-import-export")
>     (synopsis
>       "Django application and library for importing and exporting
> data with included admin integration.")
>     (description
>       "Django application and library for importing and exporting
> data with included admin integration.")
>     (license license:bsd-3)))
> 
> --8<---------------cut here---------------end--------------->8---
> 
> Here, some of tablib’s dependencies are missing; the same problem
> seems
> to happen with python-django-import-export itself.
> 
> Are we failing to parse some of the PyPI metadata?
I don't think so, rather it appears as though the requires.txt is
somehow malformed or ill-suited for importing.  It basically marks all
inputs as optional.

Perhaps we could instruct the importer to emit comments for optional
inputs like so
;; Optional inputs by section
;; -- [SECTION]
;; ("python-some-package" ,python-some-package)
;; ("python-some-other-package" ,python-some-other-package) 
Maybe add a command line switch to toggle these comments or a way of
assuming some section, e.g. [cli] to be the thing we want to build for
a package.

Regards,
Leo