From 5431aacb84189ced5b1c9f79b1f57240a07579f9 Mon Sep 17 00:00:00 2001 From: Augustin Trancart Date: Wed, 17 Jul 2024 10:39:36 +0200 Subject: [PATCH 1/3] ifcopenshell: 240611 -> 0.7.10, fix build and activate most tests By relevant release, I mean the ifcopenshell-python release, and not the blenderbim release --- .../python-modules/ifcopenshell/default.nix | 157 ++++++++++++++++-- pkgs/top-level/all-packages.nix | 2 - pkgs/top-level/python-packages.nix | 4 +- 3 files changed, 144 insertions(+), 19 deletions(-) diff --git a/pkgs/development/python-modules/ifcopenshell/default.nix b/pkgs/development/python-modules/ifcopenshell/default.nix index f9b1fb66ec202..ca4c1226ebb26 100644 --- a/pkgs/development/python-modules/ifcopenshell/default.nix +++ b/pkgs/development/python-modules/ifcopenshell/default.nix @@ -1,62 +1,187 @@ { lib, stdenv, + testers, buildPythonPackage, + pythonOlder, + python, + pytestCheckHook, + # fetchers fetchFromGitHub, - gcc10, + # build tools cmake, + swig, + # native dependencies + eigen, boost179, + cgal, + gmp, + hdf5, icu, - swig, - pcre, + libaec, + libxml2, + mpfr, + nlohmann_json, opencascade-occt_7_6, opencollada, - libxml2, + pcre, + zlib, + + # python deps + ## tools + setuptools, + build, + pytest, + ## dependencies + isodate, + lark, + numpy, + python-dateutil, + shapely, + typing-extensions, + ## additional deps for tests + lxml, + mathutils, + networkx, + tabulate, + xmlschema, + xsdata, }: let opencascade-occt = opencascade-occt_7_6; in buildPythonPackage rec { pname = "ifcopenshell"; - version = "240611"; - format = "other"; + version = "0.7.10"; + pyproject = false; src = fetchFromGitHub { owner = "IfcOpenShell"; repo = "IfcOpenShell"; - rev = "refs/tags/blenderbim-${version}"; + rev = "refs/tags/ifcopenshell-python-${version}"; fetchSubmodules = true; - hash = "sha256-fCgxSambC01qb14EoZTrVxNNw8H3nX8oMi6gk0O/HmQ="; + hash = "sha256-cRzv07T5VN5aTjMtAlLGbvI3c4SL0lfzCn/W6f/vdBY="; }; nativeBuildInputs = [ - gcc10 + # c++ cmake + swig + # python + build + setuptools ]; buildInputs = [ + # ifcopenshell needs stdc++ + stdenv.cc.cc.lib boost179 + cgal + eigen + gmp + hdf5 icu - pcre + libaec libxml2 + mpfr + nlohmann_json + opencascade-occt + opencollada + pcre ]; - preConfigure = '' - cd cmake - ''; + propagatedBuildInputs = [ + isodate + lark + numpy + python-dateutil + shapely + typing-extensions + ]; + + # list taken from .github/workflows/ci.yml:49 + nativeCheckInputs = [ + lxml + mathutils + networkx + pytest + tabulate + xmlschema + xsdata + + pytestCheckHook + ]; + + pythonImportsCheck = [ "ifcopenshell" ]; PYTHONUSERBASE = "."; + + # We still build with python to generate ifcopenshell_wrapper.py and ifcopenshell_wrapper.so cmakeFlags = [ "-DUSERSPACE_PYTHON_PREFIX=ON" + "-DBUILD_SHARED_LIBS=ON" + "-DBUILD_IFCPYTHON=ON" + "-DCITYJSON_SUPPORT=OFF" + "-DEIGEN_DIR=${eigen}/include/eigen3" + "-DJSON_INCLUDE_DIR=${nlohmann_json}/include/" "-DOCC_INCLUDE_DIR=${opencascade-occt}/include/opencascade" - "-DOCC_LIBRARY_DIR=${opencascade-occt}/lib" + "-DOCC_LIBRARY_DIR=${lib.getLib opencascade-occt}/lib" "-DOPENCOLLADA_INCLUDE_DIR=${opencollada}/include/opencollada" - "-DOPENCOLLADA_LIBRARY_DIR=${opencollada}/lib/opencollada" + "-DOPENCOLLADA_LIBRARY_DIR=${lib.getLib opencollada}/lib/opencollada" "-DSWIG_EXECUTABLE=${swig}/bin/swig" "-DLIBXML2_INCLUDE_DIR=${libxml2.dev}/include/libxml2" - "-DLIBXML2_LIBRARIES=${libxml2.out}/lib/libxml2${stdenv.hostPlatform.extensions.sharedLibrary}" + "-DLIBXML2_LIBRARIES=${lib.getLib libxml2}/lib/libxml2${stdenv.hostPlatform.extensions.sharedLibrary}" + "-DGMP_LIBRARY_DIR=${lib.getLib gmp}/lib/" + "-DMPFR_LIBRARY_DIR=${lib.getLib mpfr}/lib/" + # HDF5 support is currently not optional, see https://github.com/IfcOpenShell/IfcOpenShell/issues/1815 + "-DHDF5_SUPPORT=ON" + "-DHDF5_INCLUDE_DIR=${hdf5.dev}/include/" + "-DHDF5_LIBRARIES=${lib.getLib hdf5}/lib/libhdf5_cpp.so;${lib.getLib hdf5}/lib/libhdf5.so;${lib.getLib zlib}/lib/libz.so;${lib.getLib libaec}/lib/libaec.so;" ]; + postPatch = '' + pushd src/ifcopenshell-python + # The build process is here: https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.8.0/src/ifcopenshell-python/Makefile#L131 + # NOTE: it has changed a *lot* between 0.7.0 and 0.8.0, it *may* change again (look for mathutils and basically all the things this Makefile does manually) + substituteInPlace pyproject.toml --replace-fail "0.0.0" "${version}" + # NOTE: the following is directly inspired by https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.8.0/src/ifcopenshell-python/Makefile#L123 + cp ../../README.md README.md + popd + ''; + + preConfigure = '' + cd cmake + ''; + + preCheck = '' + pushd ../../src/ifcopenshell-python + # let's test like done in .github/workflows/ci.yml + # installing the python wrapper and the .so, both are needed to be able to test + cp -v $out/${python.sitePackages}/ifcopenshell/ifcopenshell_wrapper.py ./ifcopenshell + cp $out/${python.sitePackages}/ifcopenshell/_ifcopenshell_wrapper.cpython-${ + lib.versions.major python.version + lib.versions.minor python.version + }-${stdenv.targetPlatform.system}-gnu.so ./ifcopenshell + pushd ../../test + PYTHONPATH=../src/ifcopenshell-python/ python tests.py + popd + ''; + + pytestFlagsArray = [ + "-p no:pytest-blender" + ]; + + disabledTestPaths = [ + "test/test_open.py" + ]; + + postCheck = '' + popd + ''; + + passthru.tests = { + version = testers.testVersion { command = "IfcConvert --version"; }; + }; + meta = with lib; { broken = stdenv.hostPlatform.isDarwin; description = "Open source IFC library and geometry engine"; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 7db8390e79645..f17c4e387aa6d 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -8630,8 +8630,6 @@ with pkgs; idle3tools = callPackage ../tools/system/idle3tools { }; - ifcopenshell = with python3Packages; toPythonApplication ifcopenshell; - iftop = callPackage ../tools/networking/iftop { }; ifwifi = callPackage ../tools/networking/ifwifi { diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 78749813f9fef..ff1752052b59b 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -5983,7 +5983,9 @@ self: super: with self; { ifconfig-parser = callPackage ../development/python-modules/ifconfig-parser { }; - ifcopenshell = callPackage ../development/python-modules/ifcopenshell { }; + ifcopenshell = callPackage ../development/python-modules/ifcopenshell { + inherit (pkgs) libxml2; + }; ignite = callPackage ../development/python-modules/ignite { }; From 352c195a973897ba40e4fd764d25e50bf6c974f1 Mon Sep 17 00:00:00 2001 From: Augustin Trancart Date: Fri, 2 Aug 2024 18:19:57 +0200 Subject: [PATCH 2/3] ifcopenshell: maintainer fehnomenal -> autra, as asked by fehnomenal --- pkgs/development/python-modules/ifcopenshell/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/python-modules/ifcopenshell/default.nix b/pkgs/development/python-modules/ifcopenshell/default.nix index ca4c1226ebb26..a3e48222fb525 100644 --- a/pkgs/development/python-modules/ifcopenshell/default.nix +++ b/pkgs/development/python-modules/ifcopenshell/default.nix @@ -187,6 +187,6 @@ buildPythonPackage rec { description = "Open source IFC library and geometry engine"; homepage = "http://ifcopenshell.org/"; license = licenses.lgpl3; - maintainers = with maintainers; [ fehnomenal ]; + maintainers = with maintainers; [ autra ]; }; } From 7e80e03551c89b04754aaa5f908c23b6c00166a9 Mon Sep 17 00:00:00 2001 From: Augustin Trancart Date: Sat, 28 Sep 2024 23:54:41 +0200 Subject: [PATCH 3/3] ifcopenshell: add a passthru.updateScript --- pkgs/development/python-modules/ifcopenshell/default.nix | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkgs/development/python-modules/ifcopenshell/default.nix b/pkgs/development/python-modules/ifcopenshell/default.nix index a3e48222fb525..0ea5ee75d618c 100644 --- a/pkgs/development/python-modules/ifcopenshell/default.nix +++ b/pkgs/development/python-modules/ifcopenshell/default.nix @@ -8,6 +8,7 @@ pytestCheckHook, # fetchers fetchFromGitHub, + gitUpdater, # build tools cmake, swig, @@ -178,8 +179,11 @@ buildPythonPackage rec { popd ''; - passthru.tests = { - version = testers.testVersion { command = "IfcConvert --version"; }; + passthru = { + updateScript = gitUpdater { rev-prefix = "ifcopenshell-python-"; }; + tests = { + version = testers.testVersion { command = "IfcConvert --version"; }; + }; }; meta = with lib; {