mirror of
https://github.com/saltstack/salt.git
synced 2025-04-15 09:10:20 +00:00
Work around __file__
NameError
thrown by bbfreeze
. Fixes #5172.
This commit is contained in:
parent
0aeb2af20f
commit
6996afaf46
2 changed files with 24 additions and 6 deletions
|
@ -34,11 +34,21 @@ 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))
|
||||
)
|
||||
|
||||
try:
|
||||
kwargs = dict(
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
cwd=os.path.abspath(os.path.dirname(__file__))
|
||||
cwd=cwd
|
||||
)
|
||||
|
||||
if not sys.platform.startswith('win'):
|
||||
|
|
18
setup.py
18
setup.py
|
@ -15,7 +15,13 @@ from distutils.command.clean import clean
|
|||
from distutils.sysconfig import get_python_lib, PREFIX
|
||||
|
||||
# Change to salt source's directory prior to running any command
|
||||
setup_dirname = os.path.dirname(__file__)
|
||||
try:
|
||||
setup_dirname = os.path.dirname(__file__)
|
||||
except NameError:
|
||||
# We're most likely being frozen and __file__ triggered this NameError
|
||||
# Let's work around that
|
||||
setup_dirname = os.path.dirname(sys.argv[0])
|
||||
|
||||
if setup_dirname != '':
|
||||
os.chdir(setup_dirname)
|
||||
|
||||
|
@ -54,11 +60,13 @@ try:
|
|||
except ImportError:
|
||||
HAS_ESKY = False
|
||||
|
||||
salt_version = os.path.join(os.path.abspath(
|
||||
os.path.dirname(__file__)), 'salt', 'version.py')
|
||||
salt_version = os.path.join(
|
||||
os.path.abspath(setup_dirname), 'salt', 'version.py'
|
||||
)
|
||||
|
||||
salt_reqs = os.path.join(os.path.abspath(
|
||||
os.path.dirname(__file__)), 'requirements.txt')
|
||||
salt_reqs = os.path.join(
|
||||
os.path.abspath(setup_dirname), 'requirements.txt'
|
||||
)
|
||||
|
||||
exec(compile(open(salt_version).read(), salt_version, 'exec'))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue