set_path contextmanager, no amalg on develop

This commit is contained in:
laerus 2016-07-23 15:33:41 +03:00 committed by Leonardo Santagada
parent d6fe5ce87b
commit c6835d01bc

View file

@ -8,6 +8,7 @@ import os
import sys import sys
import json import json
import subprocess import subprocess
import contextlib
try: try:
from tempfile import TemporaryDirectory from tempfile import TemporaryDirectory
@ -35,6 +36,12 @@ except ImportError:
HAVE_JUPYTER = False 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', TABLES = ['xonsh/lexer_table.py', 'xonsh/parser_table.py',
'xonsh/__amalgam__.py', 'xonsh/completers/__amalgam__.py'] 'xonsh/__amalgam__.py', 'xonsh/completers/__amalgam__.py']
@ -51,7 +58,7 @@ os.environ['XONSH_DEBUG'] = '1'
from xonsh import __version__ as XONSH_VERSION from xonsh import __version__ as XONSH_VERSION
def amalagamate_source(): def amalgamate_source():
"""Amalgamtes source files.""" """Amalgamtes source files."""
try: try:
import amalgamate import amalgamate
@ -65,12 +72,9 @@ def amalagamate_source():
def build_tables(): def build_tables():
"""Build the lexer/parser modules.""" """Build the lexer/parser modules."""
print('Building lexer and parser tables.') print('Building lexer and parser tables.')
sys.path.insert(0, os.path.dirname(__file__))
from xonsh.parser import Parser from xonsh.parser import Parser
Parser(lexer_table='lexer_table', yacc_table='parser_table', Parser(lexer_table='lexer_table', yacc_table='parser_table',
outputdir='xonsh') outputdir='xonsh')
amalagamate_source()
sys.path.pop(0)
def install_jupyter_hook(prefix=None, root=None): def install_jupyter_hook(prefix=None, root=None):
@ -163,7 +167,9 @@ class xinstall(install):
"""Xonsh specialization of setuptools install class.""" """Xonsh specialization of setuptools install class."""
def run(self): def run(self):
clean_tables() clean_tables()
with set_path():
build_tables() build_tables()
amalagmate_source()
# add dirty version number # add dirty version number
dirty = dirty_version() dirty = dirty_version()
# install Jupyter hook # install Jupyter hook
@ -184,7 +190,9 @@ class xsdist(sdist):
"""Xonsh specialization of setuptools sdist class.""" """Xonsh specialization of setuptools sdist class."""
def make_release_tree(self, basedir, files): def make_release_tree(self, basedir, files):
clean_tables() clean_tables()
with set_path():
build_tables() build_tables()
amalgmate_source()
dirty = dirty_version() dirty = dirty_version()
sdist.make_release_tree(self, basedir, files) sdist.make_release_tree(self, basedir, files)
if dirty: if dirty:
@ -218,6 +226,7 @@ if HAVE_SETUPTOOLS:
"""Xonsh specialization of setuptools develop class.""" """Xonsh specialization of setuptools develop class."""
def run(self): def run(self):
clean_tables() clean_tables()
with set_path():
build_tables() build_tables()
dirty = dirty_version() dirty = dirty_version()
develop.run(self) develop.run(self)