Subject: [bug#78422] [PATCH electronics-team v3] gnu: Add python-apycula.

From: Maxim Cournoyer <[email-masked]>
Date: Wed, 21 May 2025 08:41:47 +0900

Hi,

I tried locally, this is my local changes so far:

--8<---------------cut here---------------start------------->8---
(define-public apycula
  (package
    (name "apycula")
    (version "0.19")
    ;; The pypi tar.gz file includes the necessary .pickle files, not available
    ;; in the home-page repository.
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://github.com/YosysHQ/apicula")
             (commit version)))
       (file-name (git-file-name name version))
       (sha256
        (base32
         "0i3p3x3hs7c2dw5g6wa5g9lh551f5drb0abp7p3gkcfq4hi7bwm0"))))
    (build-system pyproject-build-system)
    (arguments
     (list
      #:tests? #f                       ;requires Gowin EDA tools
      #:phases
      #~(modify-phases %standard-phases
          (add-after 'unpack 'generate-chipdb-files
            (lambda _
              (invoke "make" "GOWINHOME=/tmp")))
          (add-after 'unpack 'sanity-check-fix
            (lambda _
              ;; The module name changed (see:
              ;; https://github.com/YosysHQ/apicula/issues/337).
              (substitute* "setup.py"
                (("'gowin_bba")
                 "# 'gowin_bbva")))))))
    (native-inputs (list python-setuptools python-wheel
                         ;gowin-eda   ;; PACKAGE ME!
                         ))
    (inputs (list python-crc))
    (home-page "https://github.com/YosysHQ/apicula/")
    (synopsis "Gowin FPGA bitstream format")
    (description
     "The project Apycula provides tools to support development and
generating bitstreams with Gowin FPGAs.")
    (license license:expat)))
--8<---------------cut here---------------end--------------->8---

I'm fetching from git, and renamed the package to just 'apycula' since
it appears intended to be used as tools (commands), not as a library.
I've also reported the bug found upstream and linked it here.  Thus we
can also make propagated-inputs just inputs, since they are captured in
the command wrapper scripts.

The problem now is that to generate the chipdb files we need gowin-eda.
Since this would also enable running the test suite, I think gowin-eda
should be packaged first and added to the native inputs here:

--8<---------------cut here---------------start------------->8---
starting phase `generate-chipdb-files'
python3 -m apycula.tiled_fuzzer GW1N-1
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/tmp/guix-build-apycula-0.19.drv-0/source/apycula/tiled_fuzzer.py", line 231, in <module>
    with open(f"{gowinhome}/IDE/share/device/{device}/{device}.fse", 'rb') as f:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/IDE/share/device/GW1N-1/GW1N-1.fse'
make: *** [Makefile:12: GW1N-1_stage1.pickle] Error 1
error: in phase 'generate-chipdb-files': uncaught exception:
%exception #<&invoke-error program: "make" arguments: ("GOWINHOME=/tmp") exit-status: 2 term-signal: #f stop-signal: #f> 
phase `generate-chipdb-files' failed after 0.1 seconds
--8<---------------cut here---------------end--------------->8---

Cayetano, could you please try packaging gowin-eda and using it here, to
get past the above issue?  And see if we can enable the test suite too!

--
Thanks,
Maxim