[PATCH] Add qucs-s.

  • Open
  • quality assurance status badge
Details
4 participants
  • Garek Dyszel
  • Ludovic Courtès
  • (
  • Artyom V. Poptsov
Owner
unassigned
Submitted by
Garek Dyszel
Severity
normal
G
G
Garek Dyszel wrote on 13 Sep 2022 17:48
(address . guix-patches@gnu.org)
875yhrgtrb.fsf@disroot.org
* gnu/packages/engineering.scm (qucs-s): New variable.
---
gnu/packages/engineering.scm | 74 ++++++++++++++++++++++++++++++++++++
1 file changed, 74 insertions(+)

Toggle diff (87 lines)
diff --git a/gnu/packages/engineering.scm b/gnu/packages/engineering.scm
index a8b9f1e786..376cb7e8c1 100644
--- a/gnu/packages/engineering.scm
+++ b/gnu/packages/engineering.scm
@@ -2006,6 +2006,80 @@ (define-public xyce-parallel
,@(alist-delete "trilinos"
(package-inputs xyce-serial))))))
+(define-public qucs-s
+ (package
+ (name "qucs-s")
+ (version "0.0.24")
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/ra3xdh/qucs_s")
+ (commit version)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "1lbkaw0grw9w7d37z5dbhaqi8p57cpf9yp071zp6xrairkgimdx8"))))
+ (build-system qt-build-system)
+ (outputs '("out"))
+ (inputs (list qtbase-5 qtscript qtsvg-5))
+ (native-inputs (list qttools-5))
+ (propagated-inputs (list ngspice))
+ (arguments
+ `(;; There exists no "tests" target in the Makefile generated by
+ ;; CMake.
+ ;; No other tests provided.
+ #:tests? #f
+ #:phases
+ (modify-phases %standard-phases
+ (add-after 'install 'get-ngspice-path
+ (lambda* (#:key inputs #:allow-other-keys)
+ ;; Adjust two lines in the ~/.config/qucs/qucs_s.conf
+ ;; file.
+ (mkdir-p "etc/xdg/qucs_s")
+ (with-directory-excursion "etc/xdg/qucs_s"
+ (invoke "touch" "qucs_s.conf")
+ ;; Specify where the ngspice executable is located.
+ (invoke "sed" "-i"
+ (string-append "1iNgspiceExecutable=/gnu/store/"
+ (assoc-ref inputs "ngspice")
+ "/bin/ngspice") "qucs_s.conf")
+ ;; Set the spice4qucs working directory to
+ ;; ~/.qucs/spice4qucs.
+ ;; (The default is /spice4qucs, which is rather
+ ;; dangerous.)
+ (invoke "sed" "-i" "2iS4Q_workdir=~/.qucs/spice4qucs"
+ "qucs_s.conf")))))))
+
+ (home-page "https://ra3xdh.github.io")
+ (synopsis "QUCS RF circuit simulator with SPICE")
+ (description
+ "Qucs-S is a spin-off of the Qucs cross-platform circuit
+simulator. The \"S\" letter indicates SPICE. The purpose of the Qucs-S
+subproject is to use free SPICE circuit simulation kernels with the
+Qucs GUI. It merges the power of SPICE and the simplicity of the Qucs
+GUI. Qucs intentionally uses its own SPICE incompatible simulation
+kernel Qucsator. It has advanced RF and AC domain simulation features,
+but most of the existing industrial SPICE models are incompatible with
+it. Qucs-S is not a simulator by itself, but it requires to use a
+simulation backend with it. The schematic document format of Qucs and
+Qucs-S are fully compatible. Qucs-S can be used with the following
+simulation kernels:
+@itemize
+@item Ngspice is recommended to use. Ngspice is powerful
+mixed-level/mixed-signal circuit simulator. The most of industrial
+SPICE models are compatible with Ngspice. It has an excellent
+performance for time-domain simulation of switching circuits and
+powerful postprocessor.
+@item XYCE is a new SPICE-compatible circuit simulator written by
+Sandia from the scratch. It supports basic SPICE simulation types and
+has an advanced RF simulation features such as harmonic balance
+simulation.
+@item SpiceOpus is developed by the Faculty of Electrical Engineering
+of the Ljubljana University. It is based on the SPICE-3f5 code.
+@item Backward compatible with Qucsator.
+@end itemize")
+ (license license:gpl2)))
+
(define-public freehdl
(package
(name "freehdl")
--
2.37.2
(
CMVEMLCFZYJV.2HHWATU7GOQJV@guix-aspire
Hey,

On Tue Sep 13, 2022 at 4:48 PM BST, Garek Dyszel via Guix-patches via wrote:
Toggle quote (2 lines)
> + (outputs '("out"))

This line is redundant; ``out'' is implicit.

Toggle quote (2 lines)
> + (propagated-inputs (list ngspice))

Can you try to avoid propagating this somehow? Propagation is a last-resort
measure, and usually we try to do something like patching invocations of
external commands to refer to the full store path. (Although, looking at
the ``modify-phases'' below, it seems like you already do that, so I guess
you'll only need to move ``ngspice'' to ``inputs''.)

Toggle quote (3 lines)
> + (arguments
> + `(;; There exists no "tests" target in the Makefile generated by

Please use the new style ``(list ...)'' instead of ```(...)''.

Toggle quote (2 lines)
> + (modify-phases %standard-phases

You'll need to gexp this under the new arguments style: ``#~(modify-phases ...)''.

Toggle quote (14 lines)
> + (with-directory-excursion "etc/xdg/qucs_s"
> + (invoke "touch" "qucs_s.conf")
> + ;; Specify where the ngspice executable is located.
> + (invoke "sed" "-i"
> + (string-append "1iNgspiceExecutable=/gnu/store/"
> + (assoc-ref inputs "ngspice")
> + "/bin/ngspice") "qucs_s.conf")
> + ;; Set the spice4qucs working directory to
> + ;; ~/.qucs/spice4qucs.
> + ;; (The default is /spice4qucs, which is rather
> + ;; dangerous.)
> + (invoke "sed" "-i" "2iS4Q_workdir=~/.qucs/spice4qucs"
> + "qucs_s.conf")))))))

This looks pretty redundant. Try using this instead:

Toggle quote (7 lines)
> + (call-with-output-file "etc/xdg/qucs_s/qucs_s.conf"
> + (cute format <>
> + "~
> +NgspiceExecutable=~a
> +S4Q_workdir=~/.qucs/spice4qucs~%"
> + (search-input-file inputs "bin/ngspice")))

And add this to ``arguments'':

#:modules `((ice-9 format)
(srfi srfi-26)
,@%gnu-build-system-modules)

to import ``format'' and ``cute'', respectively.

Toggle quote (27 lines)
> + (description
> + "Qucs-S is a spin-off of the Qucs cross-platform circuit
> +simulator. The \"S\" letter indicates SPICE. The purpose of the Qucs-S
> +subproject is to use free SPICE circuit simulation kernels with the
> +Qucs GUI. It merges the power of SPICE and the simplicity of the Qucs
> +GUI. Qucs intentionally uses its own SPICE incompatible simulation
> +kernel Qucsator. It has advanced RF and AC domain simulation features,
> +but most of the existing industrial SPICE models are incompatible with
> +it. Qucs-S is not a simulator by itself, but it requires to use a
> +simulation backend with it. The schematic document format of Qucs and
> +Qucs-S are fully compatible. Qucs-S can be used with the following
> +simulation kernels:
> +@itemize
> +@item Ngspice is recommended to use. Ngspice is powerful
> +mixed-level/mixed-signal circuit simulator. The most of industrial
> +SPICE models are compatible with Ngspice. It has an excellent
> +performance for time-domain simulation of switching circuits and
> +powerful postprocessor.
> +@item XYCE is a new SPICE-compatible circuit simulator written by
> +Sandia from the scratch. It supports basic SPICE simulation types and
> +has an advanced RF simulation features such as harmonic balance
> +simulation.
> +@item SpiceOpus is developed by the Faculty of Electrical Engineering
> +of the Ljubljana University. It is based on the SPICE-3f5 code.
> +@item Backward compatible with Qucsator.
> +@end itemize")

I think this description would probably be better and far more succint as:

Toggle quote (5 lines)
> + (description
> + "This package provides a fork of the Qucs cross-platform circuit
> +simulator, which allows the use of SPICE circuit simulation kernels
> +with the Qucs GUI.")

-- (
A
A
Artyom V. Poptsov wrote on 13 Sep 2022 19:28
[bug#57774] [PATCH] Add qucs-s.
878rmnchg4.fsf@gmail.com
Hello Garek Dyszel,

For the sake of completeness, I've tried to package "qucs-s" already:

Wasn't finished the process though due to issues and the lack of time,
but maybe two incomplete patches could be merged into a working one.

Thanks,

- Artyom

--
Artyom "avp" Poptsov <poptsov.artyom@gmail.com>
CADR Hackerspace co-founder: https://cadrspace.ru/
GPG: D0C2 EAC1 3310 822D 98DE B57C E9C5 A2D9 0898 A02F
-----BEGIN PGP SIGNATURE-----

iQFNBAEBCgA3FiEE0MLqwTMQgi2Y3rV86cWi2QiYoC8FAmMgvasZHHBvcHRzb3Yu
YXJ0eW9tQGdtYWlsLmNvbQAKCRDpxaLZCJigLyOGB/9LC8uVdCwEdM59WQ46UTef
6iDmHOUNQ9I648tzWNpn0CR6qakkS9M18HPbQrq0P2sMqyXk/oO1wSpQqHpTvBfi
lYSHfr3rgNuGzQG6jFexzTRXiS/+4VpSoA2X7WK8q7Feuc00/Ui9bxf2GaVIH1zD
n9DfY3delOKJpy6wIIH2ernzBXMj5zZrr9J0eJKfXdGvHmCqOujV8bG9x4WvPtBN
y/g14VkO1PZYx8EMqw9ixQ/NbrkfhnbrXK9ZB37FzbFRrRiw505DBmVs4ZQweR7W
+NFF7fppaSYsGtCa2sN6g57MAhesGNhMJY39WYVpADPKgdhbW3uBLDpMmN2B09aT
=yQFX
-----END PGP SIGNATURE-----

G
G
Garek Dyszel wrote on 13 Sep 2022 23:11
[PATCH v2] Add qucs-s.
(address . 57774@debbugs.gnu.org)
87fsgvm12r.fsf@disroot.org
( and Artyom,

I synthesized my last version of this package with Artyom's version in
Starting over from that version, more or less, automatically fixed the
following issues:

1. (outputs '("out")) removed
2. (propagated-inputs (list ngspice)) removed
3. (arguments `( --> (arguments (list : style changed

Further changes:
1. Overly long description shortened by blending ('s suggestion and Artyom's version.
2. Regexps in the (substitute*) procedure now correctly detect and replace the lines where ngspice and octave are referenced in qucs/main.cpp.

Let me know what you think.

Thanks,
Garek

* gnu/packages/engineering.scm (qucs-s): New variable.
---
gnu/packages/engineering.scm | 60 ++++++++++++++++++++++++++++++++++++
1 file changed, 60 insertions(+)

Toggle diff (80 lines)
diff --git a/gnu/packages/engineering.scm b/gnu/packages/engineering.scm
index a8b9f1e786..e759134ae4 100644
--- a/gnu/packages/engineering.scm
+++ b/gnu/packages/engineering.scm
@@ -36,6 +36,7 @@
;;; Copyright © 2022 Artyom V. Poptsov <poptsov.artyom@gmail.com>
;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2022 Felix Gruber <felgru@posteo.net>
+;;; Copyright © 2022 Garek Dyszel <garekdyszel@disroot.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -2006,6 +2007,65 @@ (define-public xyce-parallel
,@(alist-delete "trilinos"
(package-inputs xyce-serial))))))
+(define-public qucs-s
+ (package
+ (name "qucs-s")
+ (version "0.0.24")
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/ra3xdh/qucs_s")
+ (commit version)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "1lbkaw0grw9w7d37z5dbhaqi8p57cpf9yp071zp6xrairkgimdx8"))))
+ (build-system qt-build-system)
+ (native-inputs (list qttools-5))
+ (inputs (list qtbase-5 qtscript qtsvg-5 ngspice octave))
+ (arguments
+ (list #:tests? #f ;no tests
+ #:phases #~(modify-phases %standard-phases
+ (add-after 'unpack 'patch
+ (lambda* (#:key inputs #:allow-other-keys)
+ (substitute* "qucs/main.cpp"
+ ;; Use the user's configuration files in
+ ;; ~/.config/qucs/qucs_s.conf for the
+ ;; locations of ngspice and octave. If
+ ;; the locations are not given in
+ ;; ~/.config/qucs/qucs_s.conf, use the
+ ;; locations provided by Guix.
+ (("QString ngsp_exe = \
+QCoreApplication::applicationDirPath\\(\\) \\+")
+ (string-append
+ "QString ngsp_exe = \""
+ (search-input-file inputs "/bin/ngspice")
+ "\";"))
+ (("QDir::separator\\(\\) \\+ \"ngspice\" \\+ \
+executableSuffix;") "")
+ (("else QucsSettings.OctaveExecutable = \"octave\" \
+\\+ QString\\(executableSuffix\\);")
+ (string-append
+ "else QucsSettings.OctaveExecutable = \""
+ (search-input-file inputs "/bin/octave")
+ "\";"))))))))
+ (synopsis "GUI for different circuit simulation kernels")
+ (description
+ "@code{Qucs-S} provides a fork of the Qucs circuit simulator,
+which is used as a graphical user interface for a number of popular
+circuit simulation engines. The package contains libraries for
+schematic capture, visualization and components. The following
+simulation kernels are supported:
+
+@itemize
+@item Ngspice (recommended)
+@item Xyce
+@item SpiceOpus
+@item Qucsator (non-spice)
+@end itemize")
+ (home-page "https://ra3xdh.github.io/")
+ (license license:gpl2+)))
+
(define-public freehdl
(package
(name "freehdl")
--
2.37.2
(
CMVWSNPV9K43.1SVD70HZ46NY8@guix-aspire
Hey,

On Tue Sep 13, 2022 at 10:11 PM BST, Garek Dyszel wrote:
Toggle quote (2 lines)
> + #:phases #~(modify-phases %standard-phases

To conserve lots of horizontal space, consider moving the ``modify-phases''
to a new line:

Toggle quote (7 lines)
> + #:phases
> + #~(modify-phases %standard-phases

> + (search-input-file inputs "/bin/ngspice")
> + [...]
> + (search-input-file inputs "/bin/octave")

You can just do ``(search-input-file inputs "bin/octave")'', no need for the
leading slash. Also, wouldn't you want to patch in the paths for Xyce,
SpiceOpus, and Qucsator, too?

Toggle quote (2 lines)
> + (synopsis "GUI for different circuit simulation kernels")

s/different/various/, perhaps?

Toggle quote (17 lines)
> +
> +@itemize
> +@item Ngspice (recommended)
> +@item Xyce
> +@item SpiceOpus
> +@item Qucsator (non-spice)
> +@end itemize")
> + (home-page "https://ra3xdh.github.io/")
> + (license license:gpl2+)))
> +
> (define-public freehdl
> (package
> (name "freehdl")
> --
> 2.37.2


-- (
G
G
Garek Dyszel wrote on 16 Sep 2022 20:27
87tu57uqcc.fsf@disroot.org
Hi (,

I applied your fixes, but in the process found that qucs-s had already been successfully added before by looking at the package definition for libngspice. This led to the following bug link: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=27344#236.

It looks like support was later dropped because qucs-s still depended on Qt4 at the time, mentioned in this thread: https://lists.gnu.org/archive/html/guix-devel/2016-02/msg00596.html.

This suggested it would be a good idea to start from the commit where qucs and qucs-s were removed. Now I'm hacking those old package definitions to work with Qt6. qucs-s 0.0.24 still depends on qt5 (which is already out of date), and I don't want to have to update it right away when this Qt security issue comes up again this year.

I'll send an updated patch when that's done. Sorry for jumping around among existing package sources; I suppose how it worked out this time.

- Garek

At 07:26 2022-09-14 UTC+0100, "(" <paren@disroot.org> wrote:
Toggle quote (41 lines)
> Hey,
>
> On Tue Sep 13, 2022 at 10:11 PM BST, Garek Dyszel wrote:
>> + #:phases #~(modify-phases %standard-phases
>
> To conserve lots of horizontal space, consider moving the ``modify-phases''
> to a new line:
>
>> + #:phases
>> + #~(modify-phases %standard-phases
>
>> + (search-input-file inputs "/bin/ngspice")
>> + [...]
>> + (search-input-file inputs "/bin/octave")
>
> You can just do ``(search-input-file inputs "bin/octave")'', no need for the
> leading slash. Also, wouldn't you want to patch in the paths for Xyce,
> SpiceOpus, and Qucsator, too?
>
>> + (synopsis "GUI for different circuit simulation kernels")
>
> s/different/various/, perhaps?
>
>> +
>> +@itemize
>> +@item Ngspice (recommended)
>> +@item Xyce
>> +@item SpiceOpus
>> +@item Qucsator (non-spice)
>> +@end itemize")
>> + (home-page "https://ra3xdh.github.io/")
>> + (license license:gpl2+)))
>> +
>> (define-public freehdl
>> (package
>> (name "freehdl")
>> --
>> 2.37.2
>
>
> -- (
L
L
Ludovic Courtès wrote on 26 Sep 2022 22:54
control message for bug #57774
(address . control@debbugs.gnu.org)
875yh9kgaa.fsf@gnu.org
tags 57774 + moreinfo
quit
?