Skip to content

Packaging for GNU guix #14

Open
Open
@nomike

Description

@nomike

I'm trying to get tests running on the GNU guix package, but almost all of them fail like this:

          Start  842: preview-cgal_triangle-with-duplicate-vertex
 842/2660 Test  #842: preview-cgal_triangle-with-duplicate-vertex ....................***Failed    0.34 sec
triangle-with-duplicate-vertex
test_cmdline_tool: args:['/tmp/guix-build-pythonscad-2025.05.25-0.97c42c9.drv-0/source/tests/test_cmdline_tool.py', '--comparator=image_compare', '-c', '/tmp/guix-build-pythonscad-2025.05.25-0.97c42c9.drv-0/build/tests/venv/bin//python', '-s', 'png', '-e', 'preview', '-t', 'preview-cgal', '-f', 'triangle-with-duplicate-vertex', '/tmp/guix-build-pythonscad-2025.05.25-0.97c42c9.drv-0/build/openscad', '/tmp/guix-build-pythonscad-2025.05.25-0.97c42c9.drv-0/source/tests/data/scad/dxf/triangle-with-duplicate-vertex.scad', '--camera=0,0,100,0,0,0', '--viewall', '--autocenter', '--projection=ortho', '--backend=cgal'] 
test_cmdline_tool: getopt args:['/tmp/guix-build-pythonscad-2025.05.25-0.97c42c9.drv-0/source/tests/test_cmdline_tool.py', '--comparator=image_compare', '-c', '/tmp/guix-build-pythonscad-2025.05.25-0.97c42c9.drv-0/build/tests/venv/bin//python', '-s', 'png', '-e', 'preview', '-t', 'preview-cgal', '-f', 'triangle-with-duplicate-vertex', '/tmp/guix-build-pythonscad-2025.05.25-0.97c42c9.drv-0/build/openscad', '/tmp/guix-build-pythonscad-2025.05.25-0.97c42c9.drv-0/source/tests/data/scad/dxf/triangle-with-duplicate-vertex.scad', '--camera=0,0,100,0,0,0', '--viewall', '--autocenter', '--projection=ortho', '--backend=cgal'] 
run_test() cmdline: /tmp/guix-build-pythonscad-2025.05.25-0.97c42c9.drv-0/build/openscad /tmp/guix-build-pythonscad-2025.05.25-0.97c42c9.drv-0/source/tests/data/scad/dxf/triangle-with-duplicate-vertex.scad --camera=0,0,100,0,0,0 --viewall --autocenter --projection=ortho --backend=cgal -o /tmp/guix-build-pythonscad-2025.05.25-0.97c42c9.drv-0/build/tests/output/preview-cgal/triangle-with-duplicate-vertex-actual.png
using font directory: /tmp/guix-build-pythonscad-2025.05.25-0.97c42c9.drv-0/source/tests/data/ttf
stderr output: Could not initialize localization (application path is '/tmp/guix-build-pythonscad-2025.05.25-0.97c42c9.drv-0/build').
Compiling design (CSG Products normalization)...
Normalized CSG tree has 1 elements
GL context provider 'glx' not found

Error: openscad failed with return code -11

I guess there's a dependency missing or something.

Here's my current package definition:

(define-public openscad
  (let ((commit "72c9919d63116f8e711f3566ae34e9eb63a2d6e6")
        (version "2025.05.08")
        (revision "0"))
    (package
      (name "openscad")
      (version (git-version version revision commit))
      (source
       (origin
         (method git-fetch)
         (uri (git-reference
               (url "https://github.com/openscad/openscad")
               (commit commit)
               (recursive? #t)))
         (sha256
          (base32 "077x7s3z65mz6rnrzan3qn06045d2fkqnd6ss6ibw1fhlaypzfbf"))
         (file-name (git-file-name name version))))
      (build-system qt-build-system)
      (arguments
       (list
        #:configure-flags
        #~(list "-DCMAKE_BUILD_TYPE=Release"
                "-DUSE_BUILTIN_OPENCSG=ON"
                "-DMANIFOLD_PYBIND=OFF"
                "-DMANIFOLD_TEST=OFF"
                "-DEXPERIMENTAL=ON"
                "-DENABLE_PYTHON=ON"
                "-DUSE_BUILTIN_CLIPPER2=OFF"
                (string-append "-DOPENSCAD_VERSION="
                               #$version)
                (string-append "-DOPENSCAD_COMMIT="
                               #$commit)
                "-DENABLE_EGL=ON"
                "-DENABLE_GLX=ON")
        #:phases
        #~(modify-phases %standard-phases
            (add-after 'unpack 'patch-source
              (lambda* (#:key inputs #:allow-other-keys)
                ;; <https://github.com/openscad/openscad/issues/5877>
                (substitute* "cmake/Modules/FindLib3MF.cmake"
                  (("PC_LIB3MF_INCLUDE_DIRS")
                   "PC_LIB3MF_INCLUDEDIR"))
                (substitute* "CMakeLists.txt"
                  ;; <https://github.com/openscad/openscad/issues/5880>
                  (("target_link_libraries\\(OpenSCAD PRIVATE OpenGL::EGL\\)")
                   "      find_package(ECM REQUIRED NO_MODULE)
      list(APPEND CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
      find_package(EGL REQUIRED)
      target_link_libraries(OpenSCAD PRIVATE EGL::EGL)")
                  ;; <https://github.com/openscad/openscad/issues/5897>
                  (("find_package\\(Nettle 3.4\\)")
                   "find_package(Nettle 3.4 REQUIRED)")
                  ;; Use the system sanitizers-cmake module.
                  (("\\$\\{CMAKE_SOURCE_DIR\\}/submodules/sanitizers-cmake/cmake")
                   (string-append (assoc-ref inputs "sanitizers-cmake")
                                  "/share/sanitizers-cmake/cmake"))))))))
      (inputs (list boost
                    cairomm
                    cgal
                    clipper2
                    double-conversion
                    eigen
                    egl-wayland
                    fontconfig
                    freetype
                    glew
                    glib
                    gmp
                    harfbuzz
                    hidapi
                    lib3mf
                    libcanberra
                    libspnav
                    libxml2
                    libzip
                    manifold
                    mesa ; or libglvnd if we had mesa-glvnd, too
                    mimalloc
                    mpfr
                    nettle
                    opencsg
                    python
                    python-numpy
                    python-pillow
                    python-pip
                    qscintilla
                    qtbase-5
                    qtmultimedia-5
                    qtsvg-5
                    qtwayland-5
                    sanitizers-cmake
                    tbb))
      (native-inputs (list bison
                           extra-cmake-modules
                           flex
                           gettext-minimal
                           pkg-config
                           which
                           xvfb-run
                           ;; the following are only needed for tests
                           imagemagick
                           ghostscript
                           procps
                           xorg-server-for-tests))
      (synopsis "Script-based 3D modeling application")
      (description
       "OpenSCAD is a software for creating solid 3D CAD objects.  It is free
software and available for Linux/UNIX, MS Windows and macOS.
Unlike most free software for creating 3D models (such as the famous
application Blender), OpenSCAD focuses on the CAD aspects rather than the
artistic aspects of 3D modeling.  Thus this might be the application you are
looking for when you are planning to create 3D models of machine parts but
probably not the tool for creating computer-animated movies.
OpenSCAD is not an interactive modeler.  Instead it is more like a 3D-compiler
that reads a script file that describes the object and renders the 3D model
from this script file.  This gives you, the designer, complete control over the
modeling process and enables you to easily change any step in the modeling
process or make designs that are defined by configurable parameters.
OpenSCAD provides two main modeling techniques: First there is constructive
solid geometry (aka CSG) and second there is extrusion of 2D outlines.  As the
data exchange format for these 2D outlines Autocad DXF files are used.  In
addition to 2D paths for extrusion it is also possible to read design
parameters from DXF files.  Besides DXF files OpenSCAD can read and create 3D
models in the STL and OFF file formats.")
      (home-page "https://openscad.org/")
      (license license:gpl2+))))

(define-public pythonscad
  (let ((commit "97c42c9159777eb41c5d983fda5ac02e035d7742")
        (version "2025.05.25")
        (revision "0"))
    (package
      (inherit openscad)
      (name "pythonscad")
      (version (git-version version revision commit))
      (source
       (origin
         (method git-fetch)
         (uri (git-reference
               (url "https://github.com/pythonscad/pythonscad")
               (commit commit)
               ;; (recursive? #t)
               ))
         (sha256
          (base32 "1ig2qrl6pxqd5bis4gyfiii09k3igg11cgij4lcaqdah0ks94z13"))
         (file-name (git-file-name name version))))
      (arguments
       (list
        #:configure-flags
        #~(list "-DCMAKE_BUILD_TYPE=Release"
                "-DUSE_BUILTIN_OPENCSG=ON"
                "-DMANIFOLD_PYBIND=OFF"
                "-DMANIFOLD_TEST=OFF"
                "-DENABLE_TESTS=ON"
                "-DEXPERIMENTAL=ON"
                "-DSNAPSHOT=ON"
                "-DENABLE_PYTHON=ON"
                (string-append "-DPYTHON_VERSION="
                               #$(version-major+minor (package-version (this-package-input
                                                                        "python"))))
                "-DUSE_BUILTIN_CLIPPER2=OFF"
                (string-append "-DOPENSCAD_VERSION="
                               #$version)
                (string-append "-DOPENSCAD_COMMIT="
                               #$commit)
                "-DENABLE_EGL=ON"
                "-DENABLE_GLX=ON")
        #:phases
        #~(modify-phases %standard-phases
            (add-after 'unpack 'patch-source
              (lambda* (#:key inputs #:allow-other-keys)
                ;; Two of the tests scripts are missing the "#!" prefix on the
                ;; shebang (see
                ;; https://github.com/pythonscad/pythonscad/pull/13).
                (substitute* "tests/test_cmdline_tool.py"
                  (("^/usr/bin/env python3")
                   "#!/usr/bin/env python3"))
                (substitute* "tests/test_pretty_print.py"
                  (("^/usr/bin/env python3")
                   "#!/usr/bin/env python3"))
                ;; The build system fails to find lib3mf; it seems it should
                ;; be using PC_LIBRMF_INCLUDEDIR instead of
                ;; PC_LIB3MF_INCLUDE_DIRS (see
                ;; https://github.com/openscad/openscad/issues/5877).
                (substitute* "cmake/Modules/FindLib3MF.cmake"
                  (("PC_LIB3MF_INCLUDE_DIRS")
                   "PC_LIB3MF_INCLUDEDIR"))
                ;; The build system failes to find EGL; a patch to
                ;; CMakeLists.txt is necessary to find the package
                ;; before adding it to the linked libraries (see
                ;; https://github.com/openscad/openscad/issues/5880).
                (substitute* "CMakeLists.txt"                                    
                  (("target_link_libraries\\(OpenSCAD PRIVATE OpenGL::EGL\\)")
                   "      find_package(ECM REQUIRED NO_MODULE)
      list(APPEND CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
      find_package(EGL REQUIRED)
      target_link_libraries(OpenSCAD PRIVATE EGL::EGL)")
                  ;; Python support is enabled with the -DENABLE_PYTHON=ON
                  ;; build flag.  This requires the Nettle library as a
                  ;; dependency.  The build files however, don´t specify
                  ;; Nettla as mandatory but instead just set ENABLE_PYTHON to
                  ;; off.  This patch set's Nettl to REQUIRED so that the
                  ;; build properly fails if it is missing from the inputs
                  ;; (see https://github.com/openscad/openscad/issues/5897).
                  (("find_package\\(Nettle 3.4\\)")
                   "find_package(Nettle 3.4 REQUIRED)")
                  ;; Use the system sanitizers-cmake module.
                  (("\\$\\{CMAKE_SOURCE_DIR\\}/submodules/sanitizers-cmake/cmake")
                   (string-append (assoc-ref inputs "sanitizers-cmake")
                                  "/share/sanitizers-cmake/cmake")))))
            (add-before 'check 'set-home-directory
              (lambda _
                ;; Tests fail with: Fontconfig error: No writable cache
                ;; directories
                (setenv "HOME" "/tmp"))))))
      (inputs (modify-inputs (package-inputs openscad)
                (append libjpeg-turbo curl python nettle)))
      (home-page "https://pythonscad.org/")
      (description
       "PythonSCAD provides a powerful framework for defining 3D
models using the Python programming language.  It extends the
capabilities of OpenSCAD, a code-driven 3D CAD modeller, by overcoming
OpenSCAD's native language limitations such as variable immutability,
limited iterations, and lack of file I/O.  This integration enables
more complex parametric designs, leverages Python's extensive library
ecosystem for data manipulation and calculations, and promotes an
object-oriented approach to 3D modeling."))))

Anyone has any idea about what could be wrong here?

Thanks!

nomike

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions