Skip to content

Commit

Permalink
Drop automatic versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
jacopoantonello committed Jul 14, 2024
1 parent c941f1d commit bbd609c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 43 deletions.
32 changes: 0 additions & 32 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,16 @@

import os
import re
import sys
from io import open # Python 2
from os import path
from subprocess import check_output

from setuptools import find_packages, setup

# Get the long description from the relevant file
here = path.abspath(path.dirname(__file__))
with open(path.join(here, 'README.md'), encoding='utf-8') as f:
long_description = f.read()


def update_version():
try:
toks = check_output('git describe --tags --long --dirty',
universal_newlines=True,
shell=True).strip().split('-')
version = toks[0].strip('v') + '.' + toks[1]
last = check_output('git log -n 1',
universal_newlines=True,
shell=True)
date = re.search(r'^Date:\s+([^\s].*)$', last, re.MULTILINE).group(1)
commit = re.search(r'^commit\s+([^\s]{40})', last,
re.MULTILINE).group(1)
except Exception as e:
version = '0.0.0'
date = 'unknown'
commit = 'unknown'
print('Cannot update version {}'.format(str(e)), file=sys.stderr)

with open(path.join('zernike', 'version.py'), 'w', newline='\n') as f:
f.write('#!/usr/bin/env python\n')
f.write('# -*- coding: utf-8 -*-\n\n')
f.write("__version__ = '{}'\n".format(version))
f.write("__date__ = '{}'\n".format(date))
f.write("__commit__ = '{}'".format(commit))


update_version()


def lookup_version():
with open(os.path.join('zernike', 'version.py'), 'r') as f:
m = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", f.read(), re.M)
Expand Down
16 changes: 5 additions & 11 deletions zernike/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright 2021 Jacopo Antonello
# Copyright 2024 Jacopo Antonello
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -40,18 +40,12 @@
__status__ = 'Production'
__version__ = version.__version__
__date__ = version.__date__
__commit__ = version.__commit__
__doc__ = """
__doc__ = f"""
Python code for Zernike polynomials.
date: {}
version: {}
commit: {}
""".format(
__date__,
__version__,
__commit__,
)
date: {__date__}
version: {__version__}
"""
__docformat__ = 'restructuredtext'

HDF5_options = {
Expand Down

0 comments on commit bbd609c

Please sign in to comment.