Skip to content

Commit 08ab934

Browse files
committed
Swap versioneer for scm_setuptools
1 parent 50247ef commit 08ab934

File tree

11 files changed

+30
-2382
lines changed

11 files changed

+30
-2382
lines changed

.git_archival.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ref-names: $Format:%D$

.gitattributes

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
src/vws_auth_tools/_version.py export-subst
1+
.git_archival.txt export-subst

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,6 @@ venv.bak/
102102

103103
# mypy
104104
.mypy_cache/
105+
106+
# setuptools_scm
107+
src/*/_setuptools_scm_version.txt

docs/source/conf.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
# |version| and |release|, also used in various other places throughout the
3333
# built documents.
3434
version = vws_auth_tools.__version__
35-
release = version.split('+')[0]
35+
_month, _day, _year, *_ = version.split('.')
36+
release = f'{_month}.{_day}.{_year}'
3637

3738
substitutions = [
3839
('|release|', release),

lint.mk

+5-7
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,20 @@ yapf:
77
yapf \
88
--diff \
99
--recursive \
10-
--exclude versioneer.py \
11-
--exclude src/*/_version.py \
10+
--exclude .eggs \
1211
.
1312

1413
.PHONY: fix-yapf
1514
fix-yapf:
1615
yapf \
1716
--in-place \
1817
--recursive \
19-
--exclude versioneer.py \
20-
--exclude src/*/_version.py \
18+
--exclude .eggs \
2119
.
2220

2321
.PHONY: mypy
2422
mypy:
25-
mypy *.py src/ tests/ docs/source/
23+
mypy *.py src/ tests/ docs/source/ admin
2624

2725
.PHONY: check-manifest
2826
check-manifest:
@@ -58,7 +56,7 @@ pyroma:
5856

5957
.PHONY: vulture
6058
vulture:
61-
vulture --min-confidence 100 --exclude _vendor .
59+
vulture --min-confidence 100 --exclude _vendor --exclude .eggs .
6260

6361
.PHONY: linkcheck
6462
linkcheck:
@@ -80,7 +78,7 @@ autoflake:
8078
--remove-all-unused-imports \
8179
--remove-unused-variables \
8280
--expand-star-imports \
83-
--exclude _vendor,src/*/_version.py,versioneer.py,release \
81+
--exclude _vendor,release \
8482
.
8583

8684
.PHONY: pydocstyle

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
setuptools_scm==3.3.3

setup.cfg

+3-22
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ ignore =
2121
doc8.ini
2222
docs
2323
docs/*
24+
.git_archival.txt
2425
minidcos.rb
2526
LICENSE
2627
Makefile
@@ -61,15 +62,8 @@ warn_return_any = True
6162
warn_unused_configs = True
6263
warn_unused_ignores = True
6364

64-
[mypy-vws_auth_tools/_version]
65-
ignore_errors = true
66-
67-
[mypy-versioneer]
68-
ignore_errors = True
69-
7065
[flake8]
71-
exclude=./versioneer.py,
72-
./src/vws_auth_tools/_version.py,
66+
exclude=./.eggs,
7367
./build/,
7468

7569
[isort]
@@ -80,15 +74,14 @@ include_trailing_comma=true
8074
branch = True
8175
omit =
8276
*_vendor*
83-
src/*/_version.py
8477

8578
[yapf]
8679
DEDENT_CLOSING_BRACKETS = true
8780
BLANK_LINE_BEFORE_NESTED_CLASS_OR_DEF = true
8881

8982
[doc8]
9083
max-line-length = 2000
91-
ignore-path = ./node_modules,./src/*.egg-info/,./docs/build/spelling/output.txt
84+
ignore-path = ./node_modules,./src/*.egg-info/,./docs/build/spelling/output.txt,./.eggs,./src/*/_setuptools_scm_version.txt,./docs/build
9285

9386
[pydocstyle]
9487
# No summary lines
@@ -114,18 +107,6 @@ ignore-path = ./node_modules,./src/*.egg-info/,./docs/build/spelling/output.txt
114107
# punctuation
115108
# - D415
116109
ignore = D200,D202,D203,D205,D212,D400,D406,D407,D413,D301,D401,D415
117-
match=(?!.*(versioneer|_version)).*\.py
118-
119-
# See the docstring in versioneer.py for instructions. Note that you must
120-
# re-run 'versioneer.py setup' after changing this section, and commit the
121-
# resulting files.
122-
[versioneer]
123-
VCS = git
124-
style = pep440
125-
versionfile_source = src/vws_auth_tools/_version.py
126-
versionfile_build = vws_auth_tools/_version.py
127-
tag_prefix =
128-
parentdir_prefix = vws_auth_tools
129110

130111
[bdist_wheel]
131112
universal = 1

setup.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
from setuptools import setup
99

10-
import versioneer
11-
1210

1311
def _get_dependencies(requirements_file: Path) -> List[str]:
1412
"""
@@ -30,8 +28,10 @@ def _get_dependencies(requirements_file: Path) -> List[str]:
3028
)
3129

3230
setup(
33-
version=versioneer.get_version(), # type: ignore
34-
cmdclass=versioneer.get_cmdclass(), # type: ignore
31+
use_scm_version={
32+
'write_to': 'src/vws_auth_tools/_setuptools_scm_version.txt',
33+
},
34+
setup_requires=['setuptools_scm', 'setuptools_scm_git_archive'],
3535
install_requires=INSTALL_REQUIRES,
3636
extras_require={'dev': DEV_REQUIRES},
3737
)

src/vws_auth_tools/__init__.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
import email.utils
77
import hashlib
88
import hmac
9+
from pathlib import Path
910

10-
from ._version import get_versions
11+
from setuptools_scm import get_version
1112

1213

1314
def _compute_hmac_base64(key: bytes, data: bytes) -> bytes:
@@ -86,5 +87,11 @@ def authorization_header( # pylint: disable=too-many-arguments
8687
return auth_header
8788

8889

89-
__version__ = get_versions()['version'] # type: ignore
90-
del get_versions
90+
try:
91+
__version__ = get_version(root='..', relative_to=Path(__file__).parent)
92+
except LookupError: # pragma: no cover
93+
# When pkg_resources and git tags are not available,
94+
# for example in a PyInstaller binary,
95+
# we write the file ``_setuptools_scm_version.py`` on ``pip install``.
96+
_VERSION_FILE = Path(__file__).parent / '_setuptools_scm_version.txt'
97+
__version__ = _VERSION_FILE.read_text()

0 commit comments

Comments
 (0)