2024-06-05 15:53:02 +00:00
{
lib ,
stdenv ,
2024-10-09 16:51:18 +00:00
testers ,
2024-06-05 15:53:02 +00:00
buildPythonPackage ,
2024-10-09 16:51:18 +00:00
pythonOlder ,
python ,
pytestCheckHook ,
# fetchers
2024-06-05 15:53:02 +00:00
fetchFromGitHub ,
2024-10-09 16:51:18 +00:00
gitUpdater ,
# build tools
2024-06-05 15:53:02 +00:00
cmake ,
2024-10-09 16:51:18 +00:00
swig ,
# native dependencies
eigen ,
2024-06-05 15:53:02 +00:00
boost179 ,
2024-10-09 16:51:18 +00:00
cgal ,
gmp ,
hdf5 ,
2024-06-05 15:53:02 +00:00
icu ,
2024-10-09 16:51:18 +00:00
libaec ,
libxml2 ,
mpfr ,
nlohmann_json ,
2024-06-05 15:53:02 +00:00
opencascade-occt_7_6 ,
opencollada ,
2024-10-09 16:51:18 +00:00
pcre ,
zlib ,
# python deps
## tools
setuptools ,
build ,
pytest ,
## dependencies
isodate ,
lark ,
numpy ,
python-dateutil ,
shapely ,
typing-extensions ,
## additional deps for tests
ifcopenshell ,
lxml ,
mathutils ,
networkx ,
tabulate ,
xmlschema ,
xsdata ,
2020-11-30 08:33:03 +00:00
} :
2024-06-05 15:53:02 +00:00
let
opencascade-occt = opencascade-occt_7_6 ;
in
2020-11-30 08:33:03 +00:00
buildPythonPackage rec {
pname = " i f c o p e n s h e l l " ;
2024-10-29 11:11:06 +00:00
version = " 0 . 8 . 0 " ;
2024-10-09 16:51:18 +00:00
pyproject = false ;
2020-11-30 08:33:03 +00:00
src = fetchFromGitHub {
2024-06-05 15:53:02 +00:00
owner = " I f c O p e n S h e l l " ;
repo = " I f c O p e n S h e l l " ;
2024-10-09 16:51:18 +00:00
rev = " r e f s / t a g s / i f c o p e n s h e l l - p y t h o n - ${ version } " ;
2020-11-30 08:33:03 +00:00
fetchSubmodules = true ;
2024-10-29 11:11:06 +00:00
hash = " s h a 2 5 6 - t n j 1 4 l B E k U Z N D M 9 J 1 s R h N A 7 O k W T W a 5 J P T S F 8 h u i 3 q 7 k = " ;
2020-11-30 08:33:03 +00:00
} ;
2024-06-05 15:53:02 +00:00
nativeBuildInputs = [
2024-10-09 16:51:18 +00:00
# c++
2024-06-05 15:53:02 +00:00
cmake
2024-10-09 16:51:18 +00:00
swig
# python
build
setuptools
2024-06-05 15:53:02 +00:00
] ;
2020-11-30 08:33:03 +00:00
buildInputs = [
2024-10-09 16:51:18 +00:00
# ifcopenshell needs stdc++
stdenv . cc . cc . lib
2023-07-15 17:15:38 +00:00
boost179
2024-10-09 16:51:18 +00:00
cgal
eigen
gmp
hdf5
2020-11-30 08:33:03 +00:00
icu
2024-10-09 16:51:18 +00:00
libaec
2020-11-30 08:33:03 +00:00
libxml2
2024-10-09 16:51:18 +00:00
mpfr
nlohmann_json
opencascade-occt
opencollada
pcre
2020-11-30 08:33:03 +00:00
] ;
2024-10-09 16:51:18 +00:00
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 = [ " i f c o p e n s h e l l " ] ;
2020-11-30 08:33:03 +00:00
2024-06-05 15:53:02 +00:00
PYTHONUSERBASE = " . " ;
2024-10-09 16:51:18 +00:00
# We still build with python to generate ifcopenshell_wrapper.py and ifcopenshell_wrapper.so
2020-11-30 08:33:03 +00:00
cmakeFlags = [
2021-04-12 18:23:04 +00:00
" - D U S E R S P A C E _ P Y T H O N _ P R E F I X = O N "
2024-10-09 16:51:18 +00:00
" - D B U I L D _ S H A R E D _ L I B S = O N "
" - D B U I L D _ I F C P Y T H O N = O N "
" - D C I T Y J S O N _ S U P P O R T = O F F "
" - D E I G E N _ D I R = ${ eigen } / i n c l u d e / e i g e n 3 "
" - D J S O N _ I N C L U D E _ D I R = ${ nlohmann_json } / i n c l u d e / "
2020-11-30 08:33:03 +00:00
" - D O C C _ I N C L U D E _ D I R = ${ opencascade-occt } / i n c l u d e / o p e n c a s c a d e "
2024-10-09 16:51:18 +00:00
" - D O C C _ L I B R A R Y _ D I R = ${ lib . getLib opencascade-occt } / l i b "
2020-11-30 08:33:03 +00:00
" - D O P E N C O L L A D A _ I N C L U D E _ D I R = ${ opencollada } / i n c l u d e / o p e n c o l l a d a "
2024-10-09 16:51:18 +00:00
" - D O P E N C O L L A D A _ L I B R A R Y _ D I R = ${ lib . getLib opencollada } / l i b / o p e n c o l l a d a "
2020-11-30 08:33:03 +00:00
" - D S W I G _ E X E C U T A B L E = ${ swig } / b i n / s w i g "
" - D L I B X M L 2 _ I N C L U D E _ D I R = ${ libxml2 . dev } / i n c l u d e / l i b x m l 2 "
2024-10-09 16:51:18 +00:00
" - D L I B X M L 2 _ L I B R A R I E S = ${ lib . getLib libxml2 } / l i b / l i b x m l 2 ${ stdenv . hostPlatform . extensions . sharedLibrary } "
" - D G M P _ L I B R A R Y _ D I R = ${ lib . getLib gmp } / l i b / "
" - D M P F R _ L I B R A R Y _ D I R = ${ lib . getLib mpfr } / l i b / "
# HDF5 support is currently not optional, see https://github.com/IfcOpenShell/IfcOpenShell/issues/1815
" - D H D F 5 _ S U P P O R T = O N "
" - D H D F 5 _ I N C L U D E _ D I R = ${ hdf5 . dev } / i n c l u d e / "
" - D H D F 5 _ L I B R A R I E S = ${ lib . getLib hdf5 } / l i b / l i b h d f 5 _ c p p . s o ; ${ lib . getLib hdf5 } / l i b / l i b h d f 5 . s o ; ${ lib . getLib zlib } / l i b / l i b z . s o ; ${ lib . getLib libaec } / l i b / l i b a e c . s o ; "
2020-11-30 08:33:03 +00:00
] ;
2024-10-09 16:51:18 +00:00
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 n o : p y t e s t - b l e n d e r "
] ;
disabledTestPaths = [
" t e s t / t e s t _ o p e n . p y "
] ;
postCheck = ''
popd
'' ;
passthru = {
updateScript = gitUpdater { rev-prefix = " i f c o p e n s h e l l - p y t h o n - " ; } ;
tests = {
version = testers . testVersion {
command = " I f c C o n v e r t - - v e r s i o n " ;
package = ifcopenshell ;
} ;
} ;
} ;
2021-01-15 22:18:51 +00:00
meta = with lib ; {
2024-09-26 11:04:55 +00:00
broken = stdenv . hostPlatform . isDarwin ;
2020-11-30 08:33:03 +00:00
description = " O p e n s o u r c e I F C l i b r a r y a n d g e o m e t r y e n g i n e " ;
2024-06-05 15:53:02 +00:00
homepage = " h t t p : / / i f c o p e n s h e l l . o r g / " ;
license = licenses . lgpl3 ;
2024-10-09 16:51:18 +00:00
maintainers = with maintainers ; [ autra ] ;
2020-11-30 08:33:03 +00:00
} ;
}