FreeCAD / FreeCAD-snap

The official Snap package of the FreeCAD project
https://snapcraft.io/freecad
10 stars 10 forks source link

freecad.pip fails to install ifcopenshell #111

Closed furgo16 closed 6 months ago

furgo16 commented 6 months ago

In order to import/export using the IFC format, ifcopenshell needs to be installed. In the past, this worked well using freecad.pip install ifcopenshell. However, recent ifcopenshell builds have added the mathutils dependency. When trying to install that dependency, the process fails with the following error:

$ freecad.pip install ifcopenshell
Collecting ifcopenshell
  Using cached ifcopenshell-0.7.0.240423-py310-none-manylinux_2_31_x86_64.whl.metadata (8.9 kB)
Collecting mathutils (from ifcopenshell)
  Using cached mathutils-3.3.0.tar.gz (245 kB)
  Preparing metadata (setup.py) ... done
Collecting shapely (from ifcopenshell)
  Using cached shapely-2.0.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (7.0 kB)
Requirement already satisfied: numpy in /snap/freecad/1002/usr/lib/python3/dist-packages (from ifcopenshell) (1.21.5)
Collecting isodate (from ifcopenshell)
  Using cached isodate-0.6.1-py2.py3-none-any.whl.metadata (9.6 kB)
Requirement already satisfied: python-dateutil in /snap/freecad/1002/usr/lib/python3/dist-packages (from ifcopenshell) (2.8.1)
Requirement already satisfied: lark in /home/dpm/snap/freecad/common/.local/lib/python3.10/site-packages (from ifcopenshell) (1.1.9)
Requirement already satisfied: six in /snap/freecad/1002/usr/lib/python3/dist-packages (from isodate->ifcopenshell) (1.16.0)
Using cached ifcopenshell-0.7.0.240423-py310-none-manylinux_2_31_x86_64.whl (51.7 MB)
Using cached isodate-0.6.1-py2.py3-none-any.whl (41 kB)
Using cached shapely-2.0.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.5 MB)
Building wheels for collected packages: mathutils
  Building wheel for mathutils (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [19 lines of output]
      running bdist_wheel
      running build
      running build_ext
      building 'mathutils' extension
      creating build
      creating build/temp.linux-x86_64-3.10
      creating build/temp.linux-x86_64-3.10/src
      creating build/temp.linux-x86_64-3.10/src/blenlib
      creating build/temp.linux-x86_64-3.10/src/blenlib/intern
      creating build/temp.linux-x86_64-3.10/src/generic
      creating build/temp.linux-x86_64-3.10/src/mathutils
      creating build/temp.linux-x86_64-3.10/src/stubs
      x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DMATH_STANDALONE -DWITH_ASSERT_ABORT -Isrc/stubs -Isrc/blenlib -Isrc/makesdna -I/usr/include/python3.10 -c src/blenlib/intern/BLI_assert.c -o build/temp.linux-x86_64-3.10/src/blenlib/intern/BLI_assert.o -funsigned-char -Wno-sign-compare -Wno-strict-aliasing -std=gnu99
      In file included from src/blenlib/intern/BLI_assert.c:10:
      src/blenlib/BLI_system.h:5:10: fatal error: stdio.h: No such file or directory
          5 | #include <stdio.h>
            |          ^~~~~~~~~
      compilation terminated.
      error: command '/snap/freecad/1002/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for mathutils
  Running setup.py clean for mathutils
Failed to build mathutils
ERROR: Could not build wheels for mathutils, which is required to install pyproject.toml-based projects

It would seem building mathutils requires some build dependency, but I'm not sure if that's the case. I installed buildutils and wheel, but that does not solve the issue. More info:

$ freecad.pip list
Package           Version
----------------- --------
attrs             23.2.0
Automat           22.10.0
buildtools        1.0.6
constantly        23.10.4
docopt            0.6.2
ezdxf             1.2.0
furl              2.1.3
greenlet          3.0.3
hyperlink         21.0.0
incremental       22.10.0
lark              1.1.9
opencv-python     4.8.0.74
orderedmultidict  1.0.1
redo              2.0.4
simplejson        3.19.2
SQLAlchemy        2.0.29
Twisted           24.3.0
typing_extensions 4.11.0
wheel             0.43.0
zope.interface    6.3

Note: either pip install ifcopenshell or pip install mathutils works on the host system where the FreeCAD snap is installed.

furgo16 commented 6 months ago

Related: https://stackoverflow.com/questions/78523816/how-to-solve-error-could-not-build-wheels-for-mathutils-in-python-3-9-6

yorikvanhavre commented 6 months ago

isn't it because FreeCAD's pip is prohibited to install mathutils @chennes ?

furgo16 commented 6 months ago

I think it makes sense at this point to distribute it with the snap package, just as it happens with the AppImage. @yorikvanhavre, @chennes would you mind reviewing the associated PR at https://github.com/FreeCAD/FreeCAD-snap/pull/113? Thanks!

yorikvanhavre commented 6 months ago

LGTM!