httpie-cli/tests/prompt/utils.py
Mickaël Schoentgen 279e387d86 WIP
2021-10-08 10:45:49 +02:00

23 lines
623 B
Python

import os
import sys
def get_http_prompt_path():
"""Get the path to http-prompt executable."""
python_dir = os.path.dirname(sys.executable)
bin_name = 'http-prompt'
if sys.platform == 'win32':
bin_name += '.exe'
paths = [
os.path.join(python_dir, bin_name),
os.path.join(python_dir, 'Scripts', bin_name), # Windows
'/usr/bin/http-prompt' # Homebrew installation
]
for path in paths:
if os.path.exists(path):
return path
raise OSError("could not locate http-prompt executable, "
"Python directory: %s" % python_dir)