Skip to content

Commit 1057068

Browse files
committed
Fix setup.py dependency cycle
The __init__.py can't be imported if the dependencies of this package aren't installed. But they can't be installed if the module cant load setup.py. So we got a dependencie cycle. All this is related to the version number, which is loaded from __init__. Hence we now parse the file only for the version string. So we must not load the imports in __init__
1 parent fc235bc commit 1057068

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

setup.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,23 @@
22
# -*- coding: utf-8 -*-
33

44
from setuptools import setup, find_packages
5+
from ast import parse
6+
import os
57

6-
from pandas_metricsreader import __version__
8+
9+
def version():
10+
"""Return version string."""
11+
with open(os.path.join(os.path.abspath(os.path.dirname(__file__)),
12+
'pandas_metricsreader',
13+
'__init__.py')) as input_file:
14+
for line in input_file:
15+
if line.startswith('__version__'):
16+
return parse(line).body[0].value.s
717

818
setup(
919
name='pandas-metricsreader',
1020
packages=find_packages(exclude=['docs', 'tests*']),
11-
version=__version__,
21+
version=version(),
1222
description='Read data from different monitoring systems into a pandas DataFrame',
1323
author='Moritz C.K.U. Schneider',
1424
author_email='[email protected]',

0 commit comments

Comments
 (0)