On Mon, Oct 12, 2020 at 07:43:56PM +0200, Zelphir Kaltstahl wrote: > Hello Julien! > > I think I did not yet reply to your e-mail yet. I put it off to "later" > and now it is much later. Sorry for my late reply and thank you for the > information already provided. > > Meanwhile I have come across another case, where I would like to install > a package from PyPI and where I do not know how to proceed: > > This time I have a more reproducible scenario using channels as well. > > I have a `channels.scm` file: > > ~~~~ > (list (channel > (name 'guix) > (url "https://git.savannah.gnu.org/git/guix.git") > (commit > "29a2eb36ff85eb75eeb907aa687fbb655b5f1097") > (introduction > (make-channel-introduction > "9edb3f66fd807b096b48283debdcddccfea34bad" > (openpgp-fingerprint > "BBB0 2DDF 2CEA F6A8 0D1D E643 A2A0 6DF2 A33A 54FA"))))) > ~~~~ > > A `manifest.scm` file: > > ~~~~ > (specifications->manifest > '("python" > "python-django")) > ~~~~ > > And I have a `django-mptt.scm` file, created using `guix import pypi > --recursive django-mptt` and by adding required imports and expressions > at the bottom for actually returning something, as indicated by comments: > Replying a bit out of order, the error below means it doesn't know what "python-django" is. 'guix package -A python-django' shows that the package definition exists in gnu/packages/django.scm > ~~~~ > ;; add module imports > (use-modules > (guix packages) > (guix download) > (guix build-system python) (gnu packages django) > ((guix licenses) #:prefix license:)) > > (define-public python-django-js-asset > (package > (name "python-django-js-asset") > (version "1.2.2") > (source > (origin > (method url-fetch) > (uri (pypi-uri "django-js-asset" version)) > (sha256 > (base32 > "0q3j2rsdb2i7mvncy9z160cghcggvk87q14qnn7jvcp0sa0awqy1")))) > (build-system python-build-system) > (home-page > "https://github.com/matthiask/django-js-asset/") > (synopsis > "script tag with additional attributes for django.forms.Media") > (description > "script tag with additional attributes for django.forms.Media") > (license license:bsd-3))) > > (define-public python-django-mptt > (package > (name "python-django-mptt") > (version "0.11.0") > (source > (origin > (method url-fetch) > (uri (pypi-uri "django-mptt" version)) > (sha256 > (base32 > "1a4m32yb85bamfpjrg4r1ywz4x21az44wm5hb12dsz6jbbvkmnyz")))) > (build-system python-build-system) > (propagated-inputs > `(("python-django" ,python-django) > ("python-django-js-asset" > ,python-django-js-asset))) > (home-page > "https://github.com/django-mptt/django-mptt") > (synopsis > "Utilities for implementing Modified Preorder Tree Traversal with your Django Models and working with trees of Model instances.") > (description > "Utilities for implementing Modified Preorder Tree Traversal with your Django Models and working with trees of Model instances.") > (license license:expat))) > > ;; add result expression > python-django-mptt > ~~~~ > > Then to make an environment I do the following: > > ~~~~ > guix time-machine --channels=channels.scm -- environment --load=django-mptt.scm --manifest=manifest.scm > ~~~~ > > Which results in: > > ~~~~ > ... (happily downloading and building stuff here) ... > > Backtrace: > 17 (primitive-load "/home/xiaolong/.cache/guix/inferiors/s…") > In guix/ui.scm: > 2115:12 16 (run-guix-command _ . _) > In ice-9/boot-9.scm: > 1736:10 15 (with-exception-handler _ _ #:unwind? _ # _) > 1731:15 14 (with-exception-handler # …) > 1736:10 13 (with-exception-handler _ _ #:unwind? _ # _) > In guix/store.scm: > 631:37 12 (thunk) > 1300:8 11 (call-with-build-handler # …) > In guix/status.scm: > 776:4 10 (call-with-status-report _ _) > In guix/scripts/environment.scm: > 345:4 9 (_) > In srfi/srfi-1.scm: > 673:15 8 (append-map _ _ . _) > 586:29 7 (map1 _) > 586:17 6 (map1 ((load package "django-mptt.scm") (system . "…") …)) > In guix/scripts/environment.scm: > 126:37 5 (packages->outputs # …) > In guix/packages.scm: > 1145:16 4 (package->bag _ _ _ #:graft? _) > 1252:48 3 (thunk) > In /home/xiaolong/dev/guix/guix-package-manager-tutorials/django-example/django-mptt.scm: > 29:2 2 (propagated-inputs _) > In ice-9/boot-9.scm: > 1669:16 1 (raise-exception _ #:continuable? _) > 1669:16 0 (raise-exception _ #:continuable? _) > > ice-9/boot-9.scm:1669:16: In procedure raise-exception: > error: python-django: unbound variable > ~~~~ > > Now this is the point, where I do not know how to continue. It seems I > am quite close to get it working, just that somewhere I need to put > `python-django`. Perhaps I need to add it to `django-mptt.scm` > somewhere? But how would I specify 2 or more "exports" from that file? > > If I try to write a list instead of only a non-compound value at the > bottom of `django-mptt`, as follows: > > ~~~~ > ... (more stuff before this as seen above) ... > > ;; add result expression > '(python-django-mptt python-django) > ~~~~ > > I get the following: > > ~~~~ > Backtrace: > 16 (primitive-load "/home/xiaolong/.cache/guix/inferiors/s…") > In guix/ui.scm: > 2115:12 15 (run-guix-command _ . _) > In ice-9/boot-9.scm: > 1736:10 14 (with-exception-handler _ _ #:unwind? _ # _) > 1731:15 13 (with-exception-handler # …) > 1736:10 12 (with-exception-handler _ _ #:unwind? _ # _) > In guix/store.scm: > 631:37 11 (thunk) > 1300:8 10 (call-with-build-handler # …) > In guix/status.scm: > 776:4 9 (call-with-status-report _ _) > In guix/scripts/environment.scm: > 345:4 8 (_) > In srfi/srfi-1.scm: > 673:15 7 (append-map _ _ . _) > 586:29 6 (map1 _) > 586:17 5 (map1 ((load package "django-mptt.scm") (system . "…") …)) > 673:15 4 (append-map # …) > 586:17 3 (map1 (python-django-mptt python-django)) > In guix/scripts/environment.scm: > 331:4 2 (packages->outputs _ _) > In ice-9/boot-9.scm: > 1669:16 1 (raise-exception _ #:continuable? _) > 1669:16 0 (raise-exception _ #:continuable? _) > > ice-9/boot-9.scm:1669:16: In procedure raise-exception: > Throw to key `match-error' with args `("match" "no matching pattern" python-django-mptt)'. > ~~~~ > > How do I get this working? > > Best regards, > Zelphir > > On 7/17/20 12:27 AM, Julien Lepiller wrote: > > Le Fri, 17 Jul 2020 00:10:36 +0200, > > Zelphir Kaltstahl a écrit : > > > >> Hello Guix Users! > >> > >> I read on > >> https://guix.gnu.org/manual/en/html_node/Invoking-guix-import.html: > >> > >> "The guix import command is useful for people who would like to add a > >> package to the distribution with as little work as possible—a > >> legitimate demand. The command knows of a few repositories from which > >> it can “import” package metadata. The result is a package definition, > >> or a template thereof, in the format we know (see Defining Packages)." > >> > >> I've recently tried this, for example for MyPy: > >> > >> ~~~~ > >> guix import pypi -r mypy > >> ~~~~ > >> > >> This will result in Guile code printed to my terminal. However, I do > >> not understand how to make use of that code. I do not understand how > >> I can load it. For example I tried using the -l argument with guix > >> environment: > >> > >> ~~~~ > >> guix import pypi -r mypy > additional_file.scm > >> guix environment --pure --load=additional_file.scm --ad-hoc > >> python@3.8.2 /home/user/dev/Python/additional_file.scm:2:2: error: > >> package: unbound variable hint: Did you forget `(use-modules (guix > >> packages))'? ~~~~ > >> > >> So that seems to be the wrong way of trying to make use of it. > >> > >> Do I need to provide a patch to the project of the Guix package > >> manager to add this to Guix packages in general and then be able to > >> use it in my local setup? > >> > >> I do not find the info, how I can now use MyPy inside an environment > >> or add it to the available packages on any of the following pages: > >> > >> - > >> https://guix.gnu.org/manual/en/html_node/Python-Modules.html#Python-Modules > >> > >> - https://guix.gnu.org/manual/en/html_node/Invoking-guix-import.html > >> > >> While https://guix.gnu.org/manual/en/html_node/Submitting-Patches.html > >> makes me think, that perhaps I need to submit it as patch to be able > >> to use MyPy. > >> > >> If so, how would I test, whether guix import did its thing correctly? > >> I could try running MyPy in an environment, but for that I would have > >> to somehow make use of what guix import gives me, before submitting a > >> patch. > >> > >> Also, if I need to submit a patch adding the guix import output > >> somewhere, is there a guide on how to create such a patch for the Guix > >> project? > >> > >> Regards, > >> Zelphir > >> > > Hi zelphir, > > > > You don't need to send a patch, although it would be very welcome. You > > should read > > https://guix.gnu.org/manual/devel/en/html_node/Defining-Packages.html > > where you can learn about package modules and how to import missing > > modules that cause the issue you are having. Basically, you need a > > header such as > > > > (use-modules (gnu) (guix packages)) > > etc... > > > > Then, you'll have to make sure your file returns something: guix import > > -r will return you a code that defines one or more variables, but > > nothing is returned. If you don't do anything, after adding the > > required headers, you'll simply see an error about #. > > > > Put the name of the package you want to build in its own line at the > > very end of the file, like: > > > > pyhon-mypyt > > > > > > this will ensure the value associated with that variable is returned > > from the file, and you will be able to load the file with guix > > environment -l or guix build -f. > > > > HTH! > > -- > repositories: https://notabug.org/ZelphirKaltstahl > -- Efraim Flashner אפרים פלשנר GPG key = A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351 Confidentiality cannot be guaranteed on emails sent or received unencrypted