Răsfoiți Sursa

Avoid loading package before dependencies are installed.

Thomas Kluyver 11 ani în urmă
părinte
comite
dae1d772ec
1 a modificat fișierele cu 12 adăugiri și 1 ștergeri
  1. 12 1
      setup.py

+ 12 - 1
setup.py

@@ -1,3 +1,4 @@
+import re
 import sys
 from distutils.core import setup
 
@@ -11,7 +12,17 @@ if PY2:
 with open('README.rst', 'r') as f:
     readme=f.read()
 
-from nsist import __version__
+# We used to just import the version number here. But you can't import the
+# package without its dependencies installed, and the dependencies are
+# specified in this file. distutils, a curse on your family even unto the
+# seventh generation. Setuptools, that goes for you too - you had a chance to
+# make this better, and you only made it worse.
+with open('nsist/__init__.py', 'r') as f:
+    for line in f:
+        m = re.match(r"__version__ = (.+)$", line)
+        if m:
+            __version__ = eval(m.group(1))
+            break
 
 setup(name='pynsist',
       version=__version__,