mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-01-14 04:50:20 -06:00
Fix appveyor and windows. Resolves #293
This commit is contained in:
@@ -31,15 +31,18 @@ def in_env(repo_cmd_runner, language_version):
|
||||
|
||||
|
||||
def norm_version(version):
|
||||
version = os.path.expanduser(version)
|
||||
if os.name == 'nt': # pragma: no cover (windows)
|
||||
if not distutils.spawn.find_executable(version):
|
||||
# expanduser introduces a leading slash
|
||||
version = version.strip('\\')
|
||||
# The default place for python on windows is:
|
||||
# C:\PythonXX\python.exe
|
||||
version = r'C:\{0}\python.exe'.format(version.replace('.', ''))
|
||||
return version
|
||||
# Try looking up by name
|
||||
if distutils.spawn.find_executable(version):
|
||||
return version
|
||||
|
||||
# If it is in the form pythonx.x search in the default
|
||||
# place on windows
|
||||
if version.startswith('python'):
|
||||
return r'C:\{0}\python.exe'.format(version.replace('.', ''))
|
||||
|
||||
# Otherwise assume it is a path
|
||||
return os.path.expanduser(version)
|
||||
|
||||
|
||||
def install_environment(
|
||||
|
||||
@@ -12,13 +12,14 @@ from pre_commit import five
|
||||
try:
|
||||
if not os.environ.get('TERM'): # pragma: no cover (dumb terminal)
|
||||
raise OSError('Cannot determine width without TERM')
|
||||
COLS = int(
|
||||
subprocess.Popen(
|
||||
('tput', 'cols'), stdout=subprocess.PIPE,
|
||||
).communicate()[0] or
|
||||
# Default in the case of no terminal
|
||||
80
|
||||
)
|
||||
else: # pragma no cover (windows)
|
||||
COLS = int(
|
||||
subprocess.Popen(
|
||||
('tput', 'cols'), stdout=subprocess.PIPE,
|
||||
).communicate()[0] or
|
||||
# Default in the case of no terminal
|
||||
80
|
||||
)
|
||||
except OSError: # pragma: no cover (windows)
|
||||
COLS = 80
|
||||
|
||||
|
||||
Reference in New Issue
Block a user