Skip to content

Commit f431d1e

Browse files
Merge pull request #1148 from adamtheturtle/scm-setuptools
Swap versioneer for scm_setuptools
2 parents 00b7742 + e8be2a1 commit f431d1e

File tree

11 files changed

+32
-2384
lines changed

11 files changed

+32
-2384
lines changed

.git_archival.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ref-names: $Format:%D$

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
src/vws/_version.py export-subst
1+
.git_archival.txt export-subst

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,6 @@ secrets.tar
106106

107107
# pytest
108108
.pytest_cache/
109+
110+
# setuptools_scm
111+
src/*/_setuptools_scm_version.txt

docs/source/conf.py

Lines changed: 2 additions & 1 deletion
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.__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

Lines changed: 5 additions & 7 deletions
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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ VWS-Auth-Tools==2019.12.27.1
22
requests==2.22.0
33
timeout-decorator==0.4.1
44
urllib3==1.25.7
5+
setuptools-scm==3.3.3

setup.cfg

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ ignore =
2323
doc8.ini
2424
docs
2525
docs/*
26+
.git_archival.txt
2627
mypy.ini
2728
pylintrc
2829
pytest.ini
@@ -34,27 +35,15 @@ ignore =
3435
lint.mk
3536

3637
[flake8]
37-
exclude=./versioneer.py,
38-
./src/vws/_version.py,
38+
exclude=./.eggs,
3939
./build/,
4040

41-
# See the docstring in versioneer.py for instructions. Note that you must
42-
# re-run 'versioneer.py setup' after changing this section, and commit the
43-
# resulting files.
44-
[versioneer]
45-
VCS = git
46-
style = pep440
47-
versionfile_source = src/vws/_version.py
48-
versionfile_build = vws/_version.py
49-
tag_prefix =
50-
parentdir_prefix = vws
51-
5241
[bdist_wheel]
5342
universal = 1
5443

5544
[doc8]
5645
max-line-length = 2000
57-
ignore-path = ./src/*.egg-info/SOURCES.txt,./docs/build/spelling/output.txt
46+
ignore-path = ./src/*.egg-info/SOURCES.txt,./docs/build/spelling/output.txt,./.eggs,src/*/_setuptools_scm_version.txt
5847

5948
[tool:pytest]
6049
xfail_strict=true
@@ -78,12 +67,6 @@ warn_return_any = True
7867
warn_unused_configs = True
7968
warn_unused_ignores = True
8069

81-
[mypy-vws/_version]
82-
ignore_errors = True
83-
84-
[mypy-versioneer]
85-
ignore_errors = True
86-
8770
[pydocstyle]
8871
# No summary lines
8972
# - D200
@@ -104,17 +87,13 @@ ignore_errors = True
10487
# Do not care about imperative mood
10588
# - D401
10689
ignore = D200,D202,D203,D205,D212,D400,D406,D407,D413,D401,D415
107-
match=(?!.*(versioneer|test_|_version)).*\.py
10890

10991
[isort]
11092
multi_line_output=3
11193
include_trailing_comma=true
11294

11395
[coverage:run]
11496
branch = True
115-
omit =
116-
*_vendor*
117-
src/*/_version.py
11897

11998
[yapf]
12099
DEDENT_CLOSING_BRACKETS = true

setup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
from setuptools import setup
77

8-
import versioneer
9-
108

119
def _get_dependencies(requirements_file: Path) -> List[str]:
1210
"""
@@ -27,8 +25,10 @@ def _get_dependencies(requirements_file: Path) -> List[str]:
2725
)
2826

2927
setup(
30-
version=versioneer.get_version(), # type: ignore
31-
cmdclass=versioneer.get_cmdclass(), # type: ignore
28+
use_scm_version={
29+
'write_to': 'src/vws/_setuptools_scm_version.txt',
30+
},
31+
setup_requires=['setuptools_scm', 'setuptools_scm_git_archive'],
3232
install_requires=INSTALL_REQUIRES,
3333
extras_require={'dev': DEV_REQUIRES},
3434
)

src/vws/__init__.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
A library for Vuforia Web Services.
33
"""
44

5-
from ._version import get_versions
5+
from pathlib import Path
6+
7+
from setuptools_scm import get_version
8+
69
from .query import CloudRecoService
710
from .vws import VWS
811

@@ -11,5 +14,11 @@
1114
'VWS',
1215
]
1316

14-
__version__ = get_versions()['version'] # type: ignore
15-
del get_versions
17+
try:
18+
__version__ = get_version(root='..', relative_to=Path(__file__).parent)
19+
except LookupError: # pragma: no cover
20+
# When pkg_resources and git tags are not available,
21+
# for example in a PyInstaller binary,
22+
# we write the file ``_setuptools_scm_version.py`` on ``pip install``.
23+
_VERSION_FILE = Path(__file__).parent / '_setuptools_scm_version.txt'
24+
__version__ = _VERSION_FILE.read_text()

0 commit comments

Comments
 (0)