Skip to content

Commit

Permalink
Remove Python 3.10+ req
Browse files Browse the repository at this point in the history
  • Loading branch information
Robadob committed Nov 8, 2023
1 parent d1e06f0 commit 54e8b9d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions swig/python/codegen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,17 @@ def translate(function: Union[str, Callable]) -> str:
# get source for each function
for d_f in d_functions:
prepend_source += inspect.getsource(d_f);
# get source for function and preprend device functions
# get source for function and prepend device functions
function_source = prepend_source + inspect.getsource(function)
tree = ast.parse(function_source)
# Filter constants
module_annontations = inspect.get_annotations(module) # requires python 3.10
module_members = inspect.getmembers(module);
print(module_annontations)
print(module_members)
# Emulate inspect.get_annotations() (requires python 3.10+)
module_annontations = {}
for mem in module_members:
if mem[0] == "__annotations__":
module_annontations = mem[1]
break
prepend_c_source = ""
# Find all annotated variables
for key, val in module_annontations.items():
Expand Down

0 comments on commit 54e8b9d

Please sign in to comment.