| 16 | |
| 17 | # Extract the project version from CMake generated ABI header. |
| 18 | def get_version(): |
| 19 | VERSION_REGEX = re.compile( |
| 20 | r"^\s*#\s*define\s+OCIO_VERSION_FULL_STR\s+\"(.*)\"\s*$", re.MULTILINE) |
| 21 | |
| 22 | here = os.path.abspath(os.path.dirname(__file__)) |
| 23 | |
| 24 | with tempfile.TemporaryDirectory() as tmpdir: |
| 25 | try: |
| 26 | subprocess.check_call(["cmake", here], cwd=tmpdir) |
| 27 | path = os.path.join(tmpdir, "include", "OpenColorIO", "OpenColorABI.h") |
| 28 | with open(path) as f: |
| 29 | match = VERSION_REGEX.search(f.read()) |
| 30 | return match.group(1) |
| 31 | except Exception as e: |
| 32 | raise RuntimeError( |
| 33 | "Unable to find OpenColorIO version: {}".format(str(e)) |
| 34 | ) |
| 35 | |
| 36 | |
| 37 | # Call CMake find_package from a dummy script and return whether the package |