mirror of
https://github.com/morpheus65535/bazarr.git
synced 2025-01-06 06:52:07 +08:00
Added virtualenv detection to better deal with requirements installation.
This commit is contained in:
parent
aca99415b8
commit
d1f86a3cbf
1 changed files with 14 additions and 4 deletions
|
@ -42,6 +42,13 @@ if not os.path.exists(os.path.join(args.config_dir, 'cache')):
|
||||||
configure_logging(settings.general.getboolean('debug') or args.debug)
|
configure_logging(settings.general.getboolean('debug') or args.debug)
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
|
||||||
|
def is_virtualenv():
|
||||||
|
# return True if Bazarr have been start from within a virtualenv or venv
|
||||||
|
base_prefix = getattr(sys, "base_prefix", None) or getattr(sys, "real_prefix", None) or sys.prefix
|
||||||
|
return base_prefix != sys.prefix
|
||||||
|
|
||||||
|
|
||||||
# deploy requirements.txt
|
# deploy requirements.txt
|
||||||
if not args.no_update:
|
if not args.no_update:
|
||||||
try:
|
try:
|
||||||
|
@ -57,10 +64,13 @@ if not args.no_update:
|
||||||
else:
|
else:
|
||||||
logging.info('BAZARR installing requirements...')
|
logging.info('BAZARR installing requirements...')
|
||||||
try:
|
try:
|
||||||
subprocess.check_output([sys.executable, '-m', 'pip', 'install', '--user', '-qq',
|
pip_command = [sys.executable, '-m', 'pip', 'install', '-qq', '--disable-pip-version-check',
|
||||||
'--disable-pip-version-check', '--no-color', '-r',
|
'--no-color', '-r', os.path.join(os.path.dirname(os.path.dirname(__file__)),
|
||||||
os.path.join(os.path.dirname(__file__), '..', 'requirements.txt')],
|
'requirements.txt')]
|
||||||
stderr=subprocess.STDOUT)
|
if not is_virtualenv():
|
||||||
|
# --user only make sense if not running under venv
|
||||||
|
pip_command.insert(4, '--user')
|
||||||
|
subprocess.check_output(pip_command, stderr=subprocess.STDOUT)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
logging.exception('BAZARR requirements.txt installation result: {}'.format(e.stdout))
|
logging.exception('BAZARR requirements.txt installation result: {}'.format(e.stdout))
|
||||||
os._exit(1)
|
os._exit(1)
|
||||||
|
|
Loading…
Reference in a new issue