Skip to content

Commit 26953a6

Browse files
ensure we find our own version in a sdist
1 parent 9cf2009 commit 26953a6

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

setup.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@
2424
sys.exit('please run `python setup.py egg_info` first')
2525

2626

27+
def _find_hackish_version():
28+
here = os.path.dirname(os.path.abspath(__file__))
29+
sys.path.insert(0, here)
30+
from setuptools_scm.hacks import parse_pkginfo
31+
from setuptools_scm import get_version
32+
try:
33+
return get_version(
34+
root=here, parse=parse_pkginfo,
35+
**scm_config())
36+
except IOError:
37+
pass
38+
39+
2740
def scm_config():
2841
from setuptools_scm.version import (
2942
guess_next_dev_version,
@@ -37,13 +50,15 @@ def scm_config():
3750
with open('README.rst') as fp:
3851
long_description = fp.read()
3952

53+
found_version = _find_hackish_version()
4054

4155
arguments = dict(
4256
name='setuptools_scm',
4357
url='https://github.com/pypa/setuptools_scm/',
4458
zip_safe=True,
59+
version=found_version,
4560
# pass here since entrypints are not yet registred
46-
use_scm_version=scm_config,
61+
use_scm_version=found_version is None and scm_config,
4762
author='Ronny Pfannschmidt',
4863
author_email='[email protected]',
4964
description=('the blessed package to manage your versions by scm tags'),

0 commit comments

Comments
 (0)