Skip to content

Commit c434a49

Browse files
fix: remove pip as a dependency
1 parent 6fb536f commit c434a49

File tree

2 files changed

+24
-18
lines changed

2 files changed

+24
-18
lines changed

zulip/zulip/__init__.py

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import os
66
import platform
77
import random
8+
import subprocess
89
import sys
910
import time
1011
import traceback
@@ -293,24 +294,30 @@ def generate_option_group(parser: optparse.OptionParser, prefix: str = "") -> op
293294
def init_from_options(options: Any, client: Optional[str] = None) -> "Client":
294295
if getattr(options, "provision", False):
295296
requirements_path = os.path.abspath(os.path.join(sys.path[0], "requirements.txt"))
296-
try:
297-
import pip
298-
except ImportError:
299-
traceback.print_exc()
300-
print(
301-
"Module `pip` is not installed. To install `pip`, follow the instructions here: "
302-
"https://pip.pypa.io/en/stable/installing/"
303-
)
304-
sys.exit(1)
305-
if not pip.main(["install", "--upgrade", "--requirement", requirements_path]):
306-
print(
307-
"{color_green}You successfully provisioned the dependencies for {script}.{end_color}".format(
308-
color_green="\033[92m",
309-
end_color="\033[0m",
310-
script=os.path.splitext(os.path.basename(sys.argv[0]))[0],
311-
)
297+
current_python_executable = os.path.abspath(sys.executable)
298+
provisioning_exit_code = subprocess.call(
299+
[
300+
current_python_executable,
301+
"-m",
302+
"pip",
303+
"install",
304+
"--upgrade",
305+
"--requirement",
306+
requirements_path,
307+
]
308+
)
309+
provisioning_succeeded = provisioning_exit_code == 0
310+
color_green = "\033[92m"
311+
color_red = "\033[91m"
312+
print(
313+
"{text_color}Dependency provisioning {status_text} for {script}.{end_color}".format(
314+
text_color=color_green if provisioning_succeeded else color_red,
315+
end_color="\033[0m",
316+
script=os.path.splitext(os.path.basename(sys.argv[0]))[0],
317+
status_text="succeeded" if provisioning_succeeded else "failed",
312318
)
313-
sys.exit(0)
319+
)
320+
sys.exit(provisioning_exit_code)
314321

315322
if options.zulip_client is not None:
316323
client = options.zulip_client

zulip_bots/setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
],
5151
},
5252
install_requires=[
53-
"pip",
5453
"zulip",
5554
"html2text",
5655
"lxml",

0 commit comments

Comments
 (0)