Skip to content

Commit 1024f4f

Browse files
authored
Remove usage of non-portable which (#346)
* Use Python's shutil.which() instead of shelling out to `which` to find Python 2 * Use `command -v` instead of `which` in README Fixes: #333
1 parent 066a02c commit 1024f4f

File tree

3 files changed

+4
-8
lines changed

3 files changed

+4
-8
lines changed

README.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ environment::
211211

212212
$ workon my_env
213213
$ npm install -g coffee-script
214-
$ which coffee
214+
$ command -v coffee
215215
/home/monty/virtualenvs/my_env/bin/coffee
216216
217217
Creating a virtual environment with a custom prompt:

README.ru.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ python'а::
155155

156156
$ workon my_env
157157
$ npm install -g coffee-script
158-
$ which coffee
158+
$ command -v coffee
159159
/home/monty/virtualenvs/my_env/bin/coffee
160160

161161

nodeenv.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -715,12 +715,8 @@ def build_node_from_src(env_dir, src_dir, node_src_dir, args):
715715
# Currently, the node.js build scripts are using python2.*,
716716
# therefore we need to temporarily point python exec to the
717717
# python 2.* version in this case.
718-
try:
719-
_, which_python2_output = callit(
720-
['which', 'python2'], args.verbose, True, node_src_dir, env
721-
)
722-
python2_path = which_python2_output[0]
723-
except (OSError, IndexError):
718+
python2_path = shutil.which('python2')
719+
if not python2_path:
724720
raise OSError(
725721
'Python >=3.0 virtualenv detected, but no python2 '
726722
'command (required for building node.js) was found'

0 commit comments

Comments
 (0)