Skip to content

Commit 2de8844

Browse files
Update shfmt to 3.7.0
1 parent 3b840a7 commit 2de8844

File tree

1 file changed

+31
-12
lines changed

1 file changed

+31
-12
lines changed

setup.py

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,57 @@
11
#!/usr/bin/env python3
2+
from __future__ import annotations
3+
24
import hashlib
35
import http
46
import os.path
7+
import platform
58
import stat
69
import sys
710
import urllib.request
8-
from typing import Tuple
911

1012
from distutils.command.build import build as orig_build
1113
from distutils.core import Command
1214
from setuptools import setup
1315
from setuptools.command.install import install as orig_install
1416

15-
SHFMT_VERSION = '3.4.3'
17+
SHFMT_VERSION = '3.7.0'
1618
POSTFIX_SHA256 = {
17-
# TODO(rhee): detect "linux.aarch64" and "linux.armv6hf"
18-
'linux': (
19+
('linux', 'armv6hf'): (
20+
'linux_arm',
21+
'3d1f5a1aede8161293bc42007af5b983f16d62857736c789f062346ed839f299',
22+
),
23+
('linux', 'aarch64'): (
24+
'linux_arm64',
25+
'111612560d15bd53d8e8f8f85731176ce12f3b418ec473d39a40ed6bbec772de',
26+
),
27+
('linux', 'x86_64'): (
1928
'linux_amd64',
20-
'713ef49db9a60a00636814a507da851b58da6b4b98a3627188fba0a61b60f9a8',
29+
'0264c424278b18e22453fe523ec01a19805ce3b8ebf18eaf3aadc1edc23f42e3',
2130
),
22-
'darwin': (
31+
('darwin', 'x86_64'): (
2332
'darwin_amd64',
24-
'22af685075e0448861c5db111e70cc399bdc95cdd7def943bc5adb6783f3e530',
33+
'ae1d1ab961c113fb3dc2ff1150f33c3548983550d91da889b3171a5bcfaab14f',
2534
),
26-
'win32': (
35+
('darwin', 'arm64'): (
36+
'darwin_arm64',
37+
'ad7ff6f666adba3d801eb17365a15539f07296718d39fb62cc2fde6b527178aa',
38+
),
39+
('win32', 'AMD64'): (
2740
'windows_amd64.exe',
28-
'a6c317a68dddf8efa9fd87d985a807cf7ab2423871d390aac4d3775691565835',
41+
'2807b4af91fbbd961b68716de06c044f1b4f897457fc89fba216e5e2e351c64f',
42+
),
43+
('win32', 'x86'): (
44+
'windows_386.exe',
45+
'8bd0422554dd6ce5e07d9d17d020d89254b5c056009005df824e39a8cbdcf6aa',
2946
),
3047
}
48+
POSTFIX_SHA256[('cygwin', 'x86_64')] = POSTFIX_SHA256[('win32', 'AMD64')]
49+
POSTFIX_SHA256[('linux', 'armv7l')] = POSTFIX_SHA256[('linux', 'armv6hf')]
3150
PY_VERSION = '1'
3251

3352

34-
def get_download_url() -> Tuple[str, str]:
35-
postfix, sha256 = POSTFIX_SHA256[sys.platform]
53+
def get_download_url() -> tuple[str, str]:
54+
postfix, sha256 = POSTFIX_SHA256[(sys.platform, platform.machine())]
3655
url = (
3756
f'https://github.com/mvdan/sh/releases/download/'
3857
f'v{SHFMT_VERSION}/shfmt_v{SHFMT_VERSION}_{postfix}'
@@ -58,7 +77,7 @@ def download(url: str, sha256: str) -> bytes:
5877
def save_executable(data: bytes, base_dir: str):
5978
exe = 'shfmt' if sys.platform != 'win32' else 'shfmt.exe'
6079
output_path = os.path.join(base_dir, exe)
61-
os.makedirs(base_dir)
80+
os.makedirs(base_dir, exist_ok=True)
6281

6382
with open(output_path, 'wb') as fp:
6483
fp.write(data)

0 commit comments

Comments
 (0)