You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package Pyconstant PyIncludePath ="";
constant PyLib ="";
class PythonLibraryHandleextends ExternalObject;
function constructor "External object constructor that loads the python dll"inputString pyLibPath = PyLib;
output PythonLibraryHandle pyHandle;
external "C" pyHandle = omc_PyLibLoad(pyLibPath) annotation ( IncludeDirectory = {"modelica://OMCallPython/Resources/C-Sources", PyIncludePath}, Include = "#include \"OMCallPython.h\"");end constructor;
...
end Py;
model Test// here we could even call some functions to fetch these values from some environment variablespackage ConfiguredPy = Py(PyIncludePath ="E:/bin/py64/include", PyLib ="E:/bin/py64/python3.dll");
....
ConfiguredPy.PythonLibraryHandle pyHandle = ConfiguredPy.PythonLibraryHandle();
end Test;
The text was updated successfully, but these errors were encountered:
It's an interesting enhancement, but I see a number of practical issues:
All tools do currently not support this.
It seems to open up rather wild ideas with string-handling for the Include-directive.
It seems necessary to also concatenate constant string arrays, and not only constant string values.
Using functions to extract them from environment variables mean that we first run some functions to generate includes for other functions that we can then run, it seems that can in turn be used for the next function ...
It's an interesting enhancement, but I see a number of practical issues:
All tools do currently not support this.
They do, at least in graphical user annotations.
It seems to open up rather wild ideas with string-handling for the Include-directive.
Sure, but much more flexibility.
It seems necessary to also concatenate constant string arrays, and not only constant string values.
True
Using functions to extract them from environment variables mean that we first run some functions to generate includes for other functions that we can then run, it seems that can in turn be used for the next function ...
One could easy add a getEnvironmentVariable operator to the Modelica Specification. You already have that in the MSL: Modelica.Utilities.System.getEnvironmentVariable. But yes, you could cascade functions like that.
The spec: https://specification.modelica.org/master/functions.html#annotations-for-external-libraries-and-include-files
says that annotations:
Library
,LibraryDirectory
,Include
andIncludeDirectory
can all specify either a scalar value or an array of values.Why do we have this restriction? All the tools should be able to support constants in these annotations.
It prevents writing flexible packages such as:
https://github.com/adrpo/OMCallPython/tree/ConfigurePython
using constants:
The text was updated successfully, but these errors were encountered: