mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
commit
25d2df5689
@ -20,7 +20,7 @@ from homeassistant.const import (
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
REQUIREMENTS = ['pychromecast==0.8.0']
|
||||
REQUIREMENTS = ['pychromecast==0.8.1']
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -2,11 +2,12 @@
|
||||
"""Constants used by Home Assistant components."""
|
||||
MAJOR_VERSION = 0
|
||||
MINOR_VERSION = 40
|
||||
PATCH_VERSION = '1'
|
||||
PATCH_VERSION = '2'
|
||||
__short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION)
|
||||
__version__ = '{}.{}'.format(__short_version__, PATCH_VERSION)
|
||||
REQUIRED_PYTHON_VER = (3, 4, 2)
|
||||
REQUIRED_PYTHON_VER_WIN = (3, 5, 2)
|
||||
CONSTRAINT_FILE = 'package_constraints.txt'
|
||||
|
||||
PROJECT_NAME = 'Home Assistant'
|
||||
PROJECT_PACKAGE_NAME = 'homeassistant'
|
||||
|
9
homeassistant/package_constraints.txt
Normal file
9
homeassistant/package_constraints.txt
Normal 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
|
@ -2,6 +2,7 @@
|
||||
import asyncio
|
||||
import logging
|
||||
import logging.handlers
|
||||
import os
|
||||
|
||||
from types import ModuleType
|
||||
from typing import Optional, Dict
|
||||
@ -12,7 +13,8 @@ import homeassistant.core as core
|
||||
import homeassistant.loader as loader
|
||||
import homeassistant.util.package as pkg_util
|
||||
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__)
|
||||
|
||||
@ -74,7 +76,10 @@ def _async_process_requirements(hass: core.HomeAssistant, name: str,
|
||||
|
||||
def pip_install(mod):
|
||||
"""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):
|
||||
for req in requirements:
|
||||
|
@ -15,7 +15,8 @@ INSTALL_LOCK = threading.Lock()
|
||||
|
||||
|
||||
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.
|
||||
|
||||
Return boolean if install successful.
|
||||
@ -32,6 +33,9 @@ def install_package(package: str, upgrade: bool=True,
|
||||
if target:
|
||||
args += ['--target', os.path.abspath(target)]
|
||||
|
||||
if constraints is not None:
|
||||
args += ['--constraint', constraints]
|
||||
|
||||
try:
|
||||
return subprocess.call(args) == 0
|
||||
except subprocess.SubprocessError:
|
||||
|
@ -2,7 +2,7 @@
|
||||
requests>=2,<3
|
||||
pyyaml>=3.11,<4
|
||||
pytz>=2016.10
|
||||
pip>=7.0.0
|
||||
pip>=7.1.0
|
||||
jinja2>=2.9.5
|
||||
voluptuous==0.9.3
|
||||
typing>=3,<4
|
||||
@ -467,7 +467,7 @@ pybbox==0.0.5-alpha
|
||||
# pybluez==0.22
|
||||
|
||||
# homeassistant.components.media_player.cast
|
||||
pychromecast==0.8.0
|
||||
pychromecast==0.8.1
|
||||
|
||||
# homeassistant.components.media_player.cmus
|
||||
pycmus==0.1.0
|
||||
|
@ -34,6 +34,10 @@ URL_PIN = ('https://home-assistant.io/developers/code_review_platform/'
|
||||
'#1-requirements')
|
||||
|
||||
|
||||
CONSTRAINT_PATH = os.path.join(os.path.dirname(__file__),
|
||||
'../homeassistant/package_constraints.txt')
|
||||
|
||||
|
||||
def explore_module(package, explore_children):
|
||||
"""Explore the modules."""
|
||||
module = importlib.import_module(package)
|
||||
@ -118,18 +122,35 @@ def gather_modules():
|
||||
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."""
|
||||
with open('requirements_all.txt', 'w+') as req_file:
|
||||
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."""
|
||||
with open('requirements_all.txt', 'r') as 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():
|
||||
"""Main section of the script."""
|
||||
if not os.path.isfile('requirements_all.txt'):
|
||||
@ -141,15 +162,25 @@ def main():
|
||||
if data is None:
|
||||
sys.exit(1)
|
||||
|
||||
constraints = gather_constraints()
|
||||
|
||||
if sys.argv[-1] == 'validate':
|
||||
if validate_file(data):
|
||||
sys.exit(0)
|
||||
if not validate_requirements_file(data):
|
||||
print("******* ERROR")
|
||||
print("requirements_all.txt is not up to date")
|
||||
print("Please run script/gen_requirements_all.py")
|
||||
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__':
|
||||
|
Loading…
x
Reference in New Issue
Block a user