Change local library path from {config_dir}/lib to {config_dir}/deps. (#1799)
Just on the off chance that someone who happens to run as root and also doesn't correctly parse "just remove config /lib and restart".
This commit is contained in:
parent
4857117dda
commit
241735c924
4 changed files with 12 additions and 6 deletions
|
@ -31,7 +31,7 @@ def validate_python():
|
|||
def ensure_config_path(config_dir):
|
||||
"""Validate the configuration directory."""
|
||||
import homeassistant.config as config_util
|
||||
lib_dir = os.path.join(config_dir, 'lib')
|
||||
lib_dir = os.path.join(config_dir, 'deps')
|
||||
|
||||
# Test if configuration directory exists
|
||||
if not os.path.isdir(config_dir):
|
||||
|
|
|
@ -65,7 +65,7 @@ def _handle_requirements(hass, component, name):
|
|||
return True
|
||||
|
||||
for req in component.REQUIREMENTS:
|
||||
if not pkg_util.install_package(req, target=hass.config.path('lib')):
|
||||
if not pkg_util.install_package(req, target=hass.config.path('deps')):
|
||||
_LOGGER.error('Not initializing %s because could not install '
|
||||
'dependency %s', name, req)
|
||||
return False
|
||||
|
@ -211,7 +211,7 @@ def prepare_setup_platform(hass, config, domain, platform_name):
|
|||
|
||||
def mount_local_lib_path(config_dir):
|
||||
"""Add local library to Python Path."""
|
||||
sys.path.insert(0, os.path.join(config_dir, 'lib'))
|
||||
sys.path.insert(0, os.path.join(config_dir, 'deps'))
|
||||
|
||||
|
||||
# pylint: disable=too-many-branches, too-many-statements, too-many-arguments
|
||||
|
@ -372,10 +372,16 @@ def process_ha_config_upgrade(hass):
|
|||
_LOGGER.info('Upgrading config directory from %s to %s', conf_version,
|
||||
__version__)
|
||||
|
||||
# This was where dependencies were installed before v0.18
|
||||
# Probably should keep this around until ~v0.20.
|
||||
lib_path = hass.config.path('lib')
|
||||
if os.path.isdir(lib_path):
|
||||
shutil.rmtree(lib_path)
|
||||
|
||||
lib_path = hass.config.path('deps')
|
||||
if os.path.isdir(lib_path):
|
||||
shutil.rmtree(lib_path)
|
||||
|
||||
with open(version_path, 'wt') as outp:
|
||||
outp.write(__version__)
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ class TestBootstrap:
|
|||
"""Test removal of library on upgrade."""
|
||||
with tempfile.TemporaryDirectory() as config_dir:
|
||||
version_path = os.path.join(config_dir, '.HA_VERSION')
|
||||
lib_dir = os.path.join(config_dir, 'lib')
|
||||
lib_dir = os.path.join(config_dir, 'deps')
|
||||
check_file = os.path.join(lib_dir, 'check')
|
||||
|
||||
with open(version_path, 'wt') as outp:
|
||||
|
@ -79,7 +79,7 @@ class TestBootstrap:
|
|||
"""Test removal of library with no upgrade."""
|
||||
with tempfile.TemporaryDirectory() as config_dir:
|
||||
version_path = os.path.join(config_dir, '.HA_VERSION')
|
||||
lib_dir = os.path.join(config_dir, 'lib')
|
||||
lib_dir = os.path.join(config_dir, 'deps')
|
||||
check_file = os.path.join(lib_dir, 'check')
|
||||
|
||||
with open(version_path, 'wt') as outp:
|
||||
|
|
|
@ -21,7 +21,7 @@ class TestPackageUtil(unittest.TestCase):
|
|||
def setUp(self):
|
||||
"""Create local library for testing."""
|
||||
self.tmp_dir = tempfile.TemporaryDirectory()
|
||||
self.lib_dir = os.path.join(self.tmp_dir.name, 'lib')
|
||||
self.lib_dir = os.path.join(self.tmp_dir.name, 'deps')
|
||||
|
||||
def tearDown(self):
|
||||
"""Stop everything that was started."""
|
||||
|
|
Loading…
Add table
Reference in a new issue