Implemented comments from Paulus.

Revised main to use frontend and demo strings rather than importing
their domains.
Removed submodule validation.
Moved local library mounting to the bootstrap module and out of core.
Added requirements_all.txt for all dependencies.
Made core dependencies looser.
Small updates to setup.py.
pull/289/head
Ryan Kraus 2015-08-29 22:19:52 -04:00
parent 893ae15042
commit 0b6358e759
7 changed files with 155 additions and 35 deletions

View File

@ -3,7 +3,7 @@ language: python
python:
- "3.4"
install:
- pip install -r requirements.txt
- pip install -r requirements_all.txt
- pip install flake8 pylint coveralls
script:
- flake8 homeassistant --exclude bower_components,external

View File

@ -8,7 +8,6 @@ import importlib
from homeassistant import bootstrap
import homeassistant.config as config_util
from homeassistant.components import frontend, demo
def validate_python():
@ -30,17 +29,6 @@ def ensure_pip():
sys.exit()
def validate_git_submodules():
""" Validate the git submodules are cloned. """
try:
# pylint: disable=no-name-in-module, unused-variable
from homeassistant.external.noop import WORKING # noqa
except ImportError:
print("Repository submodules have not been initialized")
print("Please run: git submodule update --init --recursive")
sys.exit()
def ensure_config_path(config_dir):
""" Gets the path to the configuration file.
Creates one if it not exists. """
@ -49,11 +37,16 @@ def ensure_config_path(config_dir):
# Test if configuration directory exists
if not os.path.isdir(config_dir):
try:
os.mkdir(config_dir)
except OSError:
print(('Fatal Error: Unable to create specified configuration '
'directory {} ').format(config_dir))
if config_dir == config_util.get_default_config_dir():
try:
os.mkdir(config_dir)
except OSError:
print(('Fatal Error: Unable to create default configuration '
'directory {} ').format(config_dir))
sys.exit()
else:
print(('Fatal Error: Specified configuration directory does '
'not exist {} ').format(config_dir))
sys.exit()
# Test if library directory exists
@ -98,8 +91,6 @@ def main():
""" Starts Home Assistant. """
validate_python()
validate_git_submodules()
args = get_arguments()
config_dir = os.path.join(os.getcwd(), args.config)
@ -107,8 +98,8 @@ def main():
if args.demo_mode:
hass = bootstrap.from_config_dict({
frontend.DOMAIN: {},
demo.DOMAIN: {}
'frontend': {},
'demo': {}
}, config_dir=config_dir)
else:
hass = bootstrap.from_config_file(config_path)

View File

@ -144,6 +144,11 @@ def prepare_setup_platform(hass, config, domain, platform_name):
return platform
def mount_local_lib_path(config_dir):
""" Add local library to Python Path """
sys.path.insert(0, os.path.join(config_dir, 'lib'))
# pylint: disable=too-many-branches, too-many-statements
def from_config_dict(config, hass=None, config_dir=None):
"""
@ -154,8 +159,9 @@ def from_config_dict(config, hass=None, config_dir=None):
if hass is None:
hass = core.HomeAssistant()
if config_dir is not None:
hass.config.config_dir = os.path.abspath(config_dir)
hass.config.mount_local_path()
config_dir = os.path.abspath(config_dir)
hass.config.config_dir = config_dir
mount_local_lib_path(config_dir)
process_ha_core_config(hass, config.get(core.DOMAIN, {}))
@ -198,8 +204,9 @@ def from_config_file(config_path, hass=None):
hass = core.HomeAssistant()
# Set config dir to directory holding config file
hass.config.config_dir = os.path.abspath(os.path.dirname(config_path))
hass.config.mount_local_path()
config_dir = os.path.abspath(os.path.dirname(config_path))
hass.config.config_dir = config_dir
mount_local_lib_path(config_dir)
config_dict = config_util.load_config_file(config_path)

View File

@ -666,10 +666,6 @@ class Config(object):
# Directory that holds the configuration
self.config_dir = get_default_config_dir()
def mount_local_path(self):
""" Add local library to Python Path """
sys.path.insert(0, self.path('lib'))
def path(self, *path):
""" Returns path to the file within the config dir. """
return os.path.join(self.config_dir, *path)

View File

@ -1,3 +1,3 @@
requests==2.7.0
pyyaml==3.11
pytz==2015.4
requests>=2,<3
pyyaml>=3.11,<4
pytz>=2015.4

120
requirements_all.txt Normal file
View File

@ -0,0 +1,120 @@
# Required for Home Assistant core
requests>=2,<3
pyyaml>=3.11,<4
pytz>=2015.4
# Optional, needed for specific components
# Sun (sun)
astral==0.8.1
# Philips Hue library (lights.hue)
phue==0.8
# Limitlessled/Easybulb/Milight library (lights.limitlessled)
ledcontroller==1.0.7
# Chromecast bindings (media_player.cast)
pychromecast==0.6.10
# Keyboard (keyboard)
pyuserinput==0.1.9
# Tellstick bindings (*.tellstick)
tellcore-py==1.0.4
# Nmap bindings (device_tracker.nmap)
python-libnmap==0.6.3
# PushBullet bindings (notify.pushbullet)
pushbullet.py==0.7.1
# Nest Thermostat bindings (thermostat.nest)
python-nest==2.4.0
# Z-Wave (*.zwave)
pydispatcher==2.0.5
# ISY994 bindings (*.isy994)
PyISY==1.0.5
# PSutil (sensor.systemmonitor)
psutil==3.0.0
# Pushover bindings (notify.pushover)
python-pushover==0.2
# Transmission Torrent Client (*.transmission)
transmissionrpc==0.11
# OpenWeatherMap Web API (sensor.openweathermap)
pyowm==2.2.1
# XMPP Bindings (notify.xmpp)
sleekxmpp==1.3.1
dnspython3==1.12.0
# Blockchain (sensor.bitcoin)
blockchain==1.1.2
# MPD Bindings (media_player.mpd)
python-mpd2==0.5.4
# Hikvision (switch.hikvisioncam)
hikvision==0.4
# console log coloring
colorlog==2.6.0
# JSON-RPC interface (media_player.kodi)
jsonrpc-requests==0.1
# Forecast.io Bindings (sensor.forecast)
python-forecastio==1.3.3
# Firmata Bindings (*.arduino)
PyMata==2.07a
# Rfxtrx sensor (sensor.rfxtrx)
https://github.com/Danielhiversen/pyRFXtrx/archive/ec7a1aaddf8270db6e5da1c13d58c1547effd7cf.zip
# Mysensors
https://github.com/theolind/pymysensors/archive/35b87d880147a34107da0d40cb815d75e6cb4af7.zip
# Netgear (device_tracker.netgear)
pynetgear==0.3
# Netdisco (discovery)
netdisco==0.3
# Wemo (switch.wemo)
pywemo==0.2
# Wink (*.wink)
https://github.com/balloob/python-wink/archive/c2b700e8ca866159566ecf5e644d9c297f69f257.zip
# Slack notifier (notify.slack)
slacker==0.6.8
# Temper sensors (sensor.temper)
https://github.com/rkabadi/temper-python/archive/3dbdaf2d87b8db9a3cd6e5585fc704537dd2d09b.zip
# PyEdimax
https://github.com/rkabadi/pyedimax/archive/365301ce3ff26129a7910c501ead09ea625f3700.zip
# RPI-GPIO platform (*.rpi_gpio)
# Uncomment for Raspberry Pi
# RPi.GPIO ==0.5.11
# Adafruit temperature/humidity sensor
# uncomment on a Raspberry Pi / Beaglebone
# http://github.com/mala-zaba/Adafruit_Python_DHT/archive/4101340de8d2457dd194bca1e8d11cbfc237e919.zip
# PAHO MQTT Binding (mqtt)
paho-mqtt==1.1
# PyModbus (modbus)
https://github.com/bashwork/pymodbus/archive/d7fc4f1cc975631e0a9011390e8017f64b612661.zip
# Verisure (verisure)
https://github.com/persandstrom/python-verisure/archive/9873c4527f01b1ba1f72ae60f7f35854390d59be.zip

View File

@ -6,6 +6,8 @@ PACKAGE_NAME = 'homeassistant'
HERE = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(HERE, PACKAGE_NAME, 'const.py')) as fp:
VERSION = re.search("__version__ = ['\"]([^']+)['\"]\n", fp.read()).group(1)
DOWNLOAD_URL = \
'https://github.com/balloob/home-assistant/tarball/{}'.format(VERSION)
PACKAGES = find_packages() + \
['homeassistant.external', 'homeassistant.external.noop',
@ -16,12 +18,15 @@ PACKAGE_DATA = \
'homeassistant.components.frontend.www_static': ['*.*'],
'homeassistant.components.frontend.www_static.images': ['*.*']}
REQUIRES = \
[line.strip() for line in open('requirements.txt', 'r')]
setup(
name=PACKAGE_NAME,
version=VERSION,
license='MIT License',
url='https://home-assistant.io/',
download_url='https://github.com/automicus/pyisy/tarball/0.7.0',
download_url=DOWNLOAD_URL,
author='Paulus Schoutsen',
author_email='paulus@paulusschoutsen.nl',
description='Open-source home automation platform running on Python 3.',
@ -30,7 +35,7 @@ setup(
package_data=PACKAGE_DATA,
zip_safe=False,
platforms='any',
install_requires=['requests==2.7.0', 'pyyaml==3.11', 'pytz==2015.4'],
install_requires=REQUIRES,
keywords=['home', 'automation'],
entry_points={
'console_scripts': [
@ -39,6 +44,7 @@ setup(
},
classifiers=[
'Intended Audience :: End Users/Desktop',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python :: 3.4',