Subject: Re: [bug#36440] [PATCH] Add FreeCAD

From: John Soo <[email-masked]>
Date: Tue, 23 Jul 2019 16:25:53 +0000

Hi Bjorn, Jonathon, and everyone,

FreeCAD was certainly not easy to package. I spent actually several months
just working on the pyside2 dependencies and I still do not have a working
build of Pivy from coin.  It is only thanks to the help of the upstream
maintainers that this package is even close to working.  I have attached
updated patches and my responses to Bjorn's notes below. Thanks for your
review!

As to QTWebKit - I do not know why it is a dependency. It may not be a hard
requirement. If you comment it out, I think the configure phase may
succeed. I included it for completion only.

* FreeCAD Notes

** DONE Add commit message details and copyright lines

** Coin3D

*** DONE Delete blobs

*** hg-fetch deletes .hg dirs (and all submodules' .hg dirs)

** SoQT vs. Quarter

*** Not interchangeable as far as I know.

*** FreeCAD requires SoQT specifically during configure.

** Pyside2

*** Does all of pyside2 belong in qt.scm? - there are three packages:
Shiboken2, Pyside2, and Pyside2-Tools

*** QT version compatibility

**** The pyside2 project has branches for the newest version with
compatibility with older QT versions (I am using the 5.11.3 compat branch)

 - That is also why I am using a git commit for the Pyside2 packages
 - https://code.qt.io/cgit/pyside/pyside-setup.git/
 - Pyside dependencies were by far the most challenging, and I had to track
some issues (of which, some are not resolved)

** libmedfile

*** Reason for old version is that what was released when I started

*** 4.0.0 requires hdf5 >= 1.10.2

**** HDF5 has some dependents:

guix refresh --list-dependent hdf5 Building the following 11 packages would
ensure 23 dependent packages are rebuilt:
[email-masked] [email-masked] [email-masked] [email-masked]
[email-masked] [email-masked] [email-masked]
[email-masked] [email-masked] [email-masked] [email-masked]

**** HDF5 patches need updates when HDF5 updated to 1.10.5

*** DONE Change license to gpl3+

** libarea License questions and source locations:

**** I am using the source from github: https://github.com/Heeks/libarea

 - Should I use some other source? The google archive is unavailable.
 - I cannot find any license information in the github repository.

**** DONE Change to gpl3+

** Using releases over hg/git downloads (please advise)

1. Pyside2 packages - Done for compatibility reasons
2. Coin3D and SoQt - I don't think there are releases of these aside from
the bitbucket repository.
3. LLVM propagated packages (llvm-toolchain and pyside-libcxx-headers)
 - I am not sure these are the best way to accomplish the goal anyways.
 - Not sure where to find the right sources for llvm-toolchain-6 and the
pyside-libcxx-headers.
4. libarea - Seems like libarea is actually close to not even having source
available anymore, let alone a release
5. libspnav - Confused as to the best source to use here. If there is a
release or better version, I can update.
6. FreeCAD
 - I can use the releases if they exist. I do not think they have source
tarballs available.
 - I was packaging during a lot of active development of FreeCAD

Thank you for your review and advice.

- John

On Mon, Jul 22, 2019 at 5:57 PM Jonathan Brielmaier <
[email-masked]> wrote:

> Thanks Björn for having a look here :)
>
> On 7/22/19 4:11 PM, Björn Höfling wrote:> I wanted to give it a try for
> myself but failed: I could not build
> > qtwebkit locally, and no substitutes are available. I don't want to
> > hold back my comments any longer, so I postponed trying it out.
>
> qtwebkit seems to fail on master as well and it needs long to build, so
> I can't do it locally on my laptop:
> http://ci.guix.gnu.org/build/1488065/details
>
> > I wonder if we need the dependency on qtwebkit or if we can get rid of
> this, but I haven't investigated yet.
>
> I think we need it as openSUSE and Debian have a build require on
> qtwebkit-devel and it's noted at their wiki:
> https://www.freecadweb.org/wiki/CompileOnUnix#Getting_the_dependencies
>
From 0ff20b2981ba0ddaf705bc2afb3577da9987acfa Mon Sep 17 00:00:00 2001
From: John Soo <[email-masked]>
Date: Wed, 3 Jul 2019 09:40:31 -0700
Subject: [PATCH 01/11] gnu: Add coin3D.

* gnu/packages/graphics.scm (coin3D): New variable.
---
 gnu/packages/graphics.scm | 52 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)

diff --git a/gnu/packages/graphics.scm b/gnu/packages/graphics.scm
index 94a797c8f5..0e42f80a87 100644
--- a/gnu/packages/graphics.scm
+++ b/gnu/packages/graphics.scm
@@ -12,6 +12,7 @@
 ;;; Copyright © 2018 Alex Kost <[email-masked]>
 ;;; Copyright © 2018 Kei Kebreau <[email-masked]>
 ;;; Copyright © 2019 Mark H Weaver <[email-masked]>
+;;; Copyright © 2019 John Soo <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -73,6 +74,7 @@
   #:use-module (guix build-system python)
   #:use-module (guix download)
   #:use-module (guix git-download)
+  #:use-module (guix hg-download)
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix packages)
   #:use-module (guix utils))
@@ -975,3 +977,53 @@ your terminal.  It comes bundled with predefined styles:
 look.  The result can be uploaded on any web server without additional
 requirements.")
     (license license:gpl2+)))
+
+(define-public coin3D
+  (let ((changeset  "8d860d7ba112b22c4e9b289268fd8b3625ab81d3")
+        (revision "1"))
+    (package
+      (name "coin3D")
+      (version
+       (string-append "4.0.0a-" revision "." (string-take changeset 7)))
+      (source
+       (origin
+         (method hg-fetch)
+         (uri (hg-reference (url "https://bitbucket.org/Coin3D/coin")
+                            (changeset changeset)))
+         (sha256
+          (base32
+           "0kgg782j8lkd4bicd8x207mj66vali6kxh6idczjszcxq2iifsr0"))
+         (file-name (git-file-name "coin3D" version))
+         (modules '((guix build utils)))
+         (snippet
+          '(begin
+             (for-each delete-file
+                       '("cfg/csubst.exe"
+                         "cfg/wrapmsvc.exe"))
+             #t))))
+      (build-system cmake-build-system)
+      (native-inputs
+       `(("doxygen" ,doxygen)
+         ("graphviz" ,graphviz)))
+      (inputs
+       `(("boost" ,boost)
+         ("freeglut" ,freeglut)
+         ("glew" ,glew)))
+      (arguments
+       `(#:configure-flags
+         (list
+          "-DCOIN_BUILD_DOCUMENTATION_MAN=ON"
+          (string-append "-DBOOST_ROOT="
+                         (assoc-ref %build-inputs "boost")))))
+      (home-page "https://bitbucket.org/Coin3D/coin/wiki/Home")
+      (synopsis
+       "High-level 3D visualization library with Open Inventor 2.1 API")
+      (description
+       "Coin is a 3D graphics library with an Application Programming Interface
+based on the Open Inventor 2.1 API.  For those who are not familiar with
+Open Inventor, it is a scene-graph based retain-mode rendering and model
+interaction library, written in C++, which has become the de facto
+standard graphics library for 3D visualization and visual simulation
+software in the scientific and engineering community.")
+      (license license:bsd-3))))
+
-- 
2.22.0

From d037a21c11318db6beb615fd5334b75b42f5f7e5 Mon Sep 17 00:00:00 2001
From: John Soo <[email-masked]>
Date: Sat, 6 Jul 2019 10:20:22 -0700
Subject: [PATCH 05/11] gnu: Add python-pyside-2-libcxx-headers.

* gnu/packages/llvm.scm (python-pyside-2-libcxx-headers): New variable.
---
 gnu/packages/llvm.scm | 55 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)

diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
index 188d0bb267..3641ad068e 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -702,3 +702,58 @@ using @code{clang-rename}.")))
          #t)))
     (license license:ncsa)))
 
+;; See https://bugreports.qt.io/browse/PYSIDE-787
+;; STL headers are not parsed correctly, so only send in some headers
+(define-public python-pyside-2-libcxx-headers
+  (package
+    (inherit libcxx)
+    (name "python-pyside-2-libcxx-headers")
+    (version (package-version llvm-6))
+    (source
+     (origin
+       (inherit (package-source libcxx))
+       (uri (string-append "http://llvm.org/releases/"
+                           version "/libcxx-" version ".src.tar.xz"))
+       (sha256
+        (base32
+         "0rzw4qvxp6qx4l4h9amrq02gp7hbg8lw4m0sy3k60f50234gnm3n"))))
+    (native-inputs
+     `(("clang" ,clang-6)
+       ("llvm" ,llvm-6)))
+    (arguments
+     `(#:phases
+       (modify-phases %standard-phases
+         (add-after 'install 'use-only-required-headers
+           (lambda* (#:key outputs #:allow-other-keys)
+             (use-modules ((srfi srfi-1)))
+             (let ((out (assoc-ref outputs "out"))
+                   (required-headers
+                    '("type_traits"
+                      "__config"
+                      "cstddef"
+                      "__nullptr"
+                      "utility"
+                      "__tuple"
+                      "initializer_list"
+                      "cstring"
+                      "cstdint"
+                      "__debug")))
+               (for-each
+                delete-file
+                (filter
+                 (lambda (file)
+                   (not
+                    (fold
+                     (lambda (acc header)
+                       (or acc (string-contains file header)))
+                     #f
+                     required-headers)))
+                 (find-files (string-append out "/include/c++/v1"))))
+               (delete-file-recursively (string-append out "/include/c++/v1/ext"))
+               (delete-file-recursively (string-append out "/include/c++/v1/support"))
+               (delete-file-recursively (string-append out "/lib")))
+             #t)))))
+    (synopsis
+     "Libcxx files specifically used by PySide2")
+    (description
+     "Libcxx files specifically used by PySide2.")))
-- 
2.22.0

From 1562b14afb469b7f31121145b2899a37eeb346ba Mon Sep 17 00:00:00 2001
From: John Soo <[email-masked]>
Date: Sat, 6 Jul 2019 09:13:50 -0700
Subject: [PATCH 04/11] gnu: Add python-shiboken-2.

* gnu/packages/python-xyz.scm (python-shiboken-2): New variable.
---
 gnu/packages/python-xyz.scm | 47 +++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index d8f144893d..e1a3e387a1 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -64,6 +64,7 @@
 ;;; Copyright © 2019 Alex Griffin <[email-masked]>
 ;;; Copyright © 2019 Pierre Langlois <[email-masked]>
 ;;; Copyright © 2019 Jacob MacDonald <[email-masked]>
+;;; Copyright © 2019 John Soo <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -16041,3 +16042,49 @@ one-off scripts.")
 time-or-computationally-expensive properties quick and easy and works in Python
 2 or 3.")
     (license license:bsd-3)))
+
+(define-public python-shiboken-2
+  (let ((revision "1")
+        (commit "4018787a3cc01d632fdca7891ac8aa9487110c26"))
+    (package
+      (name "python-shiboken-2")
+      (version (git-version "v5.11.3" revision commit))
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://code.qt.io/pyside/pyside-setup")
+               (commit commit)))
+         (file-name (git-file-name name version))
+         (sha256
+          (base32
+           "0g8jacm2iqd7lw2m7f1dp1nnrsk38bl3m8pihm8zz9gxs8d31sf5"))))
+      (build-system cmake-build-system)
+      (inputs
+       `(("llvm-toolchain-6" ,llvm-toolchain-6)
+         ("libxml2" ,libxml2)
+         ("libxslt" ,libxslt)
+         ("python-wrapper" ,python-wrapper)
+         ("qtbase" ,qtbase)
+         ("qtxmlpatterns" ,qtxmlpatterns)))
+      (arguments
+       `(#:tests? #f
+         #:configure-flags '("-DBUILD_TESTS=off")
+         #:phases
+         (modify-phases
+             %standard-phases
+           (add-after 'unpack 'use-shiboken-dir-only
+             (lambda _ (chdir "sources/shiboken2") #t))
+           (add-before 'configure 'set-build-env
+             (lambda* (#:key inputs #:allow-other-keys)
+               (let ((llvm-toolchain-dir (assoc-ref inputs "llvm-toolchain-6")))
+                 (setenv "CLANG_INSTALL_DIR" llvm-toolchain-dir)
+                 #t))))))
+      (home-page "https://wiki.qt.io/Qt_for_Python")
+      (synopsis
+       "Shiboken generates bindings for C++ libraries using CPython source code")
+      (description
+       "Shiboken generates bindings for C++ libraries using CPython source code")
+      ;; Help!
+      (license `(,license:gpl2+
+                 ,license:llgpl)))))
-- 
2.22.0

From 0ea619013412883a6f6e77a9cdd3cae2c61dae52 Mon Sep 17 00:00:00 2001
From: John Soo <[email-masked]>
Date: Thu, 4 Jul 2019 16:29:24 -0700
Subject: [PATCH 02/11] gnu: Add soqt.

* gnu/packages/graphics.scm (soqt): New variable.
---
 gnu/packages/graphics.scm | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/gnu/packages/graphics.scm b/gnu/packages/graphics.scm
index 0e42f80a87..75d43c346f 100644
--- a/gnu/packages/graphics.scm
+++ b/gnu/packages/graphics.scm
@@ -53,6 +53,7 @@
   #:use-module (gnu packages image)
   #:use-module (gnu packages imagemagick)
   #:use-module (gnu packages jemalloc)
+  #:use-module (gnu packages llvm)
   #:use-module (gnu packages multiprecision)
   #:use-module (gnu packages pdf)
   #:use-module (gnu packages perl)
@@ -1027,3 +1028,38 @@ standard graphics library for 3D visualization and visual simulation
 software in the scientific and engineering community.")
       (license license:bsd-3))))
 
+(define-public soqt
+  (let ((changeset "58b495aa6bed9e58542e60df28843f58e2ab8db4")
+        (revision "1"))
+    (package
+      (name "soqt")
+      (version
+       (string-append "1.6.0-" revision "." (string-take changeset 7)))
+      (source
+       (origin
+         (method hg-fetch)
+         (uri (hg-reference (url "https://bitbucket.org/Coin3d/soqt")
+                            (changeset changeset)))
+         (sha256
+          (base32
+           "023rhf8piwcmgi08d3xyqj1cj83v30z6l3zbd5qs1y1mkw9lqfpz"))
+         (file-name (git-file-name "soqt" version))))
+      (build-system cmake-build-system)
+      (native-inputs
+       `(("doxygen" ,doxygen)
+         ("graphviz" ,graphviz)))
+      (inputs
+       `(("coin3D" ,coin3D)
+         ("glew" ,glew)
+         ("libcxx" ,libcxx)
+         ("qtbase" ,qtbase)))
+      (arguments `(#:tests? #f))
+      (home-page "https://bitbucket.org/Coin3D/soqt")
+      (synopsis
+       "GUI component toolkit library for Coin")
+      (description
+       "SoQt is a Qt GUI component toolkit library for Coin.  It is also
+compatible with SGI and TGS Open Inventor, and the API is based on the API of
+the InventorXt GUI component toolkit.")
+      (license license:bsd-3))))
+
-- 
2.22.0

From 971abce6868ef86b241834786936e9a397bb06b4 Mon Sep 17 00:00:00 2001
From: John Soo <[email-masked]>
Date: Sat, 6 Jul 2019 08:34:24 -0700
Subject: [PATCH 03/11] gnu: Add llvm-toolchain-6.

* gnupackages/llvm.scm (llvm-toolchain-6): New variable.
---
 gnu/packages/llvm.scm | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
index 1fe9af38e0..188d0bb267 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -11,6 +11,7 @@
 ;;; Copyright © 2018 Tim Gesthuizen <[email-masked]>
 ;;; Copyright © 2018 Pierre Neidhardt <[email-masked]>
 ;;; Copyright © 2019 Rutger Helling <[email-masked]>
+;;; Copyright © 2019 John Soo <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -37,6 +38,7 @@
   #:use-module (guix build-system cmake)
   #:use-module (guix build-system emacs)
   #:use-module (guix build-system python)
+  #:use-module (guix build-system trivial)
   #:use-module (gnu packages)
   #:use-module (gnu packages gcc)
   #:use-module (gnu packages bootstrap)           ;glibc-dynamic-linker
@@ -667,3 +669,36 @@ C/C++/Obj-C code according to a set of style options, see
     (synopsis "Rename every occurrence of a symbol using clang-rename")
     (description "This package renames every occurrence of a symbol at point
 using @code{clang-rename}.")))
+
+;; PySide2 docs recommend using a bundled version of libclang
+;; See https://wiki.qt.io/Qt_for_Python/GettingStarted
+;; The source they recommend: https://download.qt.io/development_releases/prebuilt/libclang/
+(define-public llvm-toolchain-6
+  (package
+    (inherit llvm-6)
+    (name "llvm-toolchain")
+    (build-system trivial-build-system)
+    (inputs
+     `(("clang-6" ,clang-6)
+       ("llvm-6" ,llvm-6)))
+    (arguments
+     `(#:modules ((guix build union)
+                  (guix build utils))
+       #:builder
+       (begin
+         (use-modules (guix build union)
+                      (ice-9 match)
+                      (srfi srfi-1))
+         (union-build
+          (assoc-ref %outputs "out")
+          (filter-map
+           (match-lambda
+             ((name . dir)
+              (if (or (string=? name "clang-6")
+                      (string=? name "llvm-6"))
+                  dir
+                  #f)))
+           %build-inputs))
+         #t)))
+    (license license:ncsa)))
+
-- 
2.22.0

From 83d720573955b0d4d7b613307d1e0821ab01cfad Mon Sep 17 00:00:00 2001
From: John Soo <[email-masked]>
Date: Sat, 6 Jul 2019 18:49:08 -0700
Subject: [PATCH 07/11] gnu: Add python-pyside-2-tools.

* gnu/packages/python-xyz.scm (python-pyside-2-tools): New variable.
---
 gnu/packages/python-xyz.scm | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index 3c724f1398..2a984cda4b 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -16165,3 +16165,35 @@ which can be used to generate Python bindings for your C or C++ code.")
       ;; Help!
       (license `(,license:gpl2+
                  ,license:llgpl)))))
+
+(define-public python-pyside-2-tools
+  (let ((revision "1")
+        (commit "f1b775537e7fbd718516749583b2abf1cb6adbce"))
+    (package
+      (name "python-pyside-2-tools")
+      (version (git-version "v5.11.2" revision commit))
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://code.qt.io/pyside/pyside-tools")
+               (commit commit)))
+         (file-name (git-file-name name version))
+         (sha256
+          (base32
+           "1w2g5afvww9r89wmdm9jx8sz67x4bzy9difkh72n4c73ya1n91ry"))))
+      (build-system cmake-build-system)
+      (inputs
+       `(("python-pyside-2" ,python-pyside-2)
+         ("python-shiboken-2" ,python-shiboken-2)
+         ("qtbase" ,qtbase)))
+      (arguments
+       `(#:tests? #f
+         #:configure-flags '("-DBUILD_TESTS=off")))
+      (home-page "https://wiki.qt.io/Qt_for_Python")
+      (synopsis
+       "Contains lupdate, rcc and uic tools for PySide2")
+      (description
+       "Contains lupdate, rcc and uic tools for PySide2")
+      ;; Help! (This is from arch)
+      (license license:lgpl2.1+))))
-- 
2.22.0

From 46c7ec4990291f437311064955621cdd9a69c4b1 Mon Sep 17 00:00:00 2001
From: John Soo <[email-masked]>
Date: Sat, 6 Jul 2019 11:21:14 -0700
Subject: [PATCH 06/11] gnu: Add python-pyside-2.

* gnu/packages/python-xyz.scm (python-pyside-2): New variable.
---
 gnu/packages/python-xyz.scm | 77 +++++++++++++++++++++++++++++++++++++
 1 file changed, 77 insertions(+)

diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index e1a3e387a1..3c724f1398 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -90,6 +90,7 @@
   #:use-module (gnu packages backup)
   #:use-module (gnu packages bash)
   #:use-module (gnu packages check)
+  #:use-module (gnu packages cmake)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages crypto)
   #:use-module (gnu packages databases)
@@ -16043,6 +16044,82 @@ time-or-computationally-expensive properties quick and easy and works in Python
 2 or 3.")
     (license license:bsd-3)))
 
+(define-public python-pyside-2
+  (let ((revision "1")
+        (commit "4018787a3cc01d632fdca7891ac8aa9487110c26"))
+    (package
+      (name "python-pyside-2")
+      (version (git-version "v5.11.3" revision commit))
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://code.qt.io/pyside/pyside-setup")
+               (commit commit)))
+         (file-name (git-file-name name version))
+         (sha256
+          (base32
+           "0g8jacm2iqd7lw2m7f1dp1nnrsk38bl3m8pihm8zz9gxs8d31sf5"))))
+      (build-system cmake-build-system)
+      (inputs
+       `(("python-pyside-2-libcxx-headers" ,python-pyside-2-libcxx-headers)
+         ("libxml2" ,libxml2)
+         ("libxslt" ,libxslt)
+         ("llvm-toolchain-6" ,llvm-toolchain-6)
+         ("qtbase" ,qtbase)
+         ("qtdatavis3d" ,qtdatavis3d)
+         ("qtmultimedia" ,qtmultimedia)
+         ("qtquickcontrols" ,qtquickcontrols) ;; ??
+         ("qtscript" ,qtscript)
+         ("qtscxml" ,qtscxml)
+         ("qtsensors" ,qtsensors)
+         ("qtspeech" ,qtspeech)
+         ("qtsvg" ,qtsvg)
+         ("qtwebchannel" ,qtwebchannel)
+         ("qtwebsockets" ,qtwebsockets)
+         ("qtx11extras" ,qtx11extras)))
+      (native-inputs
+       `(("cmake" ,cmake)
+         ("git" ,git)
+         ("python-shiboken-2" ,python-shiboken-2)
+         ("python-wrapper" ,python-wrapper)
+         ("qttools" ,qttools)
+         ("which" ,which)))
+      (arguments
+       `(#:tests? #f
+         #:configure-flags '("-DBUILD_TESTS=off")
+         #:phases
+         (modify-phases
+             %standard-phases
+           (add-after 'unpack 'go-to-source-dir
+             (lambda _ (chdir "sources/pyside2") #t))
+           (add-before 'configure 'set-clang-dir
+             (lambda* (#:key inputs #:allow-other-keys)
+               (let ((clang-dir (assoc-ref inputs "llvm-toolchain-6"))
+                     (libcxx-dir (assoc-ref inputs "python-pyside-2-libcxx-headers")))
+                 (setenv "CLANG_INSTALL_DIR" clang-dir)
+                 (substitute* "cmake/Macros/PySideModules.cmake"
+                   (("--include-paths=")
+                    (string-append "--include-paths=" libcxx-dir "/include/c++/v1:")))
+                 #t))))))
+      (home-page "https://wiki.qt.io/Qt_for_Python")
+      (synopsis
+       "The Qt for Python product enables the use of Qt5 APIs in Python applications")
+      (description
+       "The Qt for Python product enables the use of Qt5 APIs in Python applications.
+It lets Python developers utilize the full potential of Qt, using the PySide2 module.
+The PySide2 module provides access to the individual Qt modules such as QtCore, QtGui,
+and so on.  Qt for Python also comes with the Shiboken2 CPython binding code generator,
+which can be used to generate Python bindings for your C or C++ code.")
+      ;; Help!
+      (license
+       `(,license:fdl1.3+
+         ,license:gpl2+
+         ,license:gpl3+
+         ;; https://code.qt.io/cgit/pyside/pyside-setup.git/tree/LICENSE.GPLv3-EXCEPT
+         ;; https://code.qt.io/cgit/pyside/pyside-setup.git/tree/LICENSE.COMMERCIAL
+         ,license:lgpl3)))))
+
 (define-public python-shiboken-2
   (let ((revision "1")
         (commit "4018787a3cc01d632fdca7891ac8aa9487110c26"))
-- 
2.22.0

From d272d9c7d5582e85c8e35a6414b56ebe5d549f92 Mon Sep 17 00:00:00 2001
From: John Soo <[email-masked]>
Date: Sat, 6 Jul 2019 19:05:37 -0700
Subject: [PATCH 08/11] gnu: Add libspnav.

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

diff --git a/gnu/packages/engineering.scm b/gnu/packages/engineering.scm
index 7d48414889..366307cb2f 100644
--- a/gnu/packages/engineering.scm
+++ b/gnu/packages/engineering.scm
@@ -11,6 +11,7 @@
 ;;; Copyright © 2018, 2019 Jonathan Brielmaier <[email-masked]>
 ;;; Copyright © 2018, 2019 Arun Isaac <[email-masked]>
 ;;; Copyright © 2019 Tim Stahel <[email-masked]>
+;;; Copyright © 2019 John Soo <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -2062,3 +2063,41 @@ purpose circuit simulator and can perform DC and transient analyses, fourier
 analysis and AC analysis.  The engine is designed to do true mixed-mode
 simulation.")
     (license license:gpl3+)))
+
+(define-public libspnav
+  (let ((commit "20961617eecc845b23fcf9e06acd1a6bb340b88b")
+        (revision "1"))
+    (package
+      (name "libspnav")
+      (version (git-version "0.2.3" revision commit))
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://github.com/FreeSpacenav/libspnav")
+               (commit commit)))
+         (file-name (git-file-name name version))
+         (sha256
+          (base32
+           "1ib5jxcpz76lr90f69vb50yn2q9ss45axlgil29layh36dnyifac"))))
+      (build-system gnu-build-system)
+      (inputs
+       `(("libx11" ,libx11)))
+      (arguments `(#:tests? #f))
+      (home-page "http://spacenav.sourceforge.net/")
+      (synopsis
+       "Library for communicating with spacenavd or 3dxsrv")
+      (description
+       "The libspnav library is provided as a replacement of the magellan
+library.  It provides a cleaner, and more orthogonal interface.  libspnav
+supports both the original X11 protocol for communicating with the driver, and
+the new alternative non-X protocol.  Programs that choose to use the X11
+protocol, are automatically compatible with either the free spacenavd driver
+or the official 3dxserv, as if they were using the magellan SDK.
+
+Also, libspnav provides a magellan API wrapper on top of the new API.  So, any
+applications that were using the magellan library, can switch to libspnav
+without any changes.  And programmers that are familliar with the magellan API
+can continue using it with a free library without the restrictions of the
+official SDK.")
+      (license license:bsd-3))))
-- 
2.22.0

From a9ba800f97e08b98e36c0a985e56be650f576c2d Mon Sep 17 00:00:00 2001
From: John Soo <[email-masked]>
Date: Sun, 7 Jul 2019 10:03:38 -0700
Subject: [PATCH 09/11] gnu: Add libarea.

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

diff --git a/gnu/packages/engineering.scm b/gnu/packages/engineering.scm
index 366307cb2f..4c97b32bf9 100644
--- a/gnu/packages/engineering.scm
+++ b/gnu/packages/engineering.scm
@@ -49,6 +49,7 @@
   #:use-module (gnu packages bison)
   #:use-module (gnu packages boost)
   #:use-module (gnu packages check)
+  #:use-module (gnu packages cmake)
   #:use-module (gnu packages commencement)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages curl)
@@ -2064,6 +2065,51 @@ analysis and AC analysis.  The engine is designed to do true mixed-mode
 simulation.")
     (license license:gpl3+)))
 
+
+;; TODO: Try the google archive version with gplv3
+;; subversion url:
+;;   svn checkout http://libarea.googlecode.com/svn/trunk/ libarea
+(define-public libarea
+  (let ((revision "1")
+        (commit "8f8bac811c10f1f01fda0d742a18591f61dd76ee"))
+    (package
+      (name "libarea")
+      (version (git-version "0" revision commit))
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference (url "https://github.com/Heeks/libarea.git")
+                             (commit commit)))
+         (file-name (git-file-name name version))
+         (sha256
+          (base32 "0pvqz6cabxqdz5y26wnj6alkn8v5d7gkx0d3h8xmg4lvy9r3kh3g"))))
+      (build-system gnu-build-system)
+      (inputs `(("boost" ,boost)
+                ("python-wrapper" ,python-wrapper)))
+      (native-inputs
+       `(("cmake" ,cmake)))
+      (arguments
+       `(#:tests? #f
+         #:phases
+         (modify-phases %standard-phases
+           (add-after 'configure 'cmake-configure
+             (lambda* (#:key inputs outputs #:allow-other-keys)
+               (let ((out (assoc-ref outputs "out"))
+                     (cmake (assoc-ref inputs "cmake")))
+                 (mkdir-p "build")
+                 (invoke "cmake"
+                         (string-append "-DCMAKE_INSTALL_PREFIX=" out)))))
+           (delete 'configure))))
+      (home-page "https://github.com/Heeks/libarea")
+      (synopsis
+       "Library and python module for pocketing and profiling operations")
+      (description
+       "Area is a CAM-related software for pocketing operation.
+
+This project provides library and associated python-module to compute pocket
+operations.")
+      (license license:gpl3+))))
+
 (define-public libspnav
   (let ((commit "20961617eecc845b23fcf9e06acd1a6bb340b88b")
         (revision "1"))
-- 
2.22.0

From 013aa0d66718ba8692e6e5703a77e54527fa3fd5 Mon Sep 17 00:00:00 2001
From: John Soo <[email-masked]>
Date: Sun, 7 Jul 2019 10:13:17 -0700
Subject: [PATCH 10/11] gnu: Add libmedfile.

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

diff --git a/gnu/packages/engineering.scm b/gnu/packages/engineering.scm
index 4c97b32bf9..f10b6dff98 100644
--- a/gnu/packages/engineering.scm
+++ b/gnu/packages/engineering.scm
@@ -2066,6 +2066,35 @@ simulation.")
     (license license:gpl3+)))

+(define-public libmedfile
+  (package
+    (name "libmedfile")
+    (version "3.3.1")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append
+             "https://files.salome-platform.org/Salome/other/med-"
+             version ".tar.gz"))
+       (sha256
+        (base32
+         "1215sal10xp6xirgggdszay2bmx0sxhn9pgh7x0wg2w32gw1wqyx"))))
+    (build-system cmake-build-system)
+    (inputs `(("hdf5" ,hdf5)))
+    (arguments
+     `(#:phases
+       (modify-phases %standard-phases
+         (add-after 'install 'remove-test-output
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let ((out (assoc-ref outputs "out")))
+               (delete-file-recursively
+                (string-append out "/bin/testc"))
+               #t))))))
+    (home-page "https://www.salome-platform.org")
+    (synopsis "Library to read and write MED files")
+    (description "Library to read and write MED files")
+    (license license:gpl3+)))
+
 ;; TODO: Try the google archive version with gplv3
 ;; subversion url:
 ;;   svn checkout http://libarea.googlecode.com/svn/trunk/ libarea
-- 
2.22.0

From 93c7a987e98e04ab0eb099a5cc8a6d53313f84a1 Mon Sep 17 00:00:00 2001
From: John Soo <[email-masked]>
Date: Sun, 7 Jul 2019 10:32:10 -0700
Subject: [PATCH 11/11] gnu: Add freecad.

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

diff --git a/gnu/packages/engineering.scm b/gnu/packages/engineering.scm
index f10b6dff98..16e98b1dff 100644
--- a/gnu/packages/engineering.scm
+++ b/gnu/packages/engineering.scm
@@ -53,6 +53,7 @@
   #:use-module (gnu packages commencement)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages curl)
+  #:use-module (gnu packages documentation)
   #:use-module (gnu packages flex)
   #:use-module (gnu packages fontutils)
   #:use-module (gnu packages fpga)
@@ -65,10 +66,13 @@
   #:use-module (gnu packages glib)
   #:use-module (gnu packages gnome)
   #:use-module (gnu packages gperf)
+  #:use-module (gnu packages graphics)
+  #:use-module (gnu packages graphviz)
   #:use-module (gnu packages groff)
   #:use-module (gnu packages gtk)
   #:use-module (gnu packages guile)
   #:use-module (gnu packages image)
+  #:use-module (gnu packages image-processing)
   #:use-module (gnu packages imagemagick)
   #:use-module (gnu packages linux)               ;FIXME: for pcb
   #:use-module (gnu packages m4)
@@ -89,6 +93,7 @@
   #:use-module (gnu packages tex)
   #:use-module (gnu packages version-control)
   #:use-module (gnu packages wxwidgets)
+  #:use-module (gnu packages xml)
   #:use-module (gnu packages xorg))
 
 (define-public librecad
@@ -2065,6 +2070,87 @@ analysis and AC analysis.  The engine is designed to do true mixed-mode
 simulation.")
     (license license:gpl3+)))
 
+(define-public freecad
+  (let ((commit "3129ae4296e40ed20e7b3d460b86e6969acbe1c3")
+        (revision "1"))
+    (package
+      (name "freecad")
+      (version (git-version "0.18.3" revision commit))
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://github.com/FreeCAD/FreeCAD.git")
+               (commit commit)))
+         (file-name (git-file-name name version))
+         (sha256
+          (base32
+           "1ny29y0h8smg1bwi5yn4kcnyfprqh3v7v2z8837cmmhcwp8dr95m"))))
+      (build-system cmake-build-system)
+      (native-inputs
+       `(("doxygen" ,doxygen)
+         ("graphviz" ,graphviz)
+         ("qttools" ,qttools)
+         ("pkg-config" ,pkg-config)
+         ("swig" ,swig)))
+      (inputs
+       `(("boost" ,boost)
+         ("coin3D" ,coin3D)
+         ("eigen" ,eigen)
+         ("freetype" ,freetype)
+         ("glew" ,glew)
+         ("hdf5" ,hdf5)
+         ("libarea" ,libarea)
+         ("libspnav" ,libspnav)
+         ("libmedfile" ,libmedfile)
+         ("openmpi" ,openmpi)
+         ("opencascade-oce" ,opencascade-oce)
+         ("python-matplotlib" ,python-matplotlib)
+         ("python-pyside-2" ,python-pyside-2)
+         ("python-pyside-2-tools" ,python-pyside-2-tools)
+         ("python-shiboken-2" ,python-shiboken-2)
+         ("python-wrapper" ,python-wrapper)
+         ("qtbase" ,qtbase)
+         ("qtsvg" ,qtsvg)
+         ("qtx11extras" ,qtx11extras)
+         ("qtxmlpatterns" ,qtxmlpatterns)
+         ("qtwebkit" ,qtwebkit)
+         ("soqt" ,soqt)
+         ("vtk" ,vtk)
+         ("xerces-c" ,xerces-c)
+         ("zlib" ,zlib)))
+      (arguments
+       `(#:tests? #f
+         #:configure-flags
+         (list
+          "-DBUILD_QT5=ON"
+          (string-append "-DCMAKE_INSTALL_LIBDIR="
+                         (assoc-ref %outputs "out") "/lib"))
+         #:phases
+         (modify-phases %standard-phases
+           (add-before 'configure 'restore-pythonpath
+             (lambda _
+               (substitute* "src/Main/MainGui.cpp"
+                 (("_?putenv\\(\"PYTHONPATH=\"\\);") ""))
+               #t))
+           (add-after 'install 'wrap-pythonpath
+             (lambda* (#:key outputs #:allow-other-keys)
+               (let ((out (assoc-ref outputs "out")))
+                 (wrap-program (string-append out "/bin/FreeCAD")
+                   (list "PYTHONPATH"
+                         'prefix (list (getenv "PYTHONPATH")))))
+               #t)))))
+      (home-page "https://www.freecadweb.org/")
+      (synopsis "Your Own 3D Parametric Modeler")
+      (description
+       "FreeCAD is a general purpose feature-based, parametric 3D modeler for
+CAD, MCAD, CAx, CAE and PLM, aimed directly at mechanical engineering and
+product design but also fits a wider range of uses in engineering, such as
+architecture or other engineering specialties.  It is 100% Open Source (LGPL2+
+license) and extremely modular, allowing for very advanced extension and
+customization.")
+      ;; Help!
+      (license license:lgpl2.1+))))
 
 (define-public libmedfile
   (package
-- 
2.22.0