Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions maintainers/maintainer-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26902,6 +26902,11 @@
githubId = 9853194;
name = "Philipp Bartsch";
};
tnytown = {
github = "tnytown";
githubId = 3821575;
name = "Andrew Pan";
};
toast = {
name = "Toast";
github = "toast003";
Expand Down
76 changes: 76 additions & 0 deletions pkgs/development/python-modules/build123d/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
lib,
buildPythonPackage,
fetchFromGitHub,
pytestCheckHook,
setuptools-scm,
anytree,
ezdxf,
ipython,
numpy,
cadquery-ocp,
ocpsvg,
ocp-gordon,
lib3mf,
sympy,
scipy,
svgpathtools,
trianglesolver,
webcolors,
}:
let
pname = "build123d";
version = "0.10.0";
src = fetchFromGitHub {
owner = "gumyr";
repo = "build123d";
tag = "v${version}";
hash = "sha256-EhV6/ZTBp9XxWY1CgNKESikgTnAk9xaF0g/bYEQPf20=";
};
in
buildPythonPackage {
inherit src pname version;
pyproject = true;

build-system = [ setuptools-scm ];

dependencies = [
anytree
ezdxf
ipython
numpy
cadquery-ocp
ocpsvg
ocp-gordon
lib3mf
scipy
sympy
svgpathtools
trianglesolver
webcolors
];

pythonRelaxDeps = [
"ipython"
"webcolors"
];

nativeCheckInputs = [
pytestCheckHook
];

disabledTests = [
# These attempt to access the network
"test_assembly_with_oriented_parts"
"test_move_single_object"
"test_single_label_color"
"test_single_object"
];

meta = {
description = "python CAD programming library";
homepage = "https://github.com/gumyr/build123d";
license = lib.licenses.asl20;
maintainers = with lib.maintainers; [ tnytown ];
};
}
126 changes: 126 additions & 0 deletions pkgs/development/python-modules/cadquery-ocp/cmake-fixes-7_9.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d0065b17..2cf2d390 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -15,7 +15,9 @@ find_package( VTK REQUIRED
CommonExecutionModel
freetype
)
+
message(STATUS "VTK ${VTK_VERSION} found")
+
find_package( RapidJSON REQUIRED )
find_package( Clang REQUIRED )

@@ -23,24 +25,33 @@ set( Python_FIND_VIRTUALENV FIRST )
find_package( Python 3.9 COMPONENTS Interpreter Development REQUIRED )

# find OCCT and dump symbols
-find_package( OpenCASCADE REQUIRED )
+if(OCCT_LIB_DIR)
+ file(GLOB occt_libs LIST_DIRECTORIES false ${OCCT_LIB_DIR} )
+else()
+ find_package( OpenCASCADE REQUIRED )

-foreach(target ${OpenCASCADE_LIBRARIES} )
- get_target_property(loc ${target} IMPORTED_LOCATION_RELEASE)
- list( APPEND occt_libs ${loc} )
-endforeach()
+ foreach(target ${OpenCASCADE_LIBRARIES} )
+ get_target_property(loc ${target} IMPORTED_LOCATION_RELEASE)
+ list( APPEND occt_libs ${loc} )
+ endforeach()
+endif()

execute_process(
COMMAND
${Python_EXECUTABLE}
- dump_symbols.py
+ ${CMAKE_SOURCE_DIR}/dump_symbols.py
"${occt_libs}"
- )
-
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+)

get_target_property( LIBCLANG_PATH libclang IMPORTED_LOCATION_RELEASE )
get_target_property( VTK_INCLUDE_DIR VTK::CommonCore INTERFACE_INCLUDE_DIRECTORIES )

+# for some reason I get multiple generator expressions
+string(REPLACE ">" ">;" VTK_INCLUDE_DIR ${VTK_INCLUDE_DIR})
+list(GET VTK_INCLUDE_DIR 0 VTK_INCLUDE_DIR)
+
+message( STATUS "Include dirs: ${VTK_INCLUDE_DIR}")
message( STATUS "Include dirs: ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}")

if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
@@ -51,38 +62,40 @@ else()
list( APPEND CXX_INCLUDES -i /opt/usr/local/include/c++/v1/ -i /opt/usr/local/include/ )
endif()

-if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
- set(PLATFORM Windows)
-elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
- set(PLATFORM OSX)
+if(PLATFORM)
+ message( STATUS "Requested platform: ${PLATFORM}")
else()
- set(PLATFORM Linux)
+ message( STATUS "Platform not specified.")
+
+ if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
+ set(PLATFORM Windows)
+ elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
+ set(PLATFORM OSX)
+ else()
+ set(PLATFORM Linux)
+ endif()
endif()

set(ENV{PYTHONPATH} ${CMAKE_SOURCE_DIR}/pywrap )

-if( NOT EXISTS ${CMAKE_SOURCE_DIR}/OCP )
- message( STATUS "Running pywrap")
- execute_process(
- COMMAND
- ${Python_EXECUTABLE}
- -m bindgen
- -n ${N_PROC}
- -l ${LIBCLANG_PATH}
- -i ${CLANG_INCLUDE_DIRS}/
- -i ${VTK_INCLUDE_DIR}/
- -i ${CLANG_INSTALL_PREFIX}/lib/clang/${LLVM_VERSION}/include/
- ${CXX_INCLUDES}
- all ocp.toml ${PLATFORM}
- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
- COMMAND_ECHO STDOUT
- RESULT_VARIABLE PYWRAP_RESULT
- )
-
- if( ${PYWRAP_RESULT} GREATER 0)
- message(FATAL_ERROR "Pywrap call failed")
- endif()
-
-endif()
+add_custom_command(
+ OUTPUT ${CMAKE_SOURCE_DIR}/OCP/CMakeLists.txt
+ COMMAND
+ ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_SOURCE_DIR}/pywrap"
+ ${Python_EXECUTABLE}
+ -m bindgen
+ -n ${N_PROC}
+ -l ${LIBCLANG_PATH}
+ -i ${CLANG_INCLUDE_DIRS}/
+ -i ${VTK_INCLUDE_DIR}/
+ -i ${CLANG_INSTALL_PREFIX}/lib/clang/${LLVM_VERSION_MAJOR}/include/
+ -p ${CMAKE_SOURCE_DIR}
+ ${CXX_INCLUDES}
+ all ${CMAKE_SOURCE_DIR}/ocp.toml ${PLATFORM}
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+ DEPENDS ${CMAKE_SOURCE_DIR}/ocp.toml
+ USES_TERMINAL
+ COMMENT "Running pywrap"
+)

-add_subdirectory( ${CMAKE_SOURCE_DIR}/OCP )
+add_custom_target(pywrap ALL DEPENDS ${CMAKE_SOURCE_DIR}/OCP/CMakeLists.txt)
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2cf2d390..691fe54c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -54,13 +54,9 @@ list(GET VTK_INCLUDE_DIR 0 VTK_INCLUDE_DIR)
message( STATUS "Include dirs: ${VTK_INCLUDE_DIR}")
message( STATUS "Include dirs: ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}")

-if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
- foreach( inc IN LISTS CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES)
- list( APPEND CXX_INCLUDES -i ${inc}/ )
- endforeach()
-else()
- list( APPEND CXX_INCLUDES -i /opt/usr/local/include/c++/v1/ -i /opt/usr/local/include/ )
-endif()
+foreach( inc IN LISTS CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES)
+ list( APPEND CXX_INCLUDES -i ${inc}/ )
+endforeach()

if(PLATFORM)
message( STATUS "Requested platform: ${PLATFORM}")
@@ -86,8 +82,6 @@ add_custom_command(
-m bindgen
-n ${N_PROC}
-l ${LIBCLANG_PATH}
- -i ${CLANG_INCLUDE_DIRS}/
-i ${VTK_INCLUDE_DIR}/
- -i ${CLANG_INSTALL_PREFIX}/lib/clang/${LLVM_VERSION_MAJOR}/include/
-p ${CMAKE_SOURCE_DIR}
${CXX_INCLUDES}
104 changes: 104 additions & 0 deletions pkgs/development/python-modules/cadquery-ocp/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
{
lib,
stdenv,
fetchFromGitHub,
callPackage,

mkPythonMetaPackage,
python,
pythonImportsCheckHook,
toPythonModule,

llvmPackages_20,
cmake,
ninja,
yj,

apple-sdk,
pybind11,
vtk,
}:

let
# Upstream requires a minimum of LLVM 20.
llvmPackages = llvmPackages_20;

# On Linux, we need to use a non-libcxx stdenv as we are compiling against
# libraries built with libstdc++. On the other hand, the ocp-sources
# derivation requires libcxx for unknowable reasons.
stdenv = llvmPackages.stdenv;

pythonBuildEnv = python.withPackages (
ps: with ps; [
click
lief
path
(libclang.override { inherit llvmPackages; })
toml
pandas
joblib
tqdm
jinja2
toposort
logzero
pyparsing
pybind11
schema
]
);

ocp-sources = callPackage ./ocp-sources.nix { inherit llvmPackages pythonBuildEnv; };
inherit (ocp-sources) version;
in
toPythonModule (
stdenv.mkDerivation (finalAttrs: {
pname = "cadquery-ocp";
inherit version;
src = ocp-sources;

nativeBuildInputs =
ocp-sources.nativeBuildInputs
++ lib.optional (stdenv.buildPlatform == stdenv.hostPlatform) pythonImportsCheckHook;
inherit (ocp-sources) buildInputs;

propagatedBuildInputs = [
(mkPythonMetaPackage {
inherit (finalAttrs) pname version meta;
dependencies = [ vtk ];
})
];

env = {
NIX_CFLAGS_COMPILE = "-Wno-deprecated-declarations";
};

cmakeFlags = [ (lib.cmakeFeature "Python_ROOT_DIR" "${pythonBuildEnv}") ];

separateDebugInfo = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this separateDebugInfo used for.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At some point I was getting instability in the bindings due to bad codegen, the debug info helped to troubleshoot. I can remove this now that we're no longer encountering those issues, if you'd like?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious to know the effect. You can keep or drop it as your wish, since you are also the end user that use cadquery-ocp.


installPhase =
let
destDir = "$out/${python.sitePackages}";
in
''
runHook preInstall

mkdir -p ${destDir}
cp ./*.so ${destDir}

runHook postInstall
'';

pythonImportsCheck = [
"OCP"
"OCP.gp"
];

meta = {
description = "Python wrapper for OCCT generated using pywrap";
homepage = "https://github.com/CadQuery/OCP";
license = lib.licenses.asl20;
maintainers = with lib.maintainers; [ tnytown ];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add

broken = (lib.versions.majorMinor finalAttrs.version) != (lib.versions.majorMinor opencascade-occt');

to not block upgrade of opencascade-occt

};
})
)
Loading
Loading