odin-blend2d

Odin bindings to Blend2D
Log | Files | Refs | README | LICENSE

blend2d-version.py (579B)


      1 #!/usr/bin/env python3
      2 
      3 import os
      4 import re
      5 
      6 BLEND2D_DIR = os.path.dirname(os.path.abspath(__file__))
      7 
      8 def read_text_file(file_name):
      9   with open(file_name, "r", encoding="utf-8") as f:
     10     return f.read()
     11 
     12 def get_version():
     13   try:
     14     api_h = read_text_file(os.path.join(BLEND2D_DIR, "src", "blend2d", "api.h"))
     15     ver = re.search("#define BL_VERSION BL_MAKE_VERSION\\((\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\)", api_h)
     16     if ver:
     17         return "{}.{}.{}".format(ver[1], ver[2], ver[3])
     18   except:
     19     pass
     20   return "unknown"
     21 
     22 if __name__ == "__main__":
     23   print(get_version())