浏览代码

feat: 修复setup的问题

SongZihuan 3 年之前
父节点
当前提交
b8acd295c7
共有 3 个文件被更改,包括 12 次插入16 次删除
  1. 4 13
      conf/matplotlib_conf.py
  2. 4 2
      init.py
  3. 4 1
      setup.py

+ 4 - 13
conf/matplotlib_conf.py

@@ -1,18 +1,9 @@
+from .font.noto import noto_font
+
+
 class ConfigMatplotlibRelease:
 class ConfigMatplotlibRelease:
     """ Matplotlib 相关配置 """
     """ Matplotlib 相关配置 """
-    matplotlib_font = "SimHei"
-    matplotlib_font_dict = dict(family=matplotlib_font)
+    matplotlib_font_dict = dict(fname=noto_font)
 
 
 
 
 ConfigMatplotlib = ConfigMatplotlibRelease
 ConfigMatplotlib = ConfigMatplotlibRelease
-
-try:
-    import matplotlib.font_manager as fm
-except ImportError:
-    pass
-else:
-    if "SimHei" not in [f.name for f in fm.fontManager.ttflist]:
-        print("请安装SimHei字体")
-        exit(1)
-    fm.rcParams["font.sans-serif"] = [ConfigMatplotlib.matplotlib_font]  # 配置中文字体
-    fm.rcParams["axes.unicode_minus"] = False  # 解决负号变豆腐块

+ 4 - 2
init.py

@@ -71,11 +71,13 @@ from conf import Config
 mysql_url = Config.mysql_url
 mysql_url = Config.mysql_url
 mysql_name = Config.mysql_name
 mysql_name = Config.mysql_name
 mysql_passwd = Config.mysql_passwd
 mysql_passwd = Config.mysql_passwd
+mysql_port = Config.mysql_port
 
 
 try:
 try:
-    sql = pymysql.connect(user=mysql_name, password=mysql_passwd, host=mysql_url)
+    print(f"MySQL -h {mysql_url} -u {mysql_name} -P {mysql_port} -p{mysql_passwd}")
+    sql = pymysql.connect(user=mysql_name, password=mysql_passwd, host=mysql_url, port=mysql_port)
     cursor = sql.cursor()
     cursor = sql.cursor()
-except pymysql.err:
+except pymysql.err.Error:
     print("请提供正确的MySQL信息", file=sys.stderr)
     print("请提供正确的MySQL信息", file=sys.stderr)
     sys.exit(1)
     sys.exit(1)
 
 

+ 4 - 1
setup.py

@@ -137,7 +137,10 @@ def install_venv():
     if not os.path.exists(venv):
     if not os.path.exists(venv):
         print(f"执行: {sys.executable} -m venv {venv}")
         print(f"执行: {sys.executable} -m venv {venv}")
         os.system(f"{sys.executable} -m venv {venv}")
         os.system(f"{sys.executable} -m venv {venv}")
-    suffix = os.path.splitext(sys.executable)[-1]
+    if os.name == 'nt':
+        suffix = os.path.splitext(sys.executable)[-1]
+    else:
+        suffix = ""
     for path, dirs, files in os.walk(venv):
     for path, dirs, files in os.walk(venv):
         if f"python{suffix}" in files:
         if f"python{suffix}" in files:
             return os.path.join(path, f"python{suffix}")
             return os.path.join(path, f"python{suffix}")