Check if curl and unzip are installed (#386)

This commit is contained in:
Francesco Ambrosini 2023-01-30 21:13:54 +01:00 committed by GitHub
parent ca637801a6
commit 4c7d923b7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,7 +17,6 @@ from collections import defaultdict
from pathlib import Path from pathlib import Path
from subprocess import DEVNULL, PIPE, STDOUT from subprocess import DEVNULL, PIPE, STDOUT
from types import ModuleType from types import ModuleType
from typing import _GenericAlias # type: ignore
from typing import ( from typing import (
TYPE_CHECKING, TYPE_CHECKING,
Any, Any,
@ -29,6 +28,7 @@ from typing import (
Type, Type,
Union, Union,
) )
from typing import _GenericAlias # type: ignore
from urllib.parse import urlparse from urllib.parse import urlparse
import psutil import psutil
import plotly.graph_objects as go import plotly.graph_objects as go
@ -414,7 +414,11 @@ def initialize_web_directory():
def install_bun(): def install_bun():
"""Install bun onto the user's system.""" """Install bun onto the user's system.
Raises:
FileNotFoundError: If the required packages are not installed.
"""
# Bun is not supported on Windows. # Bun is not supported on Windows.
if platform.system() == "Windows": if platform.system() == "Windows":
console.log("Skipping bun installation on Windows.") console.log("Skipping bun installation on Windows.")
@ -423,6 +427,17 @@ def install_bun():
# Only install if bun is not already installed. # Only install if bun is not already installed.
if not os.path.exists(get_package_manager()): if not os.path.exists(get_package_manager()):
console.log("Installing bun...") console.log("Installing bun...")
# Check if curl is installed
curl_path = which("curl")
if curl_path is None:
raise FileNotFoundError("Pynecone requires curl to be installed.")
# Check if unzip is installed
unzip_path = which("unzip")
if unzip_path is None:
raise FileNotFoundError("Pynecone requires unzip to be installed.")
os.system(constants.INSTALL_BUN) os.system(constants.INSTALL_BUN)