all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Python package with some rust dependency
@ 2024-02-12  1:49 Alexis Simon
  2024-02-12 23:29 ` Carlo Zancanaro
  0 siblings, 1 reply; 11+ messages in thread
From: Alexis Simon @ 2024-02-12  1:49 UTC (permalink / raw)
  To: help-guix

Hi,

I've been trying to package a science python software that mixes some 
C++ and rust dependencies.
https://github.com/molpopgen/fwdpy11

I'm stuck in how to handle this.
Going the pyproject-build-system way, the cargo part errors at accessing 
crates.io as would be expected, I guess I should probably patch the 
cargo.toml to use the local registry?

Going the cargo-build-system way, it errors probably because there's no 
rust crate at the root of the project.

Here is what I've tried so far
https://codeberg.org/alxsim/local-channel/src/branch/main/packages/fwdpy11.scm

Does anyone have pointers on how to handle the build of this packages?

Thanks,
Alexis


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Python package with some rust dependency
  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
  0 siblings, 1 reply; 11+ messages in thread
From: Carlo Zancanaro @ 2024-02-12 23:29 UTC (permalink / raw)
  To: Alexis Simon; +Cc: help-guix

Hi Alexis,

I don't really know much about building rust. Given this one repository
has both, I wonder if it would make sense to build them separately (as
two packages), and have one as an input of the other.

Presumably this would mean the python package taking the rust package as
an input, but the details might be more involved.

On Sun, Feb 11 2024, Alexis Simon wrote:
> Going the cargo-build-system way, it errors probably because there's
> no rust crate at the root of the project.

One option here might be to add a phase after the unpack phase, to chdir
into the directory with the rust crate. You can see examples in lots of
places in the Guix repository, like wpa-supplicant-gui. Which has a
phase modification:

    (add-after 'unpack 'chdir
      (lambda _ (chdir "wpa_supplicant/wpa_gui-qt4")))

You'll need to change the directory to match where in the fwdpy11 source
you need to go to build the rust stuff.

I hope that helps,

Carlo


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Python package with some rust dependency
  2024-02-12 23:29 ` Carlo Zancanaro
@ 2024-02-13 19:36   ` Alexis Simon
  2024-02-13 21:46     ` Carlo Zancanaro
  0 siblings, 1 reply; 11+ messages in thread
From: Alexis Simon @ 2024-02-13 19:36 UTC (permalink / raw)
  To: Carlo Zancanaro; +Cc: help-guix

Thanks a lot Carlo

I see what you mean there, but I'm probably out of my depth in terms of 
guix/guile knowledge so this will probably have to wait for me to level up.

On 12/02/2024 15:29, Carlo Zancanaro wrote:
> Hi Alexis,
> 
> I don't really know much about building rust. Given this one repository
> has both, I wonder if it would make sense to build them separately (as
> two packages), and have one as an input of the other.
> 
> Presumably this would mean the python package taking the rust package as
> an input, but the details might be more involved.
> 
> On Sun, Feb 11 2024, Alexis Simon wrote:
>> Going the cargo-build-system way, it errors probably because there's
>> no rust crate at the root of the project.
> 
> One option here might be to add a phase after the unpack phase, to chdir
> into the directory with the rust crate. You can see examples in lots of
> places in the Guix repository, like wpa-supplicant-gui. Which has a
> phase modification:
> 
>      (add-after 'unpack 'chdir
>        (lambda _ (chdir "wpa_supplicant/wpa_gui-qt4")))
> 
> You'll need to change the directory to match where in the fwdpy11 source
> you need to go to build the rust stuff.

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 hope that helps,

Thanks for the pointers, it helps

> 
> Carlo


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Python package with some rust dependency
  2024-02-13 19:36   ` Alexis Simon
@ 2024-02-13 21:46     ` Carlo Zancanaro
  2024-02-13 21:55       ` Alexis Simon
  0 siblings, 1 reply; 11+ messages in thread
From: Carlo Zancanaro @ 2024-02-13 21:46 UTC (permalink / raw)
  To: Alexis Simon; +Cc: help-guix

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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Python package with some rust dependency
  2024-02-13 21:46     ` Carlo Zancanaro
@ 2024-02-13 21:55       ` Alexis Simon
  2024-02-16  6:08         ` Alexis Simon
  0 siblings, 1 reply; 11+ messages in thread
From: Alexis Simon @ 2024-02-13 21:55 UTC (permalink / raw)
  To: Carlo Zancanaro; +Cc: help-guix

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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Python package with some rust dependency
  2024-02-13 21:55       ` Alexis Simon
@ 2024-02-16  6:08         ` Alexis Simon
  2024-02-17  0:02           ` Alexis Simon
  0 siblings, 1 reply; 11+ messages in thread
From: Alexis Simon @ 2024-02-16  6:08 UTC (permalink / raw)
  To: help-guix

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
> 


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Python package with some rust dependency
  2024-02-16  6:08         ` Alexis Simon
@ 2024-02-17  0:02           ` Alexis Simon
  2024-02-17 11:50             ` Carlo Zancanaro
  0 siblings, 1 reply; 11+ messages in thread
From: Alexis Simon @ 2024-02-17  0:02 UTC (permalink / raw)
  To: help-guix

[-- 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))
)

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Python package with some rust dependency
  2024-02-17  0:02           ` Alexis Simon
@ 2024-02-17 11:50             ` Carlo Zancanaro
  2024-02-17 16:46               ` Alexis Simon
  0 siblings, 1 reply; 11+ messages in thread
From: Carlo Zancanaro @ 2024-02-17 11:50 UTC (permalink / raw)
  To: Alexis Simon; +Cc: help-guix

Hi Alexis,

On Fri, Feb 16 2024, Alexis Simon wrote:
> ```
> 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
> ...
> ice-9/boot-9.scm:1685:16: In procedure raise-exception:
> In procedure apply: Apply to non-list: #f
> ```

This error sounds like you're trying to call #f as a function. Since
this is happening in the 'check-python-module phase, we can look at this
code:

>             (add-after 'install-python-module 'check-python-module
>               (lambda* (#:key inputs #:allow-other-keys #:rest args)
>                 (apply (assoc-ref py:%standard-phases 'check) args)))

I assume that (assoc-ref py:%standard-phases 'check) is returning #f,
which is causing the error. Given you don't use inputs, you could try
the same thing as you've done for the other phases like:

    (add-after 'install-python-module 'check-python-module
      (assoc-ref py:%standard-phases 'check))

But I'm not sure that will help you if the assoc-ref is really returning
#f. I guess in the worst case you could just leave out the check phase
entirely.

Also, as an aside, I'm not sure where the 'prepare-python-module phase
is coming from. Does it actually exist?

Carlo


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Python package with some rust dependency
  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
  0 siblings, 2 replies; 11+ messages in thread
From: Alexis Simon @ 2024-02-17 16:46 UTC (permalink / raw)
  To: Carlo Zancanaro; +Cc: help-guix



On 17/02/2024 03:50, Carlo Zancanaro wrote:
> Hi Alexis,
> 
> On Fri, Feb 16 2024, Alexis Simon wrote:
>> ```
>> 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
>> ...
>> ice-9/boot-9.scm:1685:16: In procedure raise-exception:
>> In procedure apply: Apply to non-list: #f
>> ```
> 
> This error sounds like you're trying to call #f as a function. Since
> this is happening in the 'check-python-module phase, we can look at this
> code:
> 
>>              (add-after 'install-python-module 'check-python-module
>>                (lambda* (#:key inputs #:allow-other-keys #:rest args)
>>                  (apply (assoc-ref py:%standard-phases 'check) args)))
> 
> I assume that (assoc-ref py:%standard-phases 'check) is returning #f,
> which is causing the error. Given you don't use inputs, you could try
> the same thing as you've done for the other phases like:
> 
>      (add-after 'install-python-module 'check-python-module
>        (assoc-ref py:%standard-phases 'check))
> 
> But I'm not sure that will help you if the assoc-ref is really returning
> #f. I guess in the worst case you could just leave out the check phase
> entirely.

Thanks that makes a bit more sense I think.

> 
> Also, as an aside, I'm not sure where the 'prepare-python-module phase
> is coming from. Does it actually exist?

This is a very good question I had myself and to which I couldn't find 
the answer. I found examples such as those [1] in the repo and couldn't 
find where this phase was specified. But it seems to work.

> 
> Carlo

Alexis

[1] 
https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/packages/python-xyz.scm#n3453


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Python package with some rust dependency
  2024-02-17 16:46               ` Alexis Simon
@ 2024-02-17 19:25                 ` Alexis Simon
  2024-02-18  3:03                 ` Carlo Zancanaro
  1 sibling, 0 replies; 11+ messages in thread
From: Alexis Simon @ 2024-02-17 19:25 UTC (permalink / raw)
  To: Carlo Zancanaro; +Cc: help-guix

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

for reference, I finally managed to get this working.
See attached file.
Thanks for the help
Alexis

On 17/02/2024 08:46, Alexis Simon wrote:
> 
> 
> On 17/02/2024 03:50, Carlo Zancanaro wrote:
>> Hi Alexis,
>>
>> On Fri, Feb 16 2024, Alexis Simon wrote:
>>> ```
>>> 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
>>> ...
>>> ice-9/boot-9.scm:1685:16: In procedure raise-exception:
>>> In procedure apply: Apply to non-list: #f
>>> ```
>>
>> This error sounds like you're trying to call #f as a function. Since
>> this is happening in the 'check-python-module phase, we can look at this
>> code:
>>
>>>              (add-after 'install-python-module 'check-python-module
>>>                (lambda* (#:key inputs #:allow-other-keys #:rest args)
>>>                  (apply (assoc-ref py:%standard-phases 'check) args)))
>>
>> I assume that (assoc-ref py:%standard-phases 'check) is returning #f,
>> which is causing the error. Given you don't use inputs, you could try
>> the same thing as you've done for the other phases like:
>>
>>      (add-after 'install-python-module 'check-python-module
>>        (assoc-ref py:%standard-phases 'check))
>>
>> But I'm not sure that will help you if the assoc-ref is really returning
>> #f. I guess in the worst case you could just leave out the check phase
>> entirely.
> 
> Thanks that makes a bit more sense I think.
> 
>>
>> Also, as an aside, I'm not sure where the 'prepare-python-module phase
>> is coming from. Does it actually exist?
> 
> This is a very good question I had myself and to which I couldn't find 
> the answer. I found examples such as those [1] in the repo and couldn't 
> find where this phase was specified. But it seems to work.
> 
>>
>> Carlo
> 
> Alexis
> 
> [1] 
> https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/packages/python-xyz.scm#n3453
> 

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

(define-module (packages fwdpy11)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (gnu packages)
  #:use-module (gnu packages base)
  #:use-module (gnu packages build-tools)
  #:use-module (gnu packages cmake)
  #:use-module (gnu packages check)
  #:use-module (gnu packages rust)
  #:use-module (gnu packages crates-io)
  #:use-module (gnu packages rust-apps)
  #:use-module (gnu packages python)
  #:use-module (gnu packages python-build)
  #:use-module (gnu packages python-xyz)
  #:use-module (gnu packages python-science)
  #:use-module (gnu packages bioinformatics)
  #:use-module (gnu packages serialization)
  #:use-module (gnu packages compression)
  #:use-module (gnu packages maths)
  #:use-module (gnu packages boost)
  #:use-module (gnu packages autotools)
  #:use-module (packages popgen)
  #:use-module (guix packages)
  #:use-module (guix gexp)
  #:use-module (guix download)
  #:use-module (guix git-download)
  #:use-module (guix utils)
  #:use-module (guix build-system python)
  #:use-module (guix build-system cargo)
  #:use-module (guix build-system gnu)
  #:use-module (guix build-system pyproject))

(define-public rust-demes-0.5
  (package
    (name "rust-demes")
    (version "0.5.0")
    (source
     (origin
       (method url-fetch)
       (uri (crate-uri "demes" version))
       (file-name (string-append name "-" version ".tar.gz"))
       (sha256
        (base32 "0mg78a9f16fayqpg8vkbr0209rj05svppxcfk0ldgn125mw81b11"))))
    (build-system cargo-build-system)
    (arguments
     `(#:skip-build? #t
       #:cargo-inputs (("rust-regex" ,rust-regex-1)
                       ("rust-serde" ,rust-serde-1)
                       ("rust-serde-json" ,rust-serde-json-1)
                       ("rust-serde-yaml" ,rust-serde-yaml-0.9)
                       ("rust-thiserror" ,rust-thiserror-1))))
    (home-page "https://github.com/molpopgen/demes-rs")
    (synopsis "rust implementation of demes specification")
    (description "rust implementation of demes specification")
    (license license:expat)))

(define-public rust-demes-forward-0.4
  (package
    (name "rust-demes-forward")
    (version "0.4.0")
    (source
     (origin
       (method url-fetch)
       (uri (crate-uri "demes-forward" version))
       (file-name (string-append name "-" version ".tar.gz"))
       (sha256
        (base32 "1awhy8vgmj24241vl304f0m17jdqhrw78wm5gn0q3w8y1432mclm"))))
    (build-system cargo-build-system)
    (arguments
     `(#:cargo-inputs (("rust-demes" ,rust-demes-0.5)
                       ("rust-thiserror" ,rust-thiserror-1))
       #:cargo-development-inputs (("rust-anyhow" ,rust-anyhow-1))))
    (home-page "https://github.com/molpopgen/demes-rs")
    (synopsis "rust API for iterating demes models forwards in time")
    (description "rust API for iterating demes models forwards in time")
    (license license:expat)))

(define-public rust-demes-forward-capi-0.4
  (package
    (name "rust-demes-forward-capi")
    (version "0.4.1")
    (source
     (origin
       (method url-fetch)
       (uri (crate-uri "demes-forward-capi" version))
       (file-name (string-append name "-" version ".tar.gz"))
       (sha256
        (base32 "1b3aq2wjw6sr9nqlr8v71hi9kjj4wq48k39irgvlwyipnj74ws7s"))))
    (build-system cargo-build-system)
    (arguments
     `(#:cargo-inputs (("rust-demes-forward" ,rust-demes-forward-0.4)
                       ("rust-libc" ,rust-libc-0.2))))
    (home-page "https://github.com/molpopgen/demes-rs")
    (synopsis "C API to demes-forward crate")
    (description "C API to demes-forward crate")
    (license license:expat)))

(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
            (delete 'package)
            (delete 'check)
            (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))))))            
            (add-after 'patch-cargo-checksums 'chdir-python
                        (lambda _ (chdir "../..")))
            (add-after 'chdir-python 'enable-bytecode-determinism
              (assoc-ref py:%standard-phases 'enable-bytecode-determinism))
            (replace 'build
              (assoc-ref py:%standard-phases 'build))
            (replace 'install
              (assoc-ref py:%standard-phases 'install))
            (add-after 'install 'add-install-to-pythonpath
              (assoc-ref py:%standard-phases 'add-install-to-pythonpath))
            (add-after 'add-install-to-pythonpath 'check-python-module
              (lambda* (#:key tests? #:allow-other-keys)
                (when tests?
                  (invoke "pytest" "-vv" "tests")))))
       #: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))
)

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Python package with some rust dependency
  2024-02-17 16:46               ` Alexis Simon
  2024-02-17 19:25                 ` Alexis Simon
@ 2024-02-18  3:03                 ` Carlo Zancanaro
  1 sibling, 0 replies; 11+ messages in thread
From: Carlo Zancanaro @ 2024-02-18  3:03 UTC (permalink / raw)
  To: Alexis Simon; +Cc: help-guix

On Sat, Feb 17 2024, Alexis Simon wrote:
> On 17/02/2024 03:50, Carlo Zancanaro wrote:
>> Also, as an aside, I'm not sure where the 'prepare-python-module
>> phase is coming from. Does it actually exist?
>
> This is a very good question I had myself and to which I couldn't find
> the answer. I found examples such as those [1] in the repo and
> couldn't find where this phase was specified. But it seems to work.

I don't doubt that this works at the moment, but I expect that
ed1b2d0a86a0a62d8d843f06669a5f072482c37e on core-updates will break this
(and any other packages that reference non-existent phases).

Packages in the guix repository will presumably be fixed during the
core-updates merge, but any other packages will need to be updated.

Carlo


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2024-02-18  3:04 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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.