Browse Source

[O] Make readline optional

Hykilpikonna 2 years ago
parent
commit
8f8ecb7b94
2 changed files with 7 additions and 5 deletions
  1. 6 4
      hyfetch/main.py
  2. 1 1
      setup.py

+ 6 - 4
hyfetch/main.py

@@ -1,10 +1,6 @@
 #!/usr/bin/env python3
 #!/usr/bin/env python3
 from __future__ import annotations
 from __future__ import annotations
 
 
-# Do not delete import readline. Even though it's not used in the code, importing it would allow
-# arrow keys to be used in input() functions.
-import readline
-
 import argparse
 import argparse
 import json
 import json
 import random
 import random
@@ -321,6 +317,12 @@ def create_config() -> Config:
 
 
 
 
 def run():
 def run():
+    # Optional: Import readline
+    try:
+        import readline
+    except ModuleNotFoundError:
+        pass
+
     # Create CLI
     # Create CLI
     hyfetch = color('&b&lhyfetch&r')
     hyfetch = color('&b&lhyfetch&r')
     parser = argparse.ArgumentParser(description=color(f'{hyfetch} - neofetch with flags <3'))
     parser = argparse.ArgumentParser(description=color(f'{hyfetch} - neofetch with flags <3'))

+ 1 - 1
setup.py

@@ -33,7 +33,7 @@ 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', 'pyreadline'],
+    install_requires=['setuptools', 'typing_extensions'],
     entry_points={
     entry_points={
         "console_scripts": [
         "console_scripts": [
             "hyfetch=hyfetch.main:run",
             "hyfetch=hyfetch.main:run",