Cleaned up default config directory determination. Made bootstrap creators for HA always set config directory. Made bootstrap creators set the local library in the Python Path. Moved all exceptions to their own file to make imports easier. Moved default configuration directory be in the users’ profile. Moved pip installs to be done to a lib folder in the config directory. Reduced requirements.txt to only the barebones reqs.
26 lines
799 B
Python
26 lines
799 B
Python
"""Helpers to install PyPi packages."""
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
|
|
from . import environment as env
|
|
|
|
# If we are not in a virtual environment, install in user space
|
|
INSTALL_USER = not env.is_virtual()
|
|
|
|
|
|
def install_package(package, upgrade=False, target=None):
|
|
"""Install a package on PyPi. Accepts pip compatible package strings.
|
|
Return boolean if install successfull."""
|
|
# Not using 'import pip; pip.main([])' because it breaks the logger
|
|
args = [sys.executable, '-m', 'pip', 'install', '--quiet',
|
|
'--isolated', '-I', package]
|
|
if upgrade:
|
|
args.append('--upgrade')
|
|
if target:
|
|
args += ['--target', os.path.abspath(target)]
|
|
try:
|
|
return 0 == subprocess.call(args)
|
|
except subprocess.SubprocessError:
|
|
return False
|