generate_zulip_bots_static_files: Lazy import cairosvg.

Importing cairosvg in fails in production, because `libgtk-3-dev` is not
available. This commit moves the import for `cairosvg` into the function
where it is used. This code will soon be moved into a separate script that
will not be run on production.
This commit is contained in:
Puneeth Chaganti 2020-04-20 21:17:44 +05:30 committed by Tim Abbott
parent c8b0627ffe
commit e55d967f6e
1 changed files with 2 additions and 2 deletions

View File

@ -13,8 +13,6 @@ if ZULIP_PATH not in sys.path:
from scripts.lib.setup_path import setup_path
setup_path()
import cairosvg
from zulip_bots.lib import get_bots_directory_path
def generate_zulip_bots_static_files() -> None:
@ -47,6 +45,8 @@ def generate_zulip_bots_static_files() -> None:
copyfiles(docs)
def create_png_from_svg(svg_path: str, destination_dir: Optional[str]=None) -> str:
import cairosvg
png_name = os.path.splitext(os.path.basename(svg_path))[0] + '.png'
if destination_dir is None:
destination_dir = tempfile.gettempdir()