浏览代码

[F] Make psutil dependency Windows-only

Azalea (on HyDEV-Daisy) 2 年之前
父节点
当前提交
a8352d1fef
共有 2 个文件被更改,包括 14 次插入7 次删除
  1. 7 6
      hyfetch/neofetch_util.py
  2. 7 1
      setup.py

+ 7 - 6
hyfetch/neofetch_util.py

@@ -14,7 +14,6 @@ from tempfile import TemporaryDirectory
 from urllib.request import urlretrieve
 from urllib.request import urlretrieve
 
 
 import pkg_resources
 import pkg_resources
-import psutil
 from typing_extensions import Literal
 from typing_extensions import Literal
 
 
 from hyfetch.color_util import color
 from hyfetch.color_util import color
@@ -185,11 +184,13 @@ def check_windows_cmd():
     Check if this script is running under cmd.exe. If so, launch an external window with git bash
     Check if this script is running under cmd.exe. If so, launch an external window with git bash
     since cmd doesn't support RGB colors.
     since cmd doesn't support RGB colors.
     """
     """
-    if psutil.Process(os.getppid()).name().lower().strip() == 'cmd.exe':
-        print("cmd.exe doesn't support RGB colors, restarting in MinTTY...")
-        cmd = f'"{ensure_git_bash().parent.parent / "usr/bin/mintty.exe"}" -s 110,40 -e python -m hyfetch --ask-exit'
-        os.system(cmd)
-        exit()
+    if platform.system() == 'Windows':
+        import psutil
+        if psutil.Process(os.getppid()).name().lower().strip() == 'cmd.exe':
+            print("cmd.exe doesn't support RGB colors, restarting in MinTTY...")
+            cmd = f'"{ensure_git_bash().parent.parent / "usr/bin/mintty.exe"}" -s 110,40 -e python -m hyfetch --ask-exit'
+            os.system(cmd)
+            exit()
 
 
 
 
 def run_command(args: str, pipe: bool = False) -> str | None:
 def run_command(args: str, pipe: bool = False) -> str | None:

+ 7 - 1
setup.py

@@ -33,7 +33,13 @@ setup(
     packages=['hyfetch'],
     packages=['hyfetch'],
     package_data={'hyfetch': ['hyfetch/*']},
     package_data={'hyfetch': ['hyfetch/*']},
     include_package_data=True,
     include_package_data=True,
-    install_requires=['setuptools', 'typing_extensions'],
+    install_requires=[
+        # Universal dependencies
+        'setuptools', 'typing_extensions'
+        
+        # Windows dependencies
+        'psutil ; platform_system=="Windows"'
+    ],
     entry_points={
     entry_points={
         "console_scripts": [
         "console_scripts": [
             "hyfetch=hyfetch.main:run",
             "hyfetch=hyfetch.main:run",