Skip to content

Commit 4218ae1

Browse files
authored
Merge pull request #1001 from IntelPython/feature/add_numba_rc_support
Feature/add numba rc support
2 parents aac91b8 + 78022cc commit 4218ae1

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

numba_dpex/__init__.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import logging
1010
import os
1111
import platform as plt
12+
import re
13+
from typing import Tuple
1214

1315
import dpctl
1416
import llvmlite.binding as ll
@@ -59,7 +61,22 @@ def load_dpctl_sycl_interface():
5961
Vectorize.target_registry.ondemand["dpex"] = lambda: DpexVectorize
6062

6163

62-
numba_version = tuple(map(int, numba.__version__.split(".")[:3]))
64+
def parse_sem_version(version_string: str) -> Tuple[int, int, int]:
65+
"""Parse sem version into tuple of three integers. If there is a suffix like
66+
rc1, dev0 - it will be ignored."""
67+
return tuple(
68+
map(
69+
int,
70+
re.sub(
71+
"([0-9]+\\.[0-9]+\\.[0-9]+).*",
72+
"\\g<1>",
73+
version_string,
74+
).split(".")[:3],
75+
)
76+
)
77+
78+
79+
numba_version = parse_sem_version(numba.__version__)
6380
if numba_version < (0, 56, 4):
6481
logging.warning(
6582
"numba_dpex needs numba 0.56.4, using "
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# SPDX-FileCopyrightText: 2020 - 2023 Intel Corporation
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
from numba_dpex import parse_sem_version
6+
7+
8+
class TestParseSemVersion:
9+
def test_parse_sem_version(self):
10+
assert parse_sem_version("0.56.4") == (0, 56, 4)
11+
assert parse_sem_version("0.57.0") == (0, 57, 0)
12+
assert parse_sem_version("0.57.0rc1") == (0, 57, 0)
13+
assert parse_sem_version("0.58.1dev0") == (0, 58, 1)

0 commit comments

Comments
 (0)