Skip to content

Commit 331a4f3

Browse files
committed
setup: Avoid cyclic dependency during setup
If `serial` is not installed, then `pip install` will fail trying to import `serial`.
1 parent ec708f3 commit 331a4f3

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

pymycobot/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
from __future__ import absolute_import
2-
from pymycobot.mycobot import MyCobot
3-
from pymycobot.generate import MycobotCommandGenerater
4-
from pymycobot.genre import Angle, Coord
2+
import os
3+
if os.environ.get("_MYCOBOT_VERSION_ONLY") != "1":
4+
from pymycobot.mycobot import MyCobot
5+
from pymycobot.generate import MycobotCommandGenerater
6+
from pymycobot.genre import Angle, Coord
57

6-
__all__ = ["MyCobot", "MycobotCommandGenerater", "Angle", "Coord"]
8+
__all__ = ["MyCobot", "MycobotCommandGenerater", "Angle", "Coord"]
79

810
__version__ = "2.5.3"
911
__author__ = "Zachary zhang"

setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
import sys
23

34
PYTHON_VERSION = sys.version_info[:2]
@@ -6,6 +7,7 @@
67
sys.exit(1)
78

89
import setuptools
10+
os.environ["_MYCOBOT_VERSION_ONLY"] = "1"
911
import pymycobot
1012

1113
if PYTHON_VERSION == (2, 7):

0 commit comments

Comments
 (0)