Skip to content

Commit

Permalink
Remove usage of non-portable which (#346)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
thesamesam authored May 28, 2024
1 parent 066a02c commit 1024f4f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ environment::

$ workon my_env
$ npm install -g coffee-script
$ which coffee
$ command -v coffee
/home/monty/virtualenvs/my_env/bin/coffee
Creating a virtual environment with a custom prompt:
Expand Down
2 changes: 1 addition & 1 deletion README.ru.rst
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ python'а::

$ workon my_env
$ npm install -g coffee-script
$ which coffee
$ command -v coffee
/home/monty/virtualenvs/my_env/bin/coffee


Expand Down
8 changes: 2 additions & 6 deletions nodeenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -715,12 +715,8 @@ def build_node_from_src(env_dir, src_dir, node_src_dir, args):
# Currently, the node.js build scripts are using python2.*,
# therefore we need to temporarily point python exec to the
# python 2.* version in this case.
try:
_, which_python2_output = callit(
['which', 'python2'], args.verbose, True, node_src_dir, env
)
python2_path = which_python2_output[0]
except (OSError, IndexError):
python2_path = shutil.which('python2')
if not python2_path:
raise OSError(
'Python >=3.0 virtualenv detected, but no python2 '
'command (required for building node.js) was found'
Expand Down

0 comments on commit 1024f4f

Please sign in to comment.