How is it possible to package a ‘lib’ folder with a preflight check to use a module ?
You recommend in the Hackathon notes to include reusable parts of code.
It does not seem to work the same way as for a normal bundle.
@KSalmon ,
did you already create it? with a __init__.py
file ?
Thanks Andreas for the suggestion. I was trying to use the same approach as for bundles
MyPanel.panel/
├── lib/
│ └── some_python_module.py
But I get the impression a checks folder does not work the same way. I get ImportError: No module named...
Using __init__.py
does not seem to help.
All library require a reloading of the engine. That might be your issue as lib folder are parsed at loading time of pyrevit
Thanks Jean-Marc.
I did try reloading.
I also tried with the lib folder at different levels in the folders:
MyExtension.extension/
├── lib/
│ └── some_python_module.py
or
MyExtension.extension/
├── checks/
│ └── lib/
│ └── some_python_module.py
Also using a __init__.py
inside lib.
I remain convinced that it is maybe not possible in a ‘checks’ folder. I have not seen any other Preflight check use ‘lib’.
It’s not a big deal. I have a Preflight check ready to share in a pull request. It doesn’t need a module, I just liked the idea of extracting some parts to make them reusable.
Have you tried adding the folder to path manually in the imports and verifying you can access the module that way? in case its not an issue with lib
Thanks JP.
I have tried that, but can’t get it to find the module.
I’m not going to spend more time on it now. I will share the full script anyway in a PR on the hackathon. Then see if it’s worth making any improvements.