[F] Fix entry
This commit is contained in:
parent
48f52be2d3
commit
8cc06c02b5
4 changed files with 43 additions and 30 deletions
|
|
@ -1,31 +1,10 @@
|
||||||
import os
|
import os
|
||||||
import platform
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
from . import main
|
|
||||||
from .color_util import printc
|
|
||||||
|
|
||||||
|
|
||||||
def run_py():
|
|
||||||
try:
|
|
||||||
main.run()
|
|
||||||
except KeyboardInterrupt:
|
|
||||||
printc('&cThe program is interrupted by ^C, exiting...')
|
|
||||||
exit(0)
|
|
||||||
|
|
||||||
|
|
||||||
def run_rust():
|
|
||||||
# Find the rust executable
|
|
||||||
pd = Path(__file__).parent.joinpath('rust')
|
|
||||||
pd = pd.joinpath('hyfetch.exe' if platform.system() == 'Windows' else 'hyfetch')
|
|
||||||
if not pd.exists():
|
|
||||||
printc('&cThe rust executable is not found, falling back to python...')
|
|
||||||
run_py()
|
|
||||||
return
|
|
||||||
|
|
||||||
# Run the rust executable
|
|
||||||
os.system(str(pd))
|
|
||||||
|
|
||||||
|
from .py import run_py
|
||||||
|
from .rs import run_rust
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
run_py()
|
if os.environ.get('HYFETCH_PY', False):
|
||||||
|
run_py()
|
||||||
|
else:
|
||||||
|
run_rust()
|
||||||
|
|
|
||||||
13
hyfetch/py.py
Normal file
13
hyfetch/py.py
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
from . import main
|
||||||
|
from .color_util import printc
|
||||||
|
|
||||||
|
def run_py():
|
||||||
|
try:
|
||||||
|
main.run()
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
printc('&cThe program is interrupted by ^C, exiting...')
|
||||||
|
exit(0)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
run_py()
|
||||||
|
|
@ -1,4 +1,24 @@
|
||||||
from .__main__ import run_rust
|
import platform
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
from .color_util import printc
|
||||||
|
from .py import run_py
|
||||||
|
|
||||||
|
|
||||||
|
def run_rust():
|
||||||
|
# Find the rust executable
|
||||||
|
pd = Path(__file__).parent.joinpath('rust')
|
||||||
|
pd = pd.joinpath('hyfetch.exe' if platform.system() == 'Windows' else 'hyfetch')
|
||||||
|
if not pd.exists():
|
||||||
|
printc('&cThe rust executable is not found, falling back to python...')
|
||||||
|
run_py()
|
||||||
|
return
|
||||||
|
|
||||||
|
# Run the rust executable, passing in all arguments
|
||||||
|
subprocess.run([str(pd)] + sys.argv[1:])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
run_rust()
|
run_rust()
|
||||||
|
|
|
||||||
5
setup.py
5
setup.py
|
|
@ -48,8 +48,9 @@ setup(
|
||||||
],
|
],
|
||||||
entry_points={
|
entry_points={
|
||||||
"console_scripts": [
|
"console_scripts": [
|
||||||
"hyfetch.py=hyfetch:run_py",
|
"hyfetch.v1=hyfetch.__main__:run_py",
|
||||||
"hyfetch=hyfetch:run_rust",
|
"hyfetch.rs=hyfetch.__main__:run_rust",
|
||||||
|
"hyfetch=hyfetch.__main__:run_rust",
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
scripts=['hyfetch/scripts/neowofetch']
|
scripts=['hyfetch/scripts/neowofetch']
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue