mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10: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 warnings
|
||||||
import subprocess
|
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:
|
try:
|
||||||
kwargs = dict(
|
kwargs = dict(
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE,
|
stderr=subprocess.PIPE,
|
||||||
cwd=os.path.abspath(os.path.dirname(__file__))
|
cwd=cwd
|
||||||
)
|
)
|
||||||
|
|
||||||
if not sys.platform.startswith('win'):
|
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
|
from distutils.sysconfig import get_python_lib, PREFIX
|
||||||
|
|
||||||
# Change to salt source's directory prior to running any command
|
# 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 != '':
|
if setup_dirname != '':
|
||||||
os.chdir(setup_dirname)
|
os.chdir(setup_dirname)
|
||||||
|
|
||||||
|
@ -54,11 +60,13 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
HAS_ESKY = False
|
HAS_ESKY = False
|
||||||
|
|
||||||
salt_version = os.path.join(os.path.abspath(
|
salt_version = os.path.join(
|
||||||
os.path.dirname(__file__)), 'salt', 'version.py')
|
os.path.abspath(setup_dirname), 'salt', 'version.py'
|
||||||
|
)
|
||||||
|
|
||||||
salt_reqs = os.path.join(os.path.abspath(
|
salt_reqs = os.path.join(
|
||||||
os.path.dirname(__file__)), 'requirements.txt')
|
os.path.abspath(setup_dirname), 'requirements.txt'
|
||||||
|
)
|
||||||
|
|
||||||
exec(compile(open(salt_version).read(), salt_version, 'exec'))
|
exec(compile(open(salt_version).read(), salt_version, 'exec'))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue