all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alexis Simon <alexis.simon@runbox.com>
To: help-guix <help-guix@gnu.org>
Subject: Re: Python package with some rust dependency
Date: Fri, 16 Feb 2024 16:02:45 -0800	[thread overview]
Message-ID: <f5bf57b4-fbc3-4763-a88c-2f44f77439cb@runbox.com> (raw)
In-Reply-To: <a21652ad-69cf-4271-9953-1405ddc97c94@runbox.com>

[-- Attachment #1: Type: text/plain, Size: 3702 bytes --]

Hi,

So I think I'm nearly there (part of the scm attached).

The last thing I'd like to do is run the python tests inside the 
cargo-build-system but couldn't find an example of it. I don't 
understand how to do that.

I get the following error, which is most probably me not knowing how to 
write scheme.
```
error: in phase 'check-python-module': uncaught exception:
wrong-type-arg "apply" "Apply to non-list: ~S" (#f) (#f)
phase `check-python-module' failed after 0.0 seconds
Backtrace:
            8 (primitive-load "/gnu/store/c2v51hzvlji63jbh0jwn5dbz10j…")
In guix/build/gnu-build-system.scm:
     908:2  7 (gnu-build #:source _ #:outputs _ #:inputs _ #:phases . #)
In ice-9/boot-9.scm:
   1752:10  6 (with-exception-handler _ _ #:unwind? _ # _)
In srfi/srfi-1.scm:
     634:9  5 (for-each #<procedure 7ffff5f29c20 at guix/build/gnu-b…> …)
In ice-9/boot-9.scm:
   1752:10  4 (with-exception-handler _ _ #:unwind? _ # _)
In guix/build/gnu-build-system.scm:
    929:23  3 (_)
In unknown file:
            2 (_ "/gnu/store/qzx9n7452cw0w11c96gvijdnmk6v82m2-python…" …)
In ice-9/boot-9.scm:
   1685:16  1 (raise-exception _ #:continuable? _)
   1685:16  0 (raise-exception _ #:continuable? _)

ice-9/boot-9.scm:1685:16: In procedure raise-exception:
In procedure apply: Apply to non-list: #f
```

Thanks
Alexis


On 15/02/2024 22:08, Alexis Simon wrote:
> Hi,
> 
> So right now I'm trying to go the splitting in two packages way, similar 
> to what is done for python-cryptography.
> 
> So I managed to build the first one that produces a header file in the 
> store /gnu/store/*/lib/header.h
> 
> In the second package, I don't get how to copy this file inside the 
> build. I've been trying something like this:
> ```
>      (native-inputs (list python-fwdpy11-rust-lib))
>      (arguments
>        (list
>          #:phases
>          #~(modify-phases %standard-phases
>              (add-before 'build 'copy-rust-lib
>                 (lambda* (#:key native-inputs #:allow-other-keys)
>                   (copy-file (search-input-file
>                             native-inputs "lib/fp11rust_api.h")
>                            "lib/core/internal/fp11rust_api.h"))))))
> ```
> Which complains there is no match, because it seams the package store 
> path is not present in the native-inputs, although I specify it in the 
> package.
> 
> Thanks,
> Alexis
> 
> On 13/02/2024 13:55, Alexis Simon wrote:
>> Fair enough, I just meant that it's pretty hard as a newcomer to know 
>> which build system You're supposed to use to start with when 
>> encountering a project where several languages are used.
>>
>> Alexis
>>
>> On 13/02/2024 13:46, Carlo Zancanaro wrote:
>>> On Tue, Feb 13 2024, Alexis Simon wrote:
>>>> Ok, this seems really counter intuitive though to go and use the cargo
>>>> build system for a python package only have a tiny part in rust.
>>>
>>> I'm not sure why this is counter-intuitive. The existence of any rust at
>>> all means you need to build rust code. The normal way to do that in Guix
>>> is to use the cargo-build-system.
>>>
>>> Equally, I don't find it strange that the upstream build instructions[1]
>>> ask me to install a rust compiler and cbindgen. I need to do that if I
>>> want to build rust code.
>>>
>>> It's also worth noting that there are 22 packages in Cargo.lock[2], so
>>> building the one rust file in the repository is a bit more involved.
>>>
>>> Carlo
>>>
>>> [1]: https://molpopgen.github.io/fwdpy11/misc/developersguide.html
>>> [2]: 
>>> https://github.com/molpopgen/fwdpy11/blob/main/rust/fp11rust/Cargo.lock
>>
> 

[-- Attachment #2: fwdpy11.scm --]
[-- Type: text/x-scheme, Size: 4114 bytes --]

(define-public fwdpy11
  (package
    (name "fwdpy11")
    (version "0.21.6")
    (source
     (origin
       (method url-fetch)
       (uri (pypi-uri "fwdpy11" version))
       (sha256
        (base32 "1mgs7fcda3cr7a7kbnk0x50993131453rlrkq7nv4pxqw53lnrv3"))))
    (build-system cargo-build-system)
    (arguments
      (list
        #:imported-modules `(,@%cargo-build-system-modules
                           ,@%pyproject-build-system-modules)
        #:modules '((guix build cargo-build-system)
                    ((guix build pyproject-build-system) #:prefix py:)
                    (guix build utils))
        #:phases
        #~(modify-phases %standard-phases
            (add-after 'unpack 'chdir-rust
                (lambda _
                  (chdir "rust/fp11rust")))
            (replace 'unpack-rust-crates
                ;; This is to avoid the non-crate source from being erroneously
                ;; unpacked by this phase, causing an error.
                (lambda* (#:key inputs #:allow-other-keys #:rest args)
                  (apply (assoc-ref %standard-phases 'unpack-rust-crates)
                         (append args
                                 (list #:inputs (alist-delete "source" inputs))))))
            (replace 'configure
                (lambda* (#:key inputs #:allow-other-keys #:rest args)
                  (apply (assoc-ref %standard-phases 'configure)
                         (append args
                                 (list #:inputs (alist-delete "source" inputs))))))            
            (delete 'build)
            (delete 'check)
            (delete 'install)
            (delete 'package)
            (add-before 'prepare-python-module 'chdir-root
                        (lambda _ (chdir "../..")))
            (add-after 'prepare-python-module 'build-python-module
              (assoc-ref py:%standard-phases 'build))
            (add-after 'build-python-module 'install-python-module
              (assoc-ref py:%standard-phases 'install))
            (add-after 'install-python-module 'check-python-module
              (lambda* (#:key inputs #:allow-other-keys #:rest args)
                (apply (assoc-ref py:%standard-phases 'check) args)))
            )
        #:cargo-inputs
        `(("rust-autocfg", rust-autocfg-1)
          ("rust-demes", rust-demes-0.5)
          ("rust-demes-forward", rust-demes-forward-0.4)
          ("rust-demes-forward-capi", rust-demes-forward-capi-0.4)
          ("rust-hashbrown", rust-hashbrown-0.12)
          ("rust-indexmap", rust-indexmap-1.8)
          ("rust-itoa", rust-itoa-1)
          ("rust-libc", rust-libc-0.2)
          ("rust-proc-macro2", rust-proc-macro2-1)
          ("rust-quote", rust-quote-1)
          ("rust-regex", rust-regex-1)
          ("rust-regex-syntax", rust-regex-syntax-0.6)
          ("rust-ryu", rust-ryu-1)
          ("rust-serde", rust-serde-1)
          ("rust-serde-derive", rust-serde-derive-1)
          ("rust-serde-yaml", rust-serde-yaml-0.9)
          ("rust-syn", rust-syn-1)
          ("rust-thiserror", rust-thiserror-1)
          ("rust-thiserror-impl", rust-thiserror-impl-1)
          ("rust-unicode-ident", rust-unicode-ident-1)
          ("rust-unsafe-libyaml", rust-unsafe-libyaml-0.2)
          )
      ))
    (native-inputs
     (list python-wrapper
           cmake
           rust-cbindgen
           gsl
           pybind11
           python-wheel
           python-setuptools
           python-setuptools-scm
           python-pytest
           python-pytest-xdist
           python-hypothesis
           python-msprime))
    (propagated-inputs (list python-attrs
                             python-deprecated
                             python-black
                             python-demes
                             python-numpy
                             python-scipy
                             python-tskit))
    (home-page "https://github.com/molpopgen/fwdpy11")
    (synopsis "Forward-time population genetic simulation in Python")
    (description "Forward-time population genetic simulation in Python")
    (license license:gpl3))
)

  reply	other threads:[~2024-02-17  0:04 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-12  1:49 Python package with some rust dependency Alexis Simon
2024-02-12 23:29 ` Carlo Zancanaro
2024-02-13 19:36   ` Alexis Simon
2024-02-13 21:46     ` Carlo Zancanaro
2024-02-13 21:55       ` Alexis Simon
2024-02-16  6:08         ` Alexis Simon
2024-02-17  0:02           ` Alexis Simon [this message]
2024-02-17 11:50             ` Carlo Zancanaro
2024-02-17 16:46               ` Alexis Simon
2024-02-17 19:25                 ` Alexis Simon
2024-02-18  3:03                 ` Carlo Zancanaro

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f5bf57b4-fbc3-4763-a88c-2f44f77439cb@runbox.com \
    --to=alexis.simon@runbox.com \
    --cc=help-guix@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.