19 PString fileModule = baseFileName.toLower() +
"_module";
20 fs <<
"#!/usr/bin/env python3" << std::endl;
21 fs <<
"\"\"\"Test script for " << fileModule <<
" nanobind wrapper\"\"\"" << std::endl << std::endl;
22 fs <<
"import sys" << std::endl;
23 fs <<
"import os" << std::endl << std::endl;
26 fs <<
"try:" << std::endl;
27 fs <<
"\timport " << fileModule << std::endl;
28 fs <<
"\tprint(\"✓ " << fileModule <<
" imported successfully from environment!\")" << std::endl;
29 fs <<
"except ImportError:" << std::endl;
30 fs <<
"\t# Try loading from build directory" << std::endl;
31 fs <<
"\tbuild_path = os.path.join(os.path.dirname(__file__), '..', '..', '..', 'build', 'src')" << std::endl;
32 fs <<
"\tsys.path.insert(0, build_path)" << std::endl;
33 fs <<
"\tprint(f\"Module search path: {build_path}\")" << std::endl;
34 fs <<
"\tprint(f\"Absolute path: {os.path.abspath(build_path)}\")" << std::endl;
35 fs <<
"\ttry:" << std::endl;
36 fs <<
"\t\timport " << fileModule << std::endl;
37 fs <<
"\t\tprint(\"✓ " << fileModule <<
" imported successfully from build!\")" << std::endl;
38 fs <<
"\texcept ImportError as e:" << std::endl;
39 fs <<
"\t\tprint(f\"✗ Import error: {e}\")" << std::endl;
40 fs <<
"\t\tprint(\"Verifications to do:\")" << std::endl;
41 fs <<
"\t\tprint(\"1. Have you compiled the project? (cmake .. && make)\")" << std::endl;
42 fs <<
"\t\tprint(\"2. Does the .so file exist?\")" << std::endl;
43 fs <<
"\t\tprint(f\" Check: ls -la {build_path}\")" << std::endl;
44 fs <<
"\t\tsys.exit(1)" << std::endl << std::endl;