manipulate path directly in funcs that need it

This commit is contained in:
laerus 2016-07-23 20:48:34 +03:00 committed by Leonardo Santagada
parent 2c2539ad4b
commit 95ce8c52ee

View file

@ -36,12 +36,6 @@ except ImportError:
HAVE_JUPYTER = False
@contextlib.contextmanager
def set_path():
sys.path.insert(0, os.path.dirname(__file__))
yield
sys.path.pop(0)
TABLES = ['xonsh/lexer_table.py', 'xonsh/parser_table.py',
'xonsh/__amalgam__.py', 'xonsh/completers/__amalgam__.py']
@ -60,6 +54,7 @@ from xonsh import __version__ as XONSH_VERSION
def amalgamate_source():
"""Amalgamtes source files."""
sys.path.insert(0, os.path.dirname(__file__))
try:
import amalgamate
except ImportError:
@ -67,14 +62,17 @@ def amalgamate_source():
return
amalgamate.main(['amalgamate', '--debug=XONSH_DEBUG', 'xonsh',
'xonsh.completers'])
sys.path.pop(0)
def build_tables():
"""Build the lexer/parser modules."""
print('Building lexer and parser tables.')
sys.path.insert(0, os.path.dirname(__file__))
from xonsh.parser import Parser
Parser(lexer_table='lexer_table', yacc_table='parser_table',
outputdir='xonsh')
sys.path.pop(0)
def install_jupyter_hook(prefix=None, root=None):
@ -167,9 +165,8 @@ class xinstall(install):
"""Xonsh specialization of setuptools install class."""
def run(self):
clean_tables()
with set_path():
build_tables()
amalgamate_source()
build_tables()
amalgamate_source()
# add dirty version number
dirty = dirty_version()
# install Jupyter hook
@ -190,9 +187,8 @@ class xsdist(sdist):
"""Xonsh specialization of setuptools sdist class."""
def make_release_tree(self, basedir, files):
clean_tables()
with set_path():
build_tables()
amalgamate_source()
build_tables()
amalgamate_source()
dirty = dirty_version()
sdist.make_release_tree(self, basedir, files)
if dirty:
@ -226,8 +222,7 @@ if HAVE_SETUPTOOLS:
"""Xonsh specialization of setuptools develop class."""
def run(self):
clean_tables()
with set_path():
build_tables()
build_tables()
dirty = dirty_version()
develop.run(self)
if dirty: