diff options
author | Leonardo Rochael Almeida <leorochael@gmail.com> | 2017-04-11 11:22:11 -0300 |
---|---|---|
committer | Leonardo Rochael Almeida <leorochael@gmail.com> | 2017-04-11 11:22:11 -0300 |
commit | b0262da2a2dc2654b61842325652d31b77b2af30 (patch) | |
tree | a6e509b5159c1795c35136f31370fbc9f01b6ff8 /setup.py | |
parent | 859eac40ac7d0b5f3260068c4810d027012f0488 (diff) | |
download | appdirs-b0262da2a2dc2654b61842325652d31b77b2af30.tar.gz |
Don't import appdirs from setup.py
In general, setup.py should never import the code it's trying to
install.
During a setup.py run, there is no guarantee that importing `appdirs`
will actually import the one in the same directory as `setup.py`.
Instead, read the version number out of `appdirs.py` by opening it.
Diffstat (limited to 'setup.py')
-rw-r--r-- | setup.py | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -7,7 +7,7 @@ try: from setuptools import setup except ImportError: from distutils.core import setup -import appdirs +import ast tests_require = [] if sys.version_info < (2, 7): @@ -21,9 +21,16 @@ def read(fname): return out +# Do not import `appdirs` yet, lest we import some random version on sys.path. +for line in read("appdirs.py").splitlines(): + if line.startswith("__version__"): + version = ast.literal_eval(line.split("=", 1)[1].strip()) + break + + setup( name='appdirs', - version=appdirs.__version__, + version=version, description='A small Python module for determining appropriate ' + \ 'platform-specific dirs, e.g. a "user data dir".', long_description=read('README.rst') + '\n' + read('CHANGES.rst'), |