Skip to content

Commit

Permalink
fix: Fix version getting in setup.py
Browse files Browse the repository at this point in the history
  • Loading branch information
beneboy committed Oct 17, 2019
1 parent b941e89 commit ee6ef34
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion py/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include README-python.md LICENSE
include README.md LICENSE version
16 changes: 15 additions & 1 deletion py/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,27 @@
with io.open(os.path.join(HERE, 'README.md'), encoding='utf-8') as f:
long_description = '\n' + f.read()

VERSION_PATH = os.path.join(HERE, 'version')


def get_tag_version() -> str:
result = subprocess.run(['git', 'describe', '--tags', '--abbrev=0'], stdout=subprocess.PIPE, encoding='ascii')
version = result.stdout
return version[1:] if version.startswith('v') else version


def get_version():
"""On build (in CI), the version should be written out, then included and be available during install."""
if os.path.exists(VERSION_PATH):
with open(VERSION_PATH) as vf:
return vf.read().strip()

tag_version = get_tag_version().strip()
with open(VERSION_PATH, 'w') as vf:
vf.write(tag_version)
return tag_version


class UploadCommand(Command):
"""
Support setup.py upload.
Expand Down Expand Up @@ -64,7 +78,7 @@ def run(self):

setup(
name='stencila-schema',
version=get_tag_version(),
version=get_version(),
description='',
long_description=long_description,
long_description_content_type='text/markdown',
Expand Down

0 comments on commit ee6ef34

Please sign in to comment.