From d10eef20e3432f05eafdb53b9cbb4ff8f9b54a5d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 9 Oct 2023 17:00:04 +0000 Subject: [PATCH 1/6] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/pre-commit-hooks: v4.4.0 → v4.5.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.4.0...v4.5.0) - [github.com/asottile/setup-cfg-fmt: v2.4.0 → v2.5.0](https://github.com/asottile/setup-cfg-fmt/compare/v2.4.0...v2.5.0) - [github.com/asottile/reorder-python-imports: v3.11.0 → v3.12.0](https://github.com/asottile/reorder-python-imports/compare/v3.11.0...v3.12.0) - [github.com/asottile/pyupgrade: v3.13.0 → v3.15.0](https://github.com/asottile/pyupgrade/compare/v3.13.0...v3.15.0) --- .pre-commit-config.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 912a5eb..ec7d951 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.5.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer @@ -10,11 +10,11 @@ repos: - id: name-tests-test - id: requirements-txt-fixer - repo: https://github.com/asottile/setup-cfg-fmt - rev: v2.4.0 + rev: v2.5.0 hooks: - id: setup-cfg-fmt - repo: https://github.com/asottile/reorder-python-imports - rev: v3.11.0 + rev: v3.12.0 hooks: - id: reorder-python-imports args: [--py38-plus, --add-import, 'from __future__ import annotations'] @@ -23,7 +23,7 @@ repos: hooks: - id: add-trailing-comma - repo: https://github.com/asottile/pyupgrade - rev: v3.13.0 + rev: v3.15.0 hooks: - id: pyupgrade args: [--py38-plus] From 0afa53fa8ddf1516d055db24e7ecb162980e67d7 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sun, 8 Oct 2023 17:33:34 -0400 Subject: [PATCH 2/6] use setuptools-download to download binaries --- setup.cfg | 45 +++++++++++++++ setup.py | 160 +----------------------------------------------------- 2 files changed, 48 insertions(+), 157 deletions(-) diff --git a/setup.cfg b/setup.cfg index a6f9305..f527da7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,6 @@ [metadata] name = shellcheck_py +version = 0.9.0.6 description = Python wrapper around invoking shellcheck (https://www.shellcheck.net/) long_description = file: README.md long_description_content_type = text/markdown @@ -17,3 +18,47 @@ classifiers = [options] python_requires = >=3.8 +setup_requires = + setuptools-download + +[setuptools_download] +download_scripts = + [shellcheck] + group = shellcheck-binary + marker = sys_platform == "linux" and platform_machine == "armv6hf" + marker = sys_platform == "linux" and platform_machine == "armv7l" + url = https://github.com/koalaman/shellcheck/releases/download/v0.9.0/shellcheck-v0.9.0.linux.armv6hf.tar.xz + sha256 = 03deed9ded9dd66434ccf9649815bcde7d275d6c9f6dcf665b83391673512c75 + extract = tar + extract_path = shellcheck-v0.9.0/shellcheck + [shellcheck] + group = shellcheck-binary + marker = sys_platform == "linux" and platform_machine == "aarch64" + url = https://github.com/koalaman/shellcheck/releases/download/v0.9.0/shellcheck-v0.9.0.linux.aarch64.tar.xz + sha256 = 179c579ef3481317d130adebede74a34dbbc2df961a70916dd4039ebf0735fae + extract = tar + extract_path = shellcheck-v0.9.0/shellcheck + [shellcheck] + group = shellcheck-binary + marker = sys_platform == "linux" and platform_machine == "x86_64" + url = https://github.com/koalaman/shellcheck/releases/download/v0.9.0/shellcheck-v0.9.0.linux.x86_64.tar.xz + sha256 = 700324c6dd0ebea0117591c6cc9d7350d9c7c5c287acbad7630fa17b1d4d9e2f + extract = tar + extract_path = shellcheck-v0.9.0/shellcheck + [shellcheck] + group = shellcheck-binary + marker = sys_platform == "darwin" and platform_machine == "x86_64" + marker = sys_platform == "darwin" and platform_machine == "arm64" + url = https://github.com/koalaman/shellcheck/releases/download/v0.9.0/shellcheck-v0.9.0.darwin.x86_64.tar.xz + sha256 = 7d3730694707605d6e60cec4efcb79a0632d61babc035aa16cda1b897536acf5 + extract = tar + extract_path = shellcheck-v0.9.0/shellcheck + [shellcheck.exe] + group = shellcheck-binary + marker = sys_platform == "win32" and platform_machine == "AMD64" + marker = sys_platform == "win32" and platform_machine == "ARM64" + marker = sys_platform == "cygwin" and platform_machine == "x86_64" + url = https://github.com/koalaman/shellcheck/releases/download/v0.9.0/shellcheck-v0.9.0.zip + sha256 = ae58191b1ea4ffd9e5b15da9134146e636440302ce3e2f46863e8d71c8be1bbb + extract = zip + extract_path = shellcheck.exe diff --git a/setup.py b/setup.py index 78a1400..851bbfd 100644 --- a/setup.py +++ b/setup.py @@ -1,165 +1,11 @@ -#!/usr/bin/env python3 from __future__ import annotations -import hashlib -import http -import io -import os.path -import platform -import stat -import sys -import tarfile -import urllib.request -import zipfile - -from distutils.command.build import build as orig_build -from distutils.core import Command from setuptools import setup -from setuptools.command.install import install as orig_install - -SHELLCHECK_VERSION = '0.9.0' -POSTFIX_SHA256 = { - ('linux', 'armv6hf'): ( - 'linux.armv6hf.tar.xz', - '03deed9ded9dd66434ccf9649815bcde7d275d6c9f6dcf665b83391673512c75', - ), - ('linux', 'aarch64'): ( - 'linux.aarch64.tar.xz', - '179c579ef3481317d130adebede74a34dbbc2df961a70916dd4039ebf0735fae', - ), - ('linux', 'x86_64'): ( - 'linux.x86_64.tar.xz', - '700324c6dd0ebea0117591c6cc9d7350d9c7c5c287acbad7630fa17b1d4d9e2f', - ), - ('darwin', 'x86_64'): ( - 'darwin.x86_64.tar.xz', - '7d3730694707605d6e60cec4efcb79a0632d61babc035aa16cda1b897536acf5', - ), - ('win32', 'AMD64'): ( - 'zip', - 'ae58191b1ea4ffd9e5b15da9134146e636440302ce3e2f46863e8d71c8be1bbb', - ), -} -POSTFIX_SHA256[('cygwin', 'x86_64')] = POSTFIX_SHA256[('win32', 'AMD64')] -POSTFIX_SHA256[('win32', 'ARM64')] = POSTFIX_SHA256[('win32', 'AMD64')] -POSTFIX_SHA256[('darwin', 'arm64')] = POSTFIX_SHA256[('darwin', 'x86_64')] -POSTFIX_SHA256[('linux', 'armv7l')] = POSTFIX_SHA256[('linux', 'armv6hf')] -PY_VERSION = '6' - - -def get_download_url() -> tuple[str, str]: - postfix, sha256 = POSTFIX_SHA256[(sys.platform, platform.machine())] - url = ( - f'https://github.com/koalaman/shellcheck/releases/download/' - f'v{SHELLCHECK_VERSION}/shellcheck-v{SHELLCHECK_VERSION}.{postfix}' - ) - return url, sha256 - - -def download(url: str, sha256: str) -> bytes: - with urllib.request.urlopen(url) as resp: - code = resp.getcode() - if code != http.HTTPStatus.OK: - raise ValueError(f'HTTP failure. Code: {code}') - data = resp.read() - - checksum = hashlib.sha256(data).hexdigest() - if checksum != sha256: - raise ValueError(f'sha256 mismatch, expected {sha256}, got {checksum}') - - return data - - -def extract(url: str, data: bytes) -> bytes: - with io.BytesIO(data) as bio: - if '.tar.' in url: - with tarfile.open(fileobj=bio) as tarf: - for info in tarf.getmembers(): - if info.isfile() and info.name.endswith('shellcheck'): - return tarf.extractfile(info).read() - elif url.endswith('.zip'): - with zipfile.ZipFile(bio) as zipf: - for info in zipf.infolist(): - if info.filename.endswith('.exe'): - return zipf.read(info.filename) - - raise AssertionError(f'unreachable {url}') - - -def save_executable(data: bytes, base_dir: str): - exe = 'shellcheck' if sys.platform != 'win32' else 'shellcheck.exe' - output_path = os.path.join(base_dir, exe) - os.makedirs(base_dir, exist_ok=True) - - with open(output_path, 'wb') as fp: - fp.write(data) - - # Mark as executable. - # https://stackoverflow.com/a/14105527 - mode = os.stat(output_path).st_mode - mode |= stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH - os.chmod(output_path, mode) - - -class build(orig_build): - sub_commands = orig_build.sub_commands + [('fetch_binaries', None)] - - -class install(orig_install): - sub_commands = orig_install.sub_commands + [('install_shellcheck', None)] - - -class fetch_binaries(Command): - build_temp = None - - def initialize_options(self): - pass - - def finalize_options(self): - self.set_undefined_options('build', ('build_temp', 'build_temp')) - - def run(self): - # save binary to self.build_temp - url, sha256 = get_download_url() - archive = download(url, sha256) - data = extract(url, archive) - save_executable(data, self.build_temp) - - -class install_shellcheck(Command): - description = 'install the shellcheck executable' - outfiles = () - build_dir = install_dir = None - - def initialize_options(self): - pass - - def finalize_options(self): - # this initializes attributes based on other commands' attributes - self.set_undefined_options('build', ('build_temp', 'build_dir')) - self.set_undefined_options( - 'install', ('install_scripts', 'install_dir'), - ) - - def run(self): - self.outfiles = self.copy_tree(self.build_dir, self.install_dir) - - def get_outputs(self): - return self.outfiles - - -command_overrides = { - 'install': install, - 'install_shellcheck': install_shellcheck, - 'build': build, - 'fetch_binaries': fetch_binaries, -} - try: from wheel.bdist_wheel import bdist_wheel as orig_bdist_wheel except ImportError: - pass + cmdclass = {} else: class bdist_wheel(orig_bdist_wheel): def finalize_options(self): @@ -172,6 +18,6 @@ def get_tag(self): # We don't contain any python source, nor any python extensions return 'py2.py3', 'none', plat - command_overrides['bdist_wheel'] = bdist_wheel + cmdclass = {'bdist_wheel': bdist_wheel} -setup(version=f'{SHELLCHECK_VERSION}.{PY_VERSION}', cmdclass=command_overrides) +setup(cmdclass=cmdclass) From 772e567097eaf2d8b77bd7f4f0c95f43caf5812b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 8 Jan 2024 16:58:48 +0000 Subject: [PATCH 3/6] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/PyCQA/flake8: 6.1.0 → 7.0.0](https://github.com/PyCQA/flake8/compare/6.1.0...7.0.0) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ec7d951..8124cbb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -32,6 +32,6 @@ repos: hooks: - id: autopep8 - repo: https://github.com/PyCQA/flake8 - rev: 6.1.0 + rev: 7.0.0 hooks: - id: flake8 From 84d34a55671b9f716ca5ce2afa7746121ad336bd Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 19 Feb 2024 17:03:02 +0000 Subject: [PATCH 4/6] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/asottile/pyupgrade: v3.15.0 → v3.15.1](https://github.com/asottile/pyupgrade/compare/v3.15.0...v3.15.1) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8124cbb..124e792 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -23,7 +23,7 @@ repos: hooks: - id: add-trailing-comma - repo: https://github.com/asottile/pyupgrade - rev: v3.15.0 + rev: v3.15.1 hooks: - id: pyupgrade args: [--py38-plus] From ffb81bbcbc4c77311f512f2a5682cf28e5e4d4af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20Rom=C3=A1n?= Date: Mon, 11 Mar 2024 10:53:53 -0700 Subject: [PATCH 5/6] Upgrade to v0.10.0 --- setup.cfg | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/setup.cfg b/setup.cfg index f527da7..17cedcb 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = shellcheck_py -version = 0.9.0.6 +version = 0.10.0.1 description = Python wrapper around invoking shellcheck (https://www.shellcheck.net/) long_description = file: README.md long_description_content_type = text/markdown @@ -27,38 +27,44 @@ download_scripts = group = shellcheck-binary marker = sys_platform == "linux" and platform_machine == "armv6hf" marker = sys_platform == "linux" and platform_machine == "armv7l" - url = https://github.com/koalaman/shellcheck/releases/download/v0.9.0/shellcheck-v0.9.0.linux.armv6hf.tar.xz - sha256 = 03deed9ded9dd66434ccf9649815bcde7d275d6c9f6dcf665b83391673512c75 + url = https://github.com/koalaman/shellcheck/releases/download/v0.10.0/shellcheck-v0.10.0.linux.armv6hf.tar.xz + sha256 = 1c89cb51e1412b580d7ba8aac240251ffb0b829788f83d2daa4a82da42d275e4 extract = tar - extract_path = shellcheck-v0.9.0/shellcheck + extract_path = shellcheck-v0.10.0/shellcheck [shellcheck] group = shellcheck-binary marker = sys_platform == "linux" and platform_machine == "aarch64" - url = https://github.com/koalaman/shellcheck/releases/download/v0.9.0/shellcheck-v0.9.0.linux.aarch64.tar.xz - sha256 = 179c579ef3481317d130adebede74a34dbbc2df961a70916dd4039ebf0735fae + url = https://github.com/koalaman/shellcheck/releases/download/v0.10.0/shellcheck-v0.10.0.linux.aarch64.tar.xz + sha256 = 324a7e89de8fa2aed0d0c28f3dab59cf84c6d74264022c00c22af665ed1a09bb extract = tar - extract_path = shellcheck-v0.9.0/shellcheck + extract_path = shellcheck-v0.10.0/shellcheck [shellcheck] group = shellcheck-binary marker = sys_platform == "linux" and platform_machine == "x86_64" - url = https://github.com/koalaman/shellcheck/releases/download/v0.9.0/shellcheck-v0.9.0.linux.x86_64.tar.xz - sha256 = 700324c6dd0ebea0117591c6cc9d7350d9c7c5c287acbad7630fa17b1d4d9e2f + url = https://github.com/koalaman/shellcheck/releases/download/v0.10.0/shellcheck-v0.10.0.linux.x86_64.tar.xz + sha256 = 6c881ab0698e4e6ea235245f22832860544f17ba386442fe7e9d629f8cbedf87 extract = tar - extract_path = shellcheck-v0.9.0/shellcheck + extract_path = shellcheck-v0.10.0/shellcheck [shellcheck] group = shellcheck-binary - marker = sys_platform == "darwin" and platform_machine == "x86_64" marker = sys_platform == "darwin" and platform_machine == "arm64" - url = https://github.com/koalaman/shellcheck/releases/download/v0.9.0/shellcheck-v0.9.0.darwin.x86_64.tar.xz - sha256 = 7d3730694707605d6e60cec4efcb79a0632d61babc035aa16cda1b897536acf5 + url = https://github.com/koalaman/shellcheck/releases/download/v0.10.0/shellcheck-v0.10.0.darwin.aarch64.tar.xz + sha256 = bbd2f14826328eee7679da7221f2bc3afb011f6a928b848c80c321f6046ddf81 + extract = tar + extract_path = shellcheck-v0.10.0/shellcheck + [shellcheck] + group = shellcheck-binary + marker = sys_platform == "darwin" and platform_machine == "x86_64" + url = https://github.com/koalaman/shellcheck/releases/download/v0.10.0/shellcheck-v0.10.0.darwin.x86_64.tar.xz + sha256 = ef27684f23279d112d8ad84e0823642e43f838993bbb8c0963db9b58a90464c2 extract = tar - extract_path = shellcheck-v0.9.0/shellcheck + extract_path = shellcheck-v0.10.0/shellcheck [shellcheck.exe] group = shellcheck-binary marker = sys_platform == "win32" and platform_machine == "AMD64" marker = sys_platform == "win32" and platform_machine == "ARM64" marker = sys_platform == "cygwin" and platform_machine == "x86_64" - url = https://github.com/koalaman/shellcheck/releases/download/v0.9.0/shellcheck-v0.9.0.zip - sha256 = ae58191b1ea4ffd9e5b15da9134146e636440302ce3e2f46863e8d71c8be1bbb + url = https://github.com/koalaman/shellcheck/releases/download/v0.10.0/shellcheck-v0.10.0.zip + sha256 = eb6cd53a54ea97a56540e9d296ce7e2fa68715aa507ff23574646c1e12b2e143 extract = zip extract_path = shellcheck.exe From a23f6b85d0fdd5bb9d564e2579e678033debbdff Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sun, 17 Mar 2024 11:14:48 -0400 Subject: [PATCH 6/6] v0.10.0.1 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5155bf6..7c5f4a6 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Sample `.pre-commit-config.yaml`: ```yaml - repo: https://github.com/shellcheck-py/shellcheck-py - rev: v0.9.0.6 + rev: v0.10.0.1 hooks: - id: shellcheck ```