Get Hy working on Windows by making readline use conditional.
This commit is contained in:
parent
b65c2a4596
commit
888dc19882
2
AUTHORS
2
AUTHORS
@ -14,4 +14,4 @@
|
|||||||
* Thomas Ballinger <thomasballinger@gmail.com>
|
* Thomas Ballinger <thomasballinger@gmail.com>
|
||||||
* Morten Linderud <mcfoxax@gmail.com>
|
* Morten Linderud <mcfoxax@gmail.com>
|
||||||
* Guillermo Vayá <guivaya@gmail.com>
|
* Guillermo Vayá <guivaya@gmail.com>
|
||||||
|
* Ralph Möritz <ralph.moeritz@outlook.com>
|
||||||
|
@ -28,7 +28,6 @@ import ast
|
|||||||
import code
|
import code
|
||||||
import optparse
|
import optparse
|
||||||
import os
|
import os
|
||||||
import readline
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import hy
|
import hy
|
||||||
@ -40,13 +39,13 @@ from hy.core import process
|
|||||||
from hy.importer import ast_compile, import_buffer_to_module
|
from hy.importer import ast_compile, import_buffer_to_module
|
||||||
|
|
||||||
import hy.completer
|
import hy.completer
|
||||||
|
from hy.readline_helpers import read_history_file, write_history_file
|
||||||
|
|
||||||
from hy.macros import macro, require
|
from hy.macros import macro, require
|
||||||
from hy.models.expression import HyExpression
|
from hy.models.expression import HyExpression
|
||||||
from hy.models.string import HyString
|
from hy.models.string import HyString
|
||||||
from hy.models.symbol import HySymbol
|
from hy.models.symbol import HySymbol
|
||||||
|
|
||||||
|
|
||||||
_machine = Machine(Idle, 1, 0)
|
_machine = Machine(Idle, 1, 0)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -185,15 +184,7 @@ def run_repl(hr=None):
|
|||||||
sys.ps1 = "=> "
|
sys.ps1 = "=> "
|
||||||
sys.ps2 = "... "
|
sys.ps2 = "... "
|
||||||
|
|
||||||
history = os.path.expanduser("~/.hy-history")
|
history = read_history_file()
|
||||||
readline.parse_and_bind("set blink-matching-paren on")
|
|
||||||
|
|
||||||
try:
|
|
||||||
readline.read_history_file(history)
|
|
||||||
except IOError:
|
|
||||||
open(history, 'a').close()
|
|
||||||
|
|
||||||
readline.parse_and_bind("tab: complete")
|
|
||||||
|
|
||||||
if not hr:
|
if not hr:
|
||||||
hr = HyREPL()
|
hr = HyREPL()
|
||||||
@ -201,7 +192,9 @@ def run_repl(hr=None):
|
|||||||
appname=hy.__appname__,
|
appname=hy.__appname__,
|
||||||
version=hy.__version__
|
version=hy.__version__
|
||||||
))
|
))
|
||||||
readline.write_history_file(history)
|
|
||||||
|
write_history_file(history)
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
import hy.macros
|
import hy.macros
|
||||||
import hy.compiler
|
import hy.compiler
|
||||||
|
from hy.readline_helpers import set_completer
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import __builtin__
|
import __builtin__
|
||||||
@ -57,11 +58,5 @@ class Completer(object):
|
|||||||
except IndexError:
|
except IndexError:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
set_completer(Completer().complete, "()[]{} ")
|
||||||
|
|
||||||
try:
|
|
||||||
import readline
|
|
||||||
except ImportError:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
readline.set_completer(Completer().complete)
|
|
||||||
readline.set_completer_delims("()[]{} ")
|
|
||||||
|
65
hy/readline_helpers.py
Normal file
65
hy/readline_helpers.py
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (c) 2013 Paul Tagliamonte <paultag@debian.org>
|
||||||
|
# Copyright (c) 2013 Gergely Nagy <algernon@madhouse-project.org>
|
||||||
|
# Copyright (c) 2013 James King <james@agentultra.com>
|
||||||
|
# Copyright (c) 2013 Julien Danjou <julien@danjou.info>
|
||||||
|
# Copyright (c) 2013 Konrad Hinsen <konrad.hinsen@fastmail.net>
|
||||||
|
# Copyright (c) 2013 Thom Neale <twneale@gmail.com>
|
||||||
|
# Copyright (c) 2013 Will Kahn-Greene <willg@bluesock.org>
|
||||||
|
# Copyright (c) 2013 Ralph Möritz <ralph.moeritz@outlook.com>
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
# copy of this software and associated documentation files (the "Software"),
|
||||||
|
# to deal in the Software without restriction, including without limitation
|
||||||
|
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
# and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
# Software is furnished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
# DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
noop = False
|
||||||
|
|
||||||
|
try:
|
||||||
|
import readline
|
||||||
|
except ImportError:
|
||||||
|
try:
|
||||||
|
import pyreadline.rlmain
|
||||||
|
import pyreadline.unicode_helper
|
||||||
|
import readline
|
||||||
|
except ImportError:
|
||||||
|
noop = True
|
||||||
|
|
||||||
|
def set_completer(completer, delims):
|
||||||
|
if not noop:
|
||||||
|
readline.set_completer(completer)
|
||||||
|
readline.set_completer_delims(delims)
|
||||||
|
|
||||||
|
def read_history_file():
|
||||||
|
if noop:
|
||||||
|
return None
|
||||||
|
|
||||||
|
history = os.path.expanduser("~/.hy-history")
|
||||||
|
readline.parse_and_bind("set blink-matching-paren on")
|
||||||
|
|
||||||
|
try:
|
||||||
|
readline.read_history_file(history)
|
||||||
|
except IOError:
|
||||||
|
open(history, 'a').close()
|
||||||
|
|
||||||
|
readline.parse_and_bind("tab: complete")
|
||||||
|
return history
|
||||||
|
|
||||||
|
def write_history_file(history):
|
||||||
|
if not noop:
|
||||||
|
readline.write_history_file(history)
|
6
setup.py
6
setup.py
@ -22,16 +22,20 @@
|
|||||||
|
|
||||||
from hy import __appname__, __version__
|
from hy import __appname__, __version__
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
|
import os
|
||||||
|
|
||||||
long_description = """Hy is a Python <--> Lisp layer. It helps
|
long_description = """Hy is a Python <--> Lisp layer. It helps
|
||||||
make things work nicer, and lets Python and the Hy lisp variant play
|
make things work nicer, and lets Python and the Hy lisp variant play
|
||||||
nice together. """
|
nice together. """
|
||||||
|
|
||||||
|
install_requires = []
|
||||||
|
if os.name == 'nt':
|
||||||
|
install_requires.append('pyreadline==2.0')
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name=__appname__,
|
name=__appname__,
|
||||||
version=__version__,
|
version=__version__,
|
||||||
|
install_requires=install_requires,
|
||||||
scripts=[
|
scripts=[
|
||||||
"bin/hy",
|
"bin/hy",
|
||||||
"bin/hyc",
|
"bin/hyc",
|
||||||
|
Loading…
Reference in New Issue
Block a user