Skip to content

Commit

Permalink
setup.py - simplify get_version
Browse files Browse the repository at this point in the history
  • Loading branch information
adamchainz committed Jul 15, 2017
1 parent 835db10 commit e96e74d
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions setup.py
Expand Up @@ -5,16 +5,13 @@
from setuptools import setup


def get_version(package):
"""
Return package version as listed in `__version__` in `__init__.py`.
"""
with codecs.open(os.path.join(package, '__init__.py'), 'r', 'utf-8') as fp:
init_py = fp.read()
return re.search("__version__ = ['\"]([^'\"]+)['\"]", init_py).group(1)
def get_version(filename):
with codecs.open(filename, 'r', 'utf-8') as fp:
contents = fp.read()
return re.search(r"__version__ = ['\"]([^'\"]+)['\"]", contents).group(1)


version = get_version('corsheaders')
version = get_version(os.path.join('corsheaders', '__init__.py'))

with codecs.open('README.rst', 'r', 'utf-8') as readme_file:
readme = readme_file.read()
Expand Down

0 comments on commit e96e74d

Please sign in to comment.