Skip to content

Commit

Permalink
Block dependencies that depend on enum34 (home-assistant#8698)
Browse files Browse the repository at this point in the history
* Block dependencies that depend on enum34

* Remove uninstalling enum34

* Update validation script

* Add constraints to tox.ini

* Upgrade yeelight to version that uses enum-compat

* Disable sensor.skybeacon

* Lint
  • Loading branch information
balloob authored Aug 5, 2017
1 parent a0530d8 commit e49b970
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 14 deletions.
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ COPY requirements_all.txt requirements_all.txt
# Uninstall enum34 because some depenndecies install it but breaks Python 3.4+.
# See PR #8103 for more info.
RUN pip3 install --no-cache-dir -r requirements_all.txt && \
pip3 install --no-cache-dir mysqlclient psycopg2 uvloop cchardet && \
pip3 uninstall -y enum34
pip3 install --no-cache-dir mysqlclient psycopg2 uvloop cchardet

# Copy source
COPY . .
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/light/yeelight.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
Light, PLATFORM_SCHEMA)
import homeassistant.helpers.config_validation as cv

REQUIREMENTS = ['yeelight==0.3.0']
REQUIREMENTS = ['yeelight==0.3.2']

_LOGGER = logging.getLogger(__name__)

Expand Down
7 changes: 6 additions & 1 deletion homeassistant/components/sensor/skybeacon.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from homeassistant.const import (
CONF_NAME, CONF_MAC, TEMP_CELSIUS, STATE_UNKNOWN, EVENT_HOMEASSISTANT_STOP)

REQUIREMENTS = ['pygatt==3.1.1']
# REQUIREMENTS = ['pygatt==3.1.1']

_LOGGER = logging.getLogger(__name__)

Expand All @@ -39,6 +39,10 @@
# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Set up the Skybeacon sensor."""
_LOGGER.warning("This platform has been disabled due to having a "
"requirement depending on enum34.")
return
# pylint: disable=unreachable
name = config.get(CONF_NAME)
mac = config.get(CONF_MAC)
_LOGGER.debug("Setting up...")
Expand Down Expand Up @@ -136,6 +140,7 @@ def __init__(self, hass, mac, name):

def run(self):
"""Thread that keeps connection alive."""
# pylint: disable=import-error
import pygatt
from pygatt.backends import Characteristic
from pygatt.exceptions import (
Expand Down
3 changes: 3 additions & 0 deletions homeassistant/package_constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ aiohttp==2.2.4
async_timeout==1.2.1
chardet==3.0.4
astral==1.4

# Breaks Python 3.6 and is not needed for our supported Pythons
enum34==1000000000.0.0
5 changes: 1 addition & 4 deletions requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -584,9 +584,6 @@ pyfoscam==1.2
# homeassistant.components.ifttt
pyfttt==0.3

# homeassistant.components.sensor.skybeacon
pygatt==3.1.1

# homeassistant.components.remote.harmony
pyharmony==1.0.16

Expand Down Expand Up @@ -983,7 +980,7 @@ yahoo-finance==1.4.0
yahooweather==0.8

# homeassistant.components.light.yeelight
yeelight==0.3.0
yeelight==0.3.2

# homeassistant.components.light.yeelightsunflower
yeelightsunflower==0.0.8
Expand Down
12 changes: 8 additions & 4 deletions script/gen_requirements_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@

CONSTRAINT_PATH = os.path.join(os.path.dirname(__file__),
'../homeassistant/package_constraints.txt')
CONSTRAINT_BASE = """
# Breaks Python 3.6 and is not needed for our supported Pythons
enum34==1000000000.0.0
"""


def explore_module(package, explore_children):
Expand Down Expand Up @@ -223,25 +227,25 @@ def write_test_requirements_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)
req_file.write(data + CONSTRAINT_BASE)


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)
return data == req_file.read()


def validate_requirements_test_file(data):
"""Validate if requirements_all.txt is up to date."""
with open('requirements_test_all.txt', 'r') as req_file:
return data == ''.join(req_file)
return data == req_file.read()


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)
return data + CONSTRAINT_BASE == req_file.read()


def main():
Expand Down
2 changes: 2 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ commands =
py.test --timeout=30 --duration=10 --cov --cov-report= {posargs}
deps =
-r{toxinidir}/requirements_test_all.txt
-c{toxinidir}/homeassistant/package_constraints.txt

[testenv:lint]
basepython = python3
ignore_errors = True
deps =
-r{toxinidir}/requirements_all.txt
-r{toxinidir}/requirements_test.txt
-c{toxinidir}/homeassistant/package_constraints.txt
commands =
flake8
pylint homeassistant
Expand Down
3 changes: 1 addition & 2 deletions virtualization/Docker/Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ COPY requirements_all.txt requirements_all.txt
# Uninstall enum34 because some depenndecies install it but breaks Python 3.4+.
# See PR #8103 for more info.
RUN pip3 install --no-cache-dir -r requirements_all.txt && \
pip3 install --no-cache-dir mysqlclient psycopg2 uvloop cchardet && \
pip3 uninstall -y enum34
pip3 install --no-cache-dir mysqlclient psycopg2 uvloop cchardet

# BEGIN: Development additions

Expand Down

0 comments on commit e49b970

Please sign in to comment.