Merge pull request #6740 from home-assistant/release-0-40-2

0.40.2
This commit is contained in:
Paulus Schoutsen 2017-03-22 09:31:21 -07:00 committed by GitHub
commit 25d2df5689
8 changed files with 68 additions and 18 deletions

View File

@ -20,7 +20,7 @@ from homeassistant.const import (
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
REQUIREMENTS = ['pychromecast==0.8.0'] REQUIREMENTS = ['pychromecast==0.8.1']
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)

View File

@ -2,11 +2,12 @@
"""Constants used by Home Assistant components.""" """Constants used by Home Assistant components."""
MAJOR_VERSION = 0 MAJOR_VERSION = 0
MINOR_VERSION = 40 MINOR_VERSION = 40
PATCH_VERSION = '1' PATCH_VERSION = '2'
__short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION) __short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION)
__version__ = '{}.{}'.format(__short_version__, PATCH_VERSION) __version__ = '{}.{}'.format(__short_version__, PATCH_VERSION)
REQUIRED_PYTHON_VER = (3, 4, 2) REQUIRED_PYTHON_VER = (3, 4, 2)
REQUIRED_PYTHON_VER_WIN = (3, 5, 2) REQUIRED_PYTHON_VER_WIN = (3, 5, 2)
CONSTRAINT_FILE = 'package_constraints.txt'
PROJECT_NAME = 'Home Assistant' PROJECT_NAME = 'Home Assistant'
PROJECT_PACKAGE_NAME = 'homeassistant' PROJECT_PACKAGE_NAME = 'homeassistant'

View File

@ -0,0 +1,9 @@
requests>=2,<3
pyyaml>=3.11,<4
pytz>=2016.10
pip>=7.1.0
jinja2>=2.9.5
voluptuous==0.9.3
typing>=3,<4
aiohttp==1.3.3
async_timeout==1.1.0

View File

@ -2,6 +2,7 @@
import asyncio import asyncio
import logging import logging
import logging.handlers import logging.handlers
import os
from types import ModuleType from types import ModuleType
from typing import Optional, Dict from typing import Optional, Dict
@ -12,7 +13,8 @@ import homeassistant.core as core
import homeassistant.loader as loader import homeassistant.loader as loader
import homeassistant.util.package as pkg_util import homeassistant.util.package as pkg_util
from homeassistant.util.async import run_coroutine_threadsafe from homeassistant.util.async import run_coroutine_threadsafe
from homeassistant.const import EVENT_COMPONENT_LOADED, PLATFORM_FORMAT from homeassistant.const import (
EVENT_COMPONENT_LOADED, PLATFORM_FORMAT, CONSTRAINT_FILE)
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -74,7 +76,10 @@ def _async_process_requirements(hass: core.HomeAssistant, name: str,
def pip_install(mod): def pip_install(mod):
"""Install packages.""" """Install packages."""
return pkg_util.install_package(mod, target=hass.config.path('deps')) return pkg_util.install_package(
mod, target=hass.config.path('deps'),
constraints=os.path.join(os.path.dirname(__file__),
CONSTRAINT_FILE))
with (yield from pip_lock): with (yield from pip_lock):
for req in requirements: for req in requirements:

View File

@ -15,7 +15,8 @@ INSTALL_LOCK = threading.Lock()
def install_package(package: str, upgrade: bool=True, def install_package(package: str, upgrade: bool=True,
target: Optional[str]=None) -> bool: target: Optional[str]=None,
constraints: Optional[str]=None) -> bool:
"""Install a package on PyPi. Accepts pip compatible package strings. """Install a package on PyPi. Accepts pip compatible package strings.
Return boolean if install successful. Return boolean if install successful.
@ -32,6 +33,9 @@ def install_package(package: str, upgrade: bool=True,
if target: if target:
args += ['--target', os.path.abspath(target)] args += ['--target', os.path.abspath(target)]
if constraints is not None:
args += ['--constraint', constraints]
try: try:
return subprocess.call(args) == 0 return subprocess.call(args) == 0
except subprocess.SubprocessError: except subprocess.SubprocessError:

View File

@ -2,7 +2,7 @@
requests>=2,<3 requests>=2,<3
pyyaml>=3.11,<4 pyyaml>=3.11,<4
pytz>=2016.10 pytz>=2016.10
pip>=7.0.0 pip>=7.1.0
jinja2>=2.9.5 jinja2>=2.9.5
voluptuous==0.9.3 voluptuous==0.9.3
typing>=3,<4 typing>=3,<4
@ -467,7 +467,7 @@ pybbox==0.0.5-alpha
# pybluez==0.22 # pybluez==0.22
# homeassistant.components.media_player.cast # homeassistant.components.media_player.cast
pychromecast==0.8.0 pychromecast==0.8.1
# homeassistant.components.media_player.cmus # homeassistant.components.media_player.cmus
pycmus==0.1.0 pycmus==0.1.0

View File

@ -34,6 +34,10 @@ URL_PIN = ('https://home-assistant.io/developers/code_review_platform/'
'#1-requirements') '#1-requirements')
CONSTRAINT_PATH = os.path.join(os.path.dirname(__file__),
'../homeassistant/package_constraints.txt')
def explore_module(package, explore_children): def explore_module(package, explore_children):
"""Explore the modules.""" """Explore the modules."""
module = importlib.import_module(package) module = importlib.import_module(package)
@ -118,18 +122,35 @@ def gather_modules():
return ''.join(output) return ''.join(output)
def write_file(data): def gather_constraints():
"""Construct output for constraint file."""
return '\n'.join(core_requirements() + [''])
def write_requirements_file(data):
"""Write the modules to the requirements_all.txt.""" """Write the modules to the requirements_all.txt."""
with open('requirements_all.txt', 'w+') as req_file: with open('requirements_all.txt', 'w+') as req_file:
req_file.write(data) req_file.write(data)
def validate_file(data): def write_constraints_file(data):
"""Write constraints to a file."""
with open(CONSTRAINT_PATH, 'w+', newline="\n") as req_file:
req_file.write(data)
def validate_requirements_file(data):
"""Validate if requirements_all.txt is up to date.""" """Validate if requirements_all.txt is up to date."""
with open('requirements_all.txt', 'r') as req_file: with open('requirements_all.txt', 'r') as req_file:
return data == ''.join(req_file) return data == ''.join(req_file)
def validate_constraints_file(data):
"""Validate if constraints is up to date."""
with open(CONSTRAINT_PATH, 'r') as req_file:
return data == ''.join(req_file)
def main(): def main():
"""Main section of the script.""" """Main section of the script."""
if not os.path.isfile('requirements_all.txt'): if not os.path.isfile('requirements_all.txt'):
@ -141,15 +162,25 @@ def main():
if data is None: if data is None:
sys.exit(1) sys.exit(1)
constraints = gather_constraints()
if sys.argv[-1] == 'validate': if sys.argv[-1] == 'validate':
if validate_file(data): if not validate_requirements_file(data):
sys.exit(0)
print("******* ERROR") print("******* ERROR")
print("requirements_all.txt is not up to date") print("requirements_all.txt is not up to date")
print("Please run script/gen_requirements_all.py") print("Please run script/gen_requirements_all.py")
sys.exit(1) sys.exit(1)
write_file(data) if not validate_constraints_file(constraints):
print("******* ERROR")
print("home-assistant/package_constraints.txt is not up to date")
print("Please run script/gen_requirements_all.py")
sys.exit(1)
sys.exit(0)
write_requirements_file(data)
write_constraints_file(constraints)
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -18,7 +18,7 @@ REQUIRES = [
'requests>=2,<3', 'requests>=2,<3',
'pyyaml>=3.11,<4', 'pyyaml>=3.11,<4',
'pytz>=2016.10', 'pytz>=2016.10',
'pip>=7.0.0', 'pip>=7.1.0',
'jinja2>=2.9.5', 'jinja2>=2.9.5',
'voluptuous==0.9.3', 'voluptuous==0.9.3',
'typing>=3,<4', 'typing>=3,<4',