Skip to content

Commit 8eb86d4

Browse files
committed
Migrate versioneer to no-vendor + 0.28->0.29
1 parent 9506386 commit 8eb86d4

File tree

11 files changed

+67
-2246
lines changed

11 files changed

+67
-2246
lines changed

.flake8

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,5 @@ exclude =
1919
.git,
2020
__pycache__,
2121
_version.py,
22-
versioneer.py,
2322
lowerer.py,
2423
parfor.py

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ repos:
1818
rev: 24.1.1
1919
hooks:
2020
- id: black
21-
exclude: "versioneer.py|numba_dpex/_version.py"
21+
exclude: "numba_dpex/_version.py"
2222
- repo: https://github.com/asottile/blacken-docs
2323
rev: v1.12.1
2424
hooks:

MANIFEST.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
include MANIFEST.in
22
include README.md setup.py LICENSE
33

4-
include versioneer.py
54
include numba_dpex/_version.py
65

76
recursive-include numba_dpex/examples *

conda-recipe/meta.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ requirements:
4141
# - dpcpp-llvm-spirv >={{ required_compiler_version }}
4242
- dpcpp-llvm-spirv >=2023.0
4343
- wheel >=0.43
44+
- versioneer==0.29
45+
# versioneer dependency
46+
- tomli # [py<311]
4447
run:
4548
- {{ pin_compatible('dpcpp-cpp-rt', min_pin='x.x', max_pin='x') }}
4649
- {{ pin_compatible('intel-cmplr-lib-rt', min_pin='x.x', max_pin='x') }}

environment/coverage.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ dependencies:
2121
- pexpect
2222
- scikit-build>=0.15*
2323
- cmake>=3.26*
24+
- versioneer

environment/docs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ dependencies:
1616
- dpnp>=0.14*
1717
- dpcpp-llvm-spirv
1818
- opencl_rt
19+
- versioneer
1920
- pip
2021
- pip:
2122
- sphinx

environment/pre-commit.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ dependencies:
2121
- cmake>=3.26*
2222
- pre-commit
2323
- pylint
24+
- versioneer

numba_dpex/_version.py

Lines changed: 54 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# SPDX-FileCopyrightText: 2023 - 2024 Intel Corporation
2-
#
3-
# SPDX-License-Identifier: Apache-2.0
41

52
# This file helps to compute a version number in source trees obtained from
63
# git-archive tarball (such as those provided by githubs download-from-tag
@@ -9,7 +6,7 @@
96
# that just contains the computed version number.
107

118
# This file is released into the public domain.
12-
# Generated by versioneer-0.28
9+
# Generated by versioneer-0.29
1310
# https://github.com/python-versioneer/python-versioneer
1411

1512
"""Git implementation of _version.py."""
@@ -19,11 +16,11 @@
1916
import re
2017
import subprocess
2118
import sys
22-
from typing import Callable, Dict
19+
from typing import Any, Callable, Dict, List, Optional, Tuple
2320
import functools
2421

2522

26-
def get_keywords():
23+
def get_keywords() -> Dict[str, str]:
2724
"""Get the keywords needed to look up the version information."""
2825
# these strings will be replaced by git during git-archive.
2926
# setup.py/versioneer.py will grep for the variable names, so they must
@@ -39,8 +36,15 @@ def get_keywords():
3936
class VersioneerConfig:
4037
"""Container for Versioneer configuration parameters."""
4138

39+
VCS: str
40+
style: str
41+
tag_prefix: str
42+
parentdir_prefix: str
43+
versionfile_source: str
44+
verbose: bool
4245

43-
def get_config():
46+
47+
def get_config() -> VersioneerConfig:
4448
"""Create, populate and return the VersioneerConfig() object."""
4549
# these strings are filled in when 'setup.py versioneer' creates
4650
# _version.py
@@ -62,9 +66,9 @@ class NotThisMethod(Exception):
6266
HANDLERS: Dict[str, Dict[str, Callable]] = {}
6367

6468

65-
def register_vcs_handler(vcs, method): # decorator
69+
def register_vcs_handler(vcs: str, method: str) -> Callable: # decorator
6670
"""Create decorator to mark a method as the handler of a VCS."""
67-
def decorate(f):
71+
def decorate(f: Callable) -> Callable:
6872
"""Store f in HANDLERS[vcs][method]."""
6973
if vcs not in HANDLERS:
7074
HANDLERS[vcs] = {}
@@ -73,13 +77,19 @@ def decorate(f):
7377
return decorate
7478

7579

76-
def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False,
77-
env=None):
80+
def run_command(
81+
commands: List[str],
82+
args: List[str],
83+
cwd: Optional[str] = None,
84+
verbose: bool = False,
85+
hide_stderr: bool = False,
86+
env: Optional[Dict[str, str]] = None,
87+
) -> Tuple[Optional[str], Optional[int]]:
7888
"""Call the given command(s)."""
7989
assert isinstance(commands, list)
8090
process = None
8191

82-
popen_kwargs = {}
92+
popen_kwargs: Dict[str, Any] = {}
8393
if sys.platform == "win32":
8494
# This hides the console window if pythonw.exe is used
8595
startupinfo = subprocess.STARTUPINFO()
@@ -95,8 +105,7 @@ def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False,
95105
stderr=(subprocess.PIPE if hide_stderr
96106
else None), **popen_kwargs)
97107
break
98-
except OSError:
99-
e = sys.exc_info()[1]
108+
except OSError as e:
100109
if e.errno == errno.ENOENT:
101110
continue
102111
if verbose:
@@ -116,7 +125,11 @@ def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False,
116125
return stdout, process.returncode
117126

118127

119-
def versions_from_parentdir(parentdir_prefix, root, verbose):
128+
def versions_from_parentdir(
129+
parentdir_prefix: str,
130+
root: str,
131+
verbose: bool,
132+
) -> Dict[str, Any]:
120133
"""Try to determine the version from the parent directory name.
121134
122135
Source tarballs conventionally unpack into a directory that includes both
@@ -141,13 +154,13 @@ def versions_from_parentdir(parentdir_prefix, root, verbose):
141154

142155

143156
@register_vcs_handler("git", "get_keywords")
144-
def git_get_keywords(versionfile_abs):
157+
def git_get_keywords(versionfile_abs: str) -> Dict[str, str]:
145158
"""Extract version information from the given file."""
146159
# the code embedded in _version.py can just fetch the value of these
147160
# keywords. When used from setup.py, we don't want to import _version.py,
148161
# so we do it with a regexp instead. This function is not used from
149162
# _version.py.
150-
keywords = {}
163+
keywords: Dict[str, str] = {}
151164
try:
152165
with open(versionfile_abs, "r") as fobj:
153166
for line in fobj:
@@ -169,7 +182,11 @@ def git_get_keywords(versionfile_abs):
169182

170183

171184
@register_vcs_handler("git", "keywords")
172-
def git_versions_from_keywords(keywords, tag_prefix, verbose):
185+
def git_versions_from_keywords(
186+
keywords: Dict[str, str],
187+
tag_prefix: str,
188+
verbose: bool,
189+
) -> Dict[str, Any]:
173190
"""Get version information from git keywords."""
174191
if "refnames" not in keywords:
175192
raise NotThisMethod("Short version file found")
@@ -233,7 +250,12 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose):
233250

234251

235252
@register_vcs_handler("git", "pieces_from_vcs")
236-
def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command):
253+
def git_pieces_from_vcs(
254+
tag_prefix: str,
255+
root: str,
256+
verbose: bool,
257+
runner: Callable = run_command
258+
) -> Dict[str, Any]:
237259
"""Get version from 'git describe' in the root of the source tree.
238260
239261
This only gets called if the git-archive 'subst' keywords were *not*
@@ -273,7 +295,7 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command):
273295
raise NotThisMethod("'git rev-parse' failed")
274296
full_out = full_out.strip()
275297

276-
pieces = {}
298+
pieces: Dict[str, Any] = {}
277299
pieces["long"] = full_out
278300
pieces["short"] = full_out[:7] # maybe improved later
279301
pieces["error"] = None
@@ -365,14 +387,14 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command):
365387
return pieces
366388

367389

368-
def plus_or_dot(pieces):
390+
def plus_or_dot(pieces: Dict[str, Any]) -> str:
369391
"""Return a + if we don't already have one, else return a ."""
370392
if "+" in pieces.get("closest-tag", ""):
371393
return "."
372394
return "+"
373395

374396

375-
def render_pep440(pieces):
397+
def render_pep440(pieces: Dict[str, Any]) -> str:
376398
"""Build up version string, with post-release "local version identifier".
377399
378400
Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you
@@ -397,7 +419,7 @@ def render_pep440(pieces):
397419
return rendered
398420

399421

400-
def render_pep440_branch(pieces):
422+
def render_pep440_branch(pieces: Dict[str, Any]) -> str:
401423
"""TAG[[.dev0]+DISTANCE.gHEX[.dirty]] .
402424
403425
The ".dev0" means not master branch. Note that .dev0 sorts backwards
@@ -427,7 +449,7 @@ def render_pep440_branch(pieces):
427449
return rendered
428450

429451

430-
def pep440_split_post(ver):
452+
def pep440_split_post(ver: str) -> Tuple[str, Optional[int]]:
431453
"""Split pep440 version string at the post-release segment.
432454
433455
Returns the release segments before the post-release and the
@@ -437,7 +459,7 @@ def pep440_split_post(ver):
437459
return vc[0], int(vc[1] or 0) if len(vc) == 2 else None
438460

439461

440-
def render_pep440_pre(pieces):
462+
def render_pep440_pre(pieces: Dict[str, Any]) -> str:
441463
"""TAG[.postN.devDISTANCE] -- No -dirty.
442464
443465
Exceptions:
@@ -461,7 +483,7 @@ def render_pep440_pre(pieces):
461483
return rendered
462484

463485

464-
def render_pep440_post(pieces):
486+
def render_pep440_post(pieces: Dict[str, Any]) -> str:
465487
"""TAG[.postDISTANCE[.dev0]+gHEX] .
466488
467489
The ".dev0" means dirty. Note that .dev0 sorts backwards
@@ -488,7 +510,7 @@ def render_pep440_post(pieces):
488510
return rendered
489511

490512

491-
def render_pep440_post_branch(pieces):
513+
def render_pep440_post_branch(pieces: Dict[str, Any]) -> str:
492514
"""TAG[.postDISTANCE[.dev0]+gHEX[.dirty]] .
493515
494516
The ".dev0" means not master branch.
@@ -517,7 +539,7 @@ def render_pep440_post_branch(pieces):
517539
return rendered
518540

519541

520-
def render_pep440_old(pieces):
542+
def render_pep440_old(pieces: Dict[str, Any]) -> str:
521543
"""TAG[.postDISTANCE[.dev0]] .
522544
523545
The ".dev0" means dirty.
@@ -539,7 +561,7 @@ def render_pep440_old(pieces):
539561
return rendered
540562

541563

542-
def render_git_describe(pieces):
564+
def render_git_describe(pieces: Dict[str, Any]) -> str:
543565
"""TAG[-DISTANCE-gHEX][-dirty].
544566
545567
Like 'git describe --tags --dirty --always'.
@@ -559,7 +581,7 @@ def render_git_describe(pieces):
559581
return rendered
560582

561583

562-
def render_git_describe_long(pieces):
584+
def render_git_describe_long(pieces: Dict[str, Any]) -> str:
563585
"""TAG-DISTANCE-gHEX[-dirty].
564586
565587
Like 'git describe --tags --dirty --always -long'.
@@ -579,7 +601,7 @@ def render_git_describe_long(pieces):
579601
return rendered
580602

581603

582-
def render(pieces, style):
604+
def render(pieces: Dict[str, Any], style: str) -> Dict[str, Any]:
583605
"""Render the given version pieces into the requested style."""
584606
if pieces["error"]:
585607
return {"version": "unknown",
@@ -615,7 +637,7 @@ def render(pieces, style):
615637
"date": pieces.get("date")}
616638

617639

618-
def get_versions():
640+
def get_versions() -> Dict[str, Any]:
619641
"""Get version information or return default if unable to do so."""
620642
# I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have
621643
# __file__, we can work backwards from there to the root. Some

pyproject.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ requires = [
99
"numba>=0.59.0",
1010
"dpctl>=0.16.1",
1111
"numpy>=1.24.0",
12-
"wheel"
12+
"wheel",
13+
# WARNING: check with doc how to upgrade
14+
"versioneer[toml]==0.29"
1315
]
1416

1517
[project]
@@ -65,7 +67,7 @@ Issues = "https://github.com/IntelPython/numba-dpex/issues"
6567
Repository = "https://github.com/IntelPython/numba-dpex.git"
6668

6769
[tool.black]
68-
exclude = "versioneer.py|numba_dpex/_version.py"
70+
exclude = "numba_dpex/_version.py"
6971
line-length = 80
7072

7173
[tool.coverage.report]
@@ -102,7 +104,7 @@ force_grid_wrap = 0
102104
include_trailing_comma = true
103105
line_length = 80
104106
multi_line_output = 3
105-
skip = ["versioneer.py", "numba_dpex/_version.py"]
107+
skip = ["numba_dpex/_version.py"]
106108
use_parentheses = true
107109

108110
[tool.pylint]

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55

66
import re
77

8+
import versioneer
89
from setuptools import find_packages
910
from skbuild import setup
1011

11-
import versioneer
12-
1312
"""Top level setup.py file. Uses scikit-build.
1413
1514
This will build the numba_dpex project. There are two ways to run this file.

0 commit comments

Comments
 (0)