diff --git a/setup.py b/setup.py index 251778db..b0460c58 100644 --- a/setup.py +++ b/setup.py @@ -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()