Skip to content

Commit 8029ab0

Browse files
committed
Use setuptools_scm to automatically version the package on tags
1 parent 56e6ce0 commit 8029ab0

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,6 @@ docs/_build/
5656
# PyBuilder
5757
target/
5858
*.swp
59+
60+
# generated by setuptools_scm
61+
pluggy/_version.py

pluggy/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
__version__ = '0.6.1.dev'
1+
try:
2+
from ._version import version as __version__
3+
except ImportError:
4+
# broken installation, we don't even try
5+
# unknown only works because we do poor mans version compare
6+
__version__ = 'unknown'
27

38
__all__ = ["PluginManager", "PluginValidationError", "HookCallError",
49
"HookspecMarker", "HookimplMarker"]

setup.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import os
21
from setuptools import setup
32

43
classifiers = [
@@ -20,22 +19,15 @@
2019
long_description = fd.read()
2120

2221

23-
def get_version():
24-
p = os.path.join(os.path.dirname(
25-
os.path.abspath(__file__)), "pluggy/__init__.py")
26-
with open(p) as f:
27-
for line in f.readlines():
28-
if "__version__" in line:
29-
return line.strip().split("=")[-1].strip(" '")
30-
raise ValueError("could not read version")
31-
32-
3322
def main():
3423
setup(
3524
name='pluggy',
3625
description='plugin and hook calling mechanisms for python',
3726
long_description=long_description,
38-
version=get_version(),
27+
use_scm_version={
28+
'write_to': 'pluggy/_version.py',
29+
},
30+
setup_requires=['setuptools-scm'],
3931
license='MIT license',
4032
platforms=['unix', 'linux', 'osx', 'win32'],
4133
author='Holger Krekel',

0 commit comments

Comments
 (0)