From e49b970665a8d798deab86cc7c836830e9984113 Mon Sep 17 00:00:00 2001
From: Paulus Schoutsen <paulus@paulusschoutsen.nl>
Date: Fri, 4 Aug 2017 23:06:10 -0700
Subject: [PATCH] Block dependencies that depend on enum34 (#8698)

* 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
---
 Dockerfile                                   |  3 +--
 homeassistant/components/light/yeelight.py   |  2 +-
 homeassistant/components/sensor/skybeacon.py |  7 ++++++-
 homeassistant/package_constraints.txt        |  3 +++
 requirements_all.txt                         |  5 +----
 script/gen_requirements_all.py               | 12 ++++++++----
 tox.ini                                      |  2 ++
 virtualization/Docker/Dockerfile.dev         |  3 +--
 8 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index a877f154037..f0d5accdf3d 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -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 . .
diff --git a/homeassistant/components/light/yeelight.py b/homeassistant/components/light/yeelight.py
index 301a3977543..e286bf330a1 100644
--- a/homeassistant/components/light/yeelight.py
+++ b/homeassistant/components/light/yeelight.py
@@ -22,7 +22,7 @@ from homeassistant.components.light import (
     Light, PLATFORM_SCHEMA)
 import homeassistant.helpers.config_validation as cv
 
-REQUIREMENTS = ['yeelight==0.3.0']
+REQUIREMENTS = ['yeelight==0.3.2']
 
 _LOGGER = logging.getLogger(__name__)
 
diff --git a/homeassistant/components/sensor/skybeacon.py b/homeassistant/components/sensor/skybeacon.py
index 0e8e2c6d2e9..3c14625202e 100644
--- a/homeassistant/components/sensor/skybeacon.py
+++ b/homeassistant/components/sensor/skybeacon.py
@@ -16,7 +16,7 @@ from homeassistant.components.sensor import PLATFORM_SCHEMA
 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__)
 
@@ -39,6 +39,10 @@ CONNECT_TIMEOUT = 30
 # 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...")
@@ -136,6 +140,7 @@ class Monitor(threading.Thread):
 
     def run(self):
         """Thread that keeps connection alive."""
+        # pylint: disable=import-error
         import pygatt
         from pygatt.backends import Characteristic
         from pygatt.exceptions import (
diff --git a/homeassistant/package_constraints.txt b/homeassistant/package_constraints.txt
index 63fcdc351eb..6d5fb25e514 100644
--- a/homeassistant/package_constraints.txt
+++ b/homeassistant/package_constraints.txt
@@ -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
diff --git a/requirements_all.txt b/requirements_all.txt
index ec5829c1e66..26d1d4a19ac 100644
--- a/requirements_all.txt
+++ b/requirements_all.txt
@@ -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
 
@@ -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
diff --git a/script/gen_requirements_all.py b/script/gen_requirements_all.py
index 7e2f1d99f2a..ba7a49cc7c0 100755
--- a/script/gen_requirements_all.py
+++ b/script/gen_requirements_all.py
@@ -88,6 +88,10 @@ URL_PIN = ('https://home-assistant.io/developers/code_review_platform/'
 
 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):
@@ -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():
diff --git a/tox.ini b/tox.ini
index aede0246209..e3063af8f40 100644
--- a/tox.ini
+++ b/tox.ini
@@ -15,6 +15,7 @@ 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
@@ -22,6 +23,7 @@ ignore_errors = True
 deps =
      -r{toxinidir}/requirements_all.txt
      -r{toxinidir}/requirements_test.txt
+     -c{toxinidir}/homeassistant/package_constraints.txt
 commands =
      flake8
      pylint homeassistant
diff --git a/virtualization/Docker/Dockerfile.dev b/virtualization/Docker/Dockerfile.dev
index c92294ccd11..ca75fde0411 100644
--- a/virtualization/Docker/Dockerfile.dev
+++ b/virtualization/Docker/Dockerfile.dev
@@ -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
 
-- 
GitLab