Check zeroconf installation before adding to setuptools

This commit is contained in:
Ivan Kravets
2017-12-19 12:41:56 +02:00
parent 9f2875fcd7
commit c6abdf8206
3 changed files with 28 additions and 3 deletions

View File

@ -227,3 +227,10 @@ class CygwinEnvDetected(PlatformioException):
MESSAGE = "PlatformIO does not work within Cygwin environment. "\
"Use native Terminal instead."
class ZeroconfIsNotInstalled(PlatformioException):
MESSAGE = "Python multicast DNS service discovery library has not been "\
"installed automatically. Please open terminal and run \n"\
"> pip install zeroconf"

View File

@ -32,7 +32,6 @@ from time import sleep, time
import click
import requests
import zeroconf
from platformio import __apiurl__, __version__, exception
@ -493,6 +492,10 @@ get_logicaldisks = lambda: [{
def get_mdns_services():
try:
import zeroconf
except ImportError:
raise exception.ZeroconfIsNotInstalled()
class mDNSListener(object):

View File

@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import subprocess
import sys
from os.path import normpath
from setuptools import find_packages, setup
from platformio import (__author__, __description__, __email__, __license__,
@ -25,9 +28,21 @@ install_requires = [
"lockfile>=0.9.1,<0.13",
"pyserial>=3,<4,!=3.3",
"requests>=2.4.0,<3",
"semantic_version>=2.5.0,<3",
"zeroconf<=0.19.1"
"semantic_version>=2.5.0,<3"
]
zeroconf_requirement = "zeroconf<=0.19.1"
try:
import zeroconf # pylint: disable=unused-import
except ImportError:
try:
subprocess.check_call([
normpath(sys.executable), "-m", "pip", "install",
zeroconf_requirement
])
install_requires.append(zeroconf_requirement)
except: # pylint: disable=bare-except
pass
setup(
name=__title__,