mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-29 17:47:14 +02:00
Check zeroconf installation before adding to setuptools
This commit is contained in:
@ -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"
|
||||
|
@ -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):
|
||||
|
||||
|
19
setup.py
19
setup.py
@ -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__,
|
||||
|
Reference in New Issue
Block a user