Skip to content

Commit 7d09fa8

Browse files
authored
Require flake8 to actually be on the path. (#3201)
1 parent c00f28f commit 7d09fa8

File tree

1 file changed

+4
-38
lines changed

1 file changed

+4
-38
lines changed

scripts/check_lint.py

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import argparse
2323
import logging
2424
import os
25-
import re
2625
import subprocess
2726
import sys
2827
import textwrap
@@ -144,7 +143,7 @@ def lint_py(files):
144143
_flake8_warned = True
145144
_logger.warn(textwrap.dedent(
146145
"""
147-
Could not find flake8 on the path; skipping python lint.
146+
Could not find flake8 on $PATH; skipping python lint.
148147
Install with:
149148
150149
pip install --user flake8
@@ -182,41 +181,6 @@ def _unique(items):
182181
return list(set(items))
183182

184183

185-
def make_path():
186-
"""Makes a list of paths to search for binaries.
187-
188-
Returns:
189-
A list of directories that can be sources of binaries to run. This includes
190-
both the PATH environment variable and any bin directories associated with
191-
python install locations.
192-
"""
193-
# Start with the system-supplied PATH.
194-
path = os.environ['PATH'].split(os.pathsep)
195-
196-
# In addition, add any bin directories near the lib directories in the python
197-
# path. This makes it possible to find flake8 in ~/Library/Python/2.7/bin
198-
# after pip install --user flake8. Also handle installations on Windows which
199-
# go in %APPDATA%/Python/Scripts.
200-
lib_pattern = re.compile(r'(.*)/[^/]*/site-packages')
201-
for entry in sys.path:
202-
entry = entry.replace(os.sep, '/')
203-
m = lib_pattern.match(entry)
204-
if not m:
205-
continue
206-
207-
python_root = m.group(1).replace('/', os.sep)
208-
209-
for bin_basename in ('bin', 'Scripts'):
210-
bin_dir = os.path.join(python_root, bin_basename)
211-
if bin_dir not in path and os.path.exists(bin_dir):
212-
path.append(bin_dir)
213-
214-
return path
215-
216-
217-
_PATH = make_path()
218-
219-
220184
def which(executable):
221185
"""Finds the executable with the given name.
222186
@@ -227,8 +191,10 @@ def which(executable):
227191
if executable.startswith('/'):
228192
return executable
229193

194+
path = os.environ['PATH'].split(os.pathsep)
195+
230196
for executable_with_ext in _executable_names(executable):
231-
for entry in _PATH:
197+
for entry in path:
232198
joined = os.path.join(entry, executable_with_ext)
233199
if os.path.isfile(joined) and os.access(joined, os.X_OK):
234200
return joined

0 commit comments

Comments
 (0)