from pathlib import Path as PI_PATH import subprocess as PI_SUBPROCESS import sys as PI_SYS import os as PI_OS def FC_INSTALL_REQUIREMENTS(*,ZVFCI_ST_02PROG_FOLDER): ZV_OB_02PROG_FOLDER = PI_PATH(ZVFCI_ST_02PROG_FOLDER) # 1/ Find requirements.txt ZV_LI_OB_PATH_REQ_FILES = list( ZV_OB_02PROG_FOLDER.rglob('requirements.txt') ) if not ZV_LI_OB_PATH_REQ_FILES: raise FileNotFoundError(f'No requirements.txt file found under {ZV_OB_02PROG_FOLDER}') ZV_OB_PATH_REQUIREMENTS_FILE = ZV_LI_OB_PATH_REQ_FILES[0] # 2/ Install python requirements PI_SUBPROCESS.run( [ PI_SYS.executable, '-m', 'pip', 'install', '-r', str(ZV_OB_PATH_REQUIREMENTS_FILE) ], check=True ) if PI_OS.name != 'nt': try: PI_SUBPROCESS.run( ['apt-get', 'install', '-y', 'antiword'], check=True ) except Exception as ZV_OB_ERROR: raise RuntimeError('antiword was not installed') from ZV_OB_ERROR else: print('Skipping apt-get antiword install on Windows.')