77from __future__ import annotations
88
99import os
10- from pathlib import Path
1110from sys import platform as sysplatform
1211
1312HUGO_VERSION = "0.160.0"
1413FILE_EXT = ".exe" if sysplatform == "win32" else ""
15- HUGO_PLATFORM = {"darwin" : "darwin" , "linux" : "linux" , "win32" : "windows" }[sysplatform ]
14+ if sysplatform == "win32" :
15+ HUGO_PLATFORM = "windows"
16+ elif sysplatform == "linux" :
17+ HUGO_PLATFORM = "linux"
18+ else :
19+ HUGO_PLATFORM = "darwin"
1620
1721
1822def get_hugo_arch ():
19- from platform import machine
2023 from sys import maxsize as sysmaxsize
2124
25+ if sysplatform == "win32" :
26+ from platform import machine
27+
28+ m = machine ()
29+ else :
30+ m = os .uname ().machine
31+
2232 HUGO_ARCH = {
2333 "x86_64" : "amd64" ,
2434 "arm64" : "arm64" ,
@@ -32,11 +42,11 @@ def get_hugo_arch():
3242 "armv7l" : "arm" ,
3343 "armv6l" : "arm" ,
3444 "riscv64" : "riscv64" ,
35- }[machine () ]
45+ }[m ]
3646
3747 # platform.machine returns AMD64 on Windows because the architecture is
3848 # 64-bit (even if one is running a 32-bit Python interpreter). Therefore
39- # we use sys. maxsize to handle this special case on Windows
49+ # we use sys.maxsize to handle this special case on Windows
4050
4151 if not (sysmaxsize > 2 ** 32 ) and sysplatform == "win32" :
4252 HUGO_ARCH = "386"
@@ -46,22 +56,20 @@ def get_hugo_arch():
4656
4757HUGO_ARCH = get_hugo_arch ()
4858
49- DIR = Path (__file__ ).parent .resolve ()
50-
51- HUGO_EXECUTABLE = Path (
52- DIR / "binaries" / f"hugo-{ HUGO_VERSION } -{ HUGO_PLATFORM } -{ HUGO_ARCH } { FILE_EXT } " ,
53- ).resolve ()
59+ DIR = os .path .dirname (os .path .abspath (__file__ )) # noqa: PTH100, PTH120
5460
55- MESSAGE = (
56- f"Running Hugo { HUGO_VERSION } via hugo-python-distributions at { HUGO_EXECUTABLE } "
61+ HUGO_EXECUTABLE = os . path . join ( # noqa: PTH118
62+ DIR , "binaries" , f"hugo- { HUGO_VERSION } - { HUGO_PLATFORM } - { HUGO_ARCH } { FILE_EXT } "
5763)
5864
5965
6066def __call ():
6167 """
6268 Hugo binary entry point. Passes all command-line arguments to Hugo.
6369 """
64- print (f"\033 [95m{ MESSAGE } \033 [0m" )
70+ print (
71+ f"\033 [95mRunning Hugo { HUGO_VERSION } via hugo-python-distributions at { HUGO_EXECUTABLE } \033 [0m"
72+ )
6573
6674 from sys import argv as sysargv
6775
0 commit comments