diff mbox

Stuck on KiCad dependency wxPython

Message ID 87twcyb46k.fsf@openmailbox.org
State New
Headers show

Commit Message

Theodoros Foradis Sept. 30, 2016, 12:51 a.m. UTC
Danny Milosavljevic writes:

> Or maybe the attached patch captures the goal of wxwidgets better (which they IMO don't succeed at).
>
> I added gtk, opengl etc as native inputs instead of regular inputs because from the point of view of Python they are not direct inputs.
>
> wxPython only requires gtk while building the extension because wxwidgets does #include <gtk/gtk.h> in their exported API (why...) - but after it's done it will not require it directly anymore and actually just require wxwidgets.
>
> Of course, the gtk version of wxwidgets will still require gtk by itself.
>
> That said, I still think it would be nicer if wxwidgets propagated gtk - since when you use wxwidgets, you also need to have gtk as well if wxwidgets was compiled for gtk - and the one deciding what wxwidgets is compiled for is the wxwidgets package. So it should go there...
>
> What do you think?

Hello,

I worked on your wxpython patch, and got wxpython to build, with kicad on top
of it. Quite a lot of problems exist in the packages as of now.

Regarding kicad, the built binary has the following issues:
-In eeschema, the screen does not get redrawn automatically, leaving
mouse traces. I found somewhere some suggestions, that building
wxwidgets3.0 with gtk2 solves the issue, but I tried that and it does
not.
-When pcbnew is fired up, there is a "pcbnewInitPythonScripting() failed."
message. Trying again, it opens normally (and effectively shows
drawn pcb layouts), but with ui resizing issues. The ui resizing issues
exist everywhere.
-I have not added the kicad-libraries(components and footprints) in the package yet.

On the build side of things, first of all, the update to boost 1.61.0
breaks the build of kicad, with a header missing error. I have reverted
the latest changes in boost (to 1.60.1), in the patch, for development purposes.

The wxpython package tries to install the wxPython headers in
gnu/store/...-wxwidgets-3.0.2/include by default. I force set WXPREFIX
in config.py to get around that. In turn, in the kicad package, the
include path has to be set with a cmake flag, to find the wxPython
headers. I am sure there is a better way to handle this, but this is how I got it
to build for now.

The phase that replaces 'install in wxpython, can be obviously ommitted, if
your patch to honor configure-flags in python build phase is accepted.

I think you are correct, in that wxwidgets should propagate gtk.

I am waiting for some feedback on the patch.

Greetings

Comments

Danny Milosavljevic Sept. 30, 2016, 7:09 a.m. UTC | #1
Hi,

your patch looks good. But I'd rather not downgrade boost and neither do I want to carry a second boost on my system.

> On the build side of things, first of all, the update to boost 1.61.0
> breaks the build of kicad, with a header missing error. I have reverted
> the latest changes in boost (to 1.60.1), in the patch, for development purposes.

Boost 1.61.0 can be used in KiCad after applying <https://github.com/KiCad/kicad-source-mirror/commit/06d4894fdbeb00727cdcc667b8899ad73d8eb1c2> (which has been applied upstream). That is a mirror site - I'm just using it because of the nice syntax highlighting so you can read it better.

I also have the redrawing and resizing problems with the patch - I thought it was a general KiCad bug.

I think that it would be good to use git-download in the package definition and see whether all the problems vanish. If not we should notify them of the problems (the redrawing, resizing etc). 

The git-download would be:

...
  #:use-module (guix git-download)
...
      (source
        (origin
          (method git-fetch)
          (uri (git-reference
                 (url "https://git.launchpad.net/kicad")
                 (commit commit))) ; FIXME find a good commit
          (sha256
            (base32
              "0cm47s5pvijfs3v2k7hmpxv3mvp4n5la0ihnsczk5ym3iq166jil")) ;  FIXME update
          (file-name (string-append name "-" version "-checkout"))))


> -I have not added the kicad-libraries(components and footprints) in the package yet.

We should add components and footprints in an extra package - because many people use external footprint repos (tuned for their manufacturing tolerances) and don't need the "official" ones at all.

> The wxpython package tries to install the wxPython headers in
> gnu/store/...-wxwidgets-3.0.2/include by default. I force set WXPREFIX
> in config.py to get around that. 

Good :)

>In turn, in the kicad package, the
> include path has to be set with a cmake flag, to find the wxPython
> headers. 

The discovery of wxpython in kicad works via CMakeLists.txt :

        set( PYTHON_DEST ${LIBWXPYTHON_ROOT}/wxPython/lib/python2.6/site-packages )

So it might be enough to

    (setenv "LIBWXPYTHON_ROOT" (assoc-ref inputs "python2-wxpython"))

after we make python2-wxpython install to $out/wxPython . Or we could patch CMakeLists.txt to s/wxPython// and do the latter.

I'm not sure whether either would be an improvement, though.

> The phase that replaces 'install in wxpython, can be obviously ommitted, if
> your patch to honor configure-flags in python build phase is accepted.

'build - yes. It's interesting that few packages seem to be affected by missing build flags without the patch. Either that or they broke silently :P

> I think you are correct, in that wxwidgets should propagate gtk.
diff mbox

Patch

 gnu/packages/boost.scm       |  8 ++--
 gnu/packages/engineering.scm | 63 +++++++++++++++++++++++++++++
 gnu/packages/wxwidgets.scm   | 94 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 160 insertions(+), 5 deletions(-)

diff --git a/gnu/packages/boost.scm b/gnu/packages/boost.scm
index ab31fa8..8fe8c8e 100644
--- a/gnu/packages/boost.scm
+++ b/gnu/packages/boost.scm
@@ -34,7 +34,7 @@ 
 (define-public boost
   (package
     (name "boost")
-    (version "1.61.0")
+    (version "1.60.0")
     (source (origin
               (method url-fetch)
               (uri (string-append
@@ -43,7 +43,7 @@ 
                     ".tar.bz2"))
               (sha256
                (base32
-                "0h5nk7pgxf7xsvvshj9qfpsfp9wx6gq9r78n3nx736pxq83bsix5"))))
+                "0fzx6dwqbrkd4bcd8pjv0fpapwmrxxwr8yx9g67lihlsk3zzysk8"))))
     (build-system gnu-build-system)
     (inputs `(("zlib" ,zlib)))
     (native-inputs
@@ -90,9 +90,7 @@ 
          (replace
              'build
            (lambda* (#:key outputs make-flags #:allow-other-keys)
-             (zero? (apply system* "./b2"
-                           (format #f "-j~a" (parallel-job-count))
-                           make-flags))))
+             (zero? (apply system* "./b2" make-flags))))
          (replace
              'install
            (lambda* (#:key outputs make-flags #:allow-other-keys)
diff --git a/gnu/packages/engineering.scm b/gnu/packages/engineering.scm
index dad38e0..d222bda 100644
--- a/gnu/packages/engineering.scm
+++ b/gnu/packages/engineering.scm
@@ -28,6 +28,7 @@ 
   #:use-module (guix store)
   #:use-module (guix utils)
   #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (guix build-system cmake)
   #:use-module (guix build-system gnu)
   #:use-module (gnu packages)
   #:use-module (gnu packages autotools)
@@ -50,9 +51,14 @@ 
   #:use-module (gnu packages maths)
   #:use-module (gnu packages perl)
   #:use-module (gnu packages pkg-config)
+  #:use-module (gnu packages python)
   #:use-module (gnu packages qt)
+  #:use-module (gnu packages swig)
   #:use-module (gnu packages tcl)
+  #:use-module (gnu packages tls)
   #:use-module (gnu packages tex)
+  #:use-module (gnu packages wxwidgets)
+  #:use-module (gnu packages xorg)
   #:use-module (srfi srfi-1))
 
 (define-public librecad
@@ -460,3 +466,60 @@  you load several files on top of each other, do measurements on the displayed
 image, etc.  Besides viewing Gerbers, you may also view Excellon drill files
 as well as pick-place files.")
     (license license:gpl2+)))
+
+(define-public kicad
+  (package
+    (name "kicad")
+    (version "4.0.4")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "https://launchpad.net/kicad/4.0/"
+                                  version "/+download/kicad-" version ".tar.xz"))
+              (sha256
+               (base32
+                "006sgv446wwm0apvb5l52q9dfi8v85abkr7ms2scbab3pkvx79bd"))))
+    (build-system cmake-build-system)
+    (arguments
+     `(#:out-of-source? #t
+       ;; #:parallel-build? #f
+       #:tests? #f
+       #:configure-flags (list "-DKICAD_STABLE_VERSION=ON"
+                               "-DKICAD_REPO_NAME=stable"
+                               "-DKICAD_BUILD_VERSION=4.0.4"
+                               "-DCMAKE_BUILD_TYPE=Release"
+                               "-DKICAD_SKIP_BOOST=ON"
+                               "-DKICAD_SCRIPTING=ON"
+                               "-DKICAD_SCRIPTING_MODULES=ON"
+                               "-DKICAD_SCRIPTING_WXPYTHON=ON"
+                               ;; Has to be set explicitely, because we don't have the wxPython
+                               ;; headers in the wxwidgets store item, but in wxPython.
+                               (string-append "-DCMAKE_CXX_FLAGS=-I"
+                                              (assoc-ref %build-inputs "wxpython")
+                                              "/include/wx-3.0")
+                               ;; "-DBUILD_GITHUB_PLUGIN=ON"
+                               )))
+    (native-inputs
+     `(("boost" ,boost)
+       ("gettext" ,gnu-gettext)
+       ("mesa" ,mesa)
+       ("pkg-config" ,pkg-config)
+       ("swig" ,swig)
+       ("zlib" ,zlib)))
+    (inputs
+     `(("cairo" ,cairo)
+       ("desktop-file-utils" ,desktop-file-utils)
+       ("glew" ,glew)
+       ("hicolor-icon-theme" ,hicolor-icon-theme)
+       ("libsm" ,libsm)
+       ("openssl" ,openssl)
+       ("python" ,python-2)
+       ("wxwidgets" ,wxwidgets)
+       ("wxpython" ,python2-wxpython)))
+    (home-page "http://http://kicad-pcb.org/")
+    (synopsis "Electronics Design Automation Suite")
+    (description
+     "Kicad is created for the formation of printed circuit boards and electrical circuits.
+      The software has a number of programs that perform specific functions, for example,
+      pcbnew (Editing PCB), eeschema (editing electrical diagrams), gerbview (viewing Gerber
+      files) and others. ")
+    (license license:gpl3+)))
diff --git a/gnu/packages/wxwidgets.scm b/gnu/packages/wxwidgets.scm
index 31da2a9..69ab115 100644
--- a/gnu/packages/wxwidgets.scm
+++ b/gnu/packages/wxwidgets.scm
@@ -22,6 +22,7 @@ 
   #:use-module (guix download)
   #:use-module ((guix licenses) #:prefix l:)
   #:use-module (guix build-system glib-or-gtk)
+  #:use-module (guix build-system python)
   #:use-module (guix build utils)
   #:use-module (gnu packages)
   #:use-module (gnu packages compression)
@@ -31,8 +32,10 @@ 
   #:use-module (gnu packages gtk)
   #:use-module (gnu packages image)
   #:use-module (gnu packages pkg-config)
+  #:use-module (gnu packages python)
   #:use-module (gnu packages sdl)
   #:use-module (gnu packages webkit)
+  #:use-module (gnu packages xml)
   #:use-module (gnu packages xorg))
 
 (define-public wxwidgets
@@ -109,3 +112,94 @@  and many other languages.")
                             (assoc-ref %outputs "out") "/lib"))
        ;; No 'check' target.
        #:tests? #f))))
+
+(define-public python2-wxpython
+  (package
+    (name "python2-wxpython")
+    (version "3.0.2.0")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "mirror://sourceforge/wxpython/wxPython/"
+                                  version "/wxPython-src-" version ".tar.bz2"))
+              (sha256
+               (base32
+                "0qfzx3sqx4mwxv99sfybhsij4b5pc03ricl73h4vhkzazgjjjhfm"))
+              (modules '((guix build utils)))
+              (snippet
+               '(begin
+                  ;; TODO Audit fully
+                  (delete-file-recursively "src/expat")
+                  (delete-file-recursively "src/jpeg")
+                  (delete-file-recursively "src/png")
+                  (delete-file-recursively "src/tiff")
+                  (delete-file-recursively "src/zlib")
+
+
+                  (delete-file-recursively "src/msw")
+                  (delete-file-recursively "src/osx")
+                  (substitute* '("wxPython/setup.py")
+                    ;; setup.py tries to keep its own license the same as wxwidget's license (which it expects under $WXWIN/docs).
+                    (("'preamble.txt', 'licence.txt', 'licendoc.txt', 'lgpl.txt'") ""))
+                  ))))
+    (build-system python-build-system)
+    (arguments
+     `(#:python ,python-2
+       #:tests? #f ; FIXME re-enable
+       #:configure-flags
+       (list "WXPORT=gtk3"
+             "UNICODE=1")
+       #:modules ((guix build python-build-system)
+                  ((guix build gnu-build-system) #:prefix gnu:)
+                  (guix build utils))
+       #:phases
+       (modify-phases %standard-phases
+         (add-before 'build 'chdir
+           (lambda _
+             (chdir "wxPython")))
+         (add-after 'chdir 'set-wx-out-dir
+           (lambda* (#:key outputs #:allow-other-keys)
+             ;; By default, install phase tries to copy the wxPython headers in
+             ;; gnu/store/...-wxwidgets-3.0.2 , which it can't, so they are redirected
+             ;; the output directory by setting WXPREFIX.
+             (substitute* "config.py"
+               (("= getWxConfigValue\\('--prefix'\\)") (string-append "= '" (assoc-ref outputs "out") "'")))
+             (substitute* "wx/build/config.py"
+               (("= getWxConfigValue\\('--prefix'\\)") (string-append "= '" (assoc-ref outputs "out") "'")))))
+         (add-after 'set-wx-out-dir 'setenv
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (setenv "WXWIN" (assoc-ref inputs "wxwidgets"))
+             ;; FIXME better: just call wx-config --cppflags and set that (how?)
+             (setenv "CPPFLAGS" (string-append "-I"
+                                               (assoc-ref inputs "wxwidgets")
+                                               "/lib/wx/include/gtk3-unicode-3.0"
+                                               " -I"
+                                               (assoc-ref inputs "wxwidgets")
+                                               "/include/wx-3.0"
+                                               " -D_FILE_OFFSET_BITS=64"
+                                               " -DWXUSINGDLL"
+                                               " -D__WXGTK__"))))
+         ;; Can be removed with [PATCH] guix: python-build-system: Honor configure-flags
+         (replace 'build
+           (lambda* (#:key inputs #:allow-other-keys)
+             (zero?
+              (system* "python" "setup.py" "WXPORT=gtk3" "UNICODE=1" "build")))))))
+    (native-inputs
+     `(("pkg-config" ,pkg-config) ; for gtk
+       ("expat" ,expat)
+       ("gtk+" ,gtk+)
+       ("libjpeg" ,libjpeg)
+       ("libpng" ,libpng)
+       ("libtiff" ,libtiff)
+       ("libsm" ,libsm)
+       ("libx11" ,libx11)
+       ("mesa" ,mesa)
+       ("zlib" ,zlib)
+       ("python2-setuptools" ,python2-setuptools)))
+    (inputs
+     `(("wxwidgets" ,wxwidgets)))
+    (synopsis "Python2 Bindings for wxWidgets")
+    (description "@code{wxpython} are Python2 bindings for wxWidgets.")
+    (home-page "http://wxpython.org/")
+    (license l:fsf-free))) ; TODO Audit
+
+; Note: there's a Python 3 port https://wxpython.org/Phoenix/snapshot-builds/README.txt (no releases yet)
-- 
2.10.0