Better exec() detection. Avoids esky build NameError.

This commit is contained in:
Pedro Algarvio 2013-11-14 23:01:30 +00:00
parent cfa3ba3d48
commit 99148a1380
2 changed files with 9 additions and 15 deletions

View file

@ -358,25 +358,17 @@ def __get_version(version, version_info):
import warnings
import subprocess
try:
cwd = os.path.abspath(os.path.dirname(__file__))
except NameError:
# We're most likely being frozen and __file__ triggered this NameError
# Let's work around that
import inspect
cwd = os.path.abspath(
os.path.dirname(inspect.getsourcefile(__get_version))
)
if __file__ == 'setup.py':
if 'SETUP_DIRNAME' in globals():
# This is from the exec() call in Salt's setup.py
cwd = SETUP_DIRNAME # pylint: disable=E0602
if not os.path.exists(os.path.join(cwd, '.git')):
# This is not a Salt git checkout!!! Don't even try to parse...
return version, version_info
elif not os.path.exists(os.path.join(os.path.dirname(cwd), '.git')):
# This is not a Salt git checkout!!! Don't even try to parse...
return version, version_info
else:
cwd = os.path.abspath(os.path.dirname(__file__))
if not os.path.exists(os.path.join(os.path.dirname(cwd), '.git')):
# This is not a Salt git checkout!!! Don't even try to parse...
return version, version_info
try:
kwargs = dict(

View file

@ -33,6 +33,8 @@ except NameError:
if SETUP_DIRNAME != '':
os.chdir(SETUP_DIRNAME)
SETUP_DIRNAME = os.path.abspath(SETUP_DIRNAME)
BOOTSTRAP_SCRIPT_DISTRIBUTED_VERSION = os.environ.get(
# The user can provide a different bootstrap-script version.
# ATTENTION: A tag for that version MUST exist