mwilliamson / spur.py

Run commands and manipulate files locally or over SSH using the same interface
BSD 2-Clause "Simplified" License
267 stars 37 forks source link

Depends on termios, which is unix only #16

Closed erikalfthan closed 10 years ago

erikalfthan commented 10 years ago

I tried to install this on Windows, which worked, but when importing, it failed due to missing termios. Termios is a unix only module.

EDIT: I tried to install this with Portable Python 2.7.5.1 on Windows

This should be noted in the readme and perhaps the setup.py should fail if termios is missing.

mwilliamson commented 10 years ago

Could you provide a stack trace? Spur doesn't directly import termios, and there's no particular reason I know of why Spur shouldn't support Windows (which is to say: the lack of Windows support is not intentional!).

erikalfthan commented 10 years ago

EDIT: Removed "false" blame, tty module is not working on a standard 2.7.x Windows installation either

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

E:\>cd "Portable Python 2.7.5.1\App\Scripts"

E:\Portable Python 2.7.5.1\App\Scripts>pip install spur
Downloading/unpacking spur
  Downloading spur-0.3.10.tar.gz
  Running setup.py (path:*** CLEANED PATH ***\s
pur\setup.py) egg_info for package spur

Requirement already satisfied (use --upgrade to upgrade): paramiko>=1.13.0,<2 in
 e:\portable python 2.7.5.1\app\lib\site-packages (from spur)
Installing collected packages: spur
  Running setup.py install for spur

Successfully installed spur
Cleaning up...

E:\Portable Python 2.7.5.1\App\Scripts>..\python
Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import spur
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "E:\Portable Python 2.7.5.1\App\lib\site-packages\spur\__init__.py", line
 1, in <module>
    from spur.local import LocalShell
  File "E:\Portable Python 2.7.5.1\App\lib\site-packages\spur\local.py", line 4,
 in <module>
    import pty
  File "E:\Portable Python 2.7.5.1\App\lib\pty.py", line 11, in <module>
    import tty
  File "E:\Portable Python 2.7.5.1\App\lib\tty.py", line 5, in <module>
    from termios import *
ImportError: No module named termios
>>> import tty
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "E:\Portable Python 2.7.5.1\App\lib\tty.py", line 5, in <module>
    from termios import *
ImportError: No module named termios
>>>
mwilliamson commented 10 years ago

Looks like the pty module is the culprit, so it makes sense it wouldn't be supported on Windows. Since it's only used in an experimental feature, we can just handle the failure to import.

erikalfthan commented 10 years ago

(Verified that the tty is not supported on standard Windows 2.7.x Python either)

erikalfthan commented 10 years ago

The solution is confirmed, I tried an "ugly patch", i.e. I didnt clean up the exceptions thrown if using the pty option, but if you are not, this change in local.py line 4 is enough to make it Windows-compatible

try:
    import pty
except ImportError,e:
    # Failed to import experimental pty support
    pass
mwilliamson commented 10 years ago

I've just published 0.3.11 to PyPI which should fix the issue. Thanks for the report!