We are moving toward replacing the Python Connector with the Python API and our IDL files are also used with C++. In our case rtiddsgen for python creates invalid python code, for example, in this snippet there is a missing ‘)’ at the end of the line with ‘sys.path.append’ and we also get the general error “NameError: name 'sys' is not defined ”. Details are provided below, please advise.
sys.path.append(os.path.join(os.path.dirname(sys.path[0]), /Test_001/idls/foo/')
from bar import *
sys.path.pop()
Version:
rti_connext_dds-7.1.0
rtiddsgen version 4.1.0
python --version
Python 3.6.8
python3.10 --version
Python 3.10.8
Command line for running rtiddsgen :
rtiddsgen -language Python -verbosity 3 -update typefiles -I /home/user/Test_001/otherIdls/ /home/user/idls/helloWorld.idl
Directory structure:
-Test_001
--idls
HellowWorld.idl
-otherIdls
-Foo
Bar.idl
HelloWorld.idl:
#include "foo/bar.idl"
struct HelloWorld {
string<128> msg;
};
Complete file generated:
from dataclasses import field
from typing import Union, Sequence, Optional
import rti.idl as idl
from enum import IntEnum
sys.path.append(os.path.join(os.path.dirname(sys.path[0]), 'Test_001/idls/foo/')
from bar import *
sys.path.pop()
@idl.struct(
member_annotations = {
'msg': [idl.bound(128)],
}
)
class HelloWorld:
msg: str = ""
Hi,
We are aware of the issue (CODEGENII-1847) and it will be fixed in the next release. The issue affects any IDL included with a path.
The workaround is to remove the path from the include file. If you change the rtiddsgen call to:
rtiddsgen -language Python -verbosity 3 -update typefiles -I /home/user/Test_001/otherIdls/foo /home/user/idls/helloWorld.idl
And the included idl to:
#include "bar.idl"
It should work