1
0
Fork 0

Adding upstream version 3.3.2.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-09 21:42:32 +01:00
parent 00f36ec412
commit 05acda6fb8
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
7 changed files with 63 additions and 52 deletions

View file

@ -63,8 +63,6 @@ jobs:
echo 'C:\Strawberry\c\bin' >> "$GITHUB_PATH" echo 'C:\Strawberry\c\bin' >> "$GITHUB_PATH"
shell: bash shell: bash
if: matrix.os == 'windows-latest' && matrix.language == 'perl' if: matrix.os == 'windows-latest' && matrix.language == 'perl'
- run: testing/get-swift.sh
if: matrix.os == 'ubuntu-latest' && matrix.language == 'swift'
- name: install deps - name: install deps
run: python -mpip install -e . -r requirements-dev.txt run: python -mpip install -e . -r requirements-dev.txt

View file

@ -13,7 +13,7 @@ repos:
rev: v2.2.0 rev: v2.2.0
hooks: hooks:
- id: setup-cfg-fmt - id: setup-cfg-fmt
- repo: https://github.com/asottile/reorder_python_imports - repo: https://github.com/asottile/reorder-python-imports
rev: v3.9.0 rev: v3.9.0
hooks: hooks:
- id: reorder-python-imports - id: reorder-python-imports
@ -25,7 +25,7 @@ repos:
- id: add-trailing-comma - id: add-trailing-comma
args: [--py36-plus] args: [--py36-plus]
- repo: https://github.com/asottile/pyupgrade - repo: https://github.com/asottile/pyupgrade
rev: v3.3.2 rev: v3.4.0
hooks: hooks:
- id: pyupgrade - id: pyupgrade
args: [--py38-plus] args: [--py38-plus]
@ -38,7 +38,7 @@ repos:
hooks: hooks:
- id: flake8 - id: flake8
- repo: https://github.com/pre-commit/mirrors-mypy - repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.2.0 rev: v1.3.0
hooks: hooks:
- id: mypy - id: mypy
additional_dependencies: [types-all] additional_dependencies: [types-all]

View file

@ -1,3 +1,11 @@
3.3.2 - 2023-05-17
==================
### Fixes
- Work around `r` on windows sometimes double-un-quoting arguments.
- #2885 PR by @lorenzwalthert.
- #2870 issue by @lorenzwalthert.
3.3.1 - 2023-05-02 3.3.1 - 2023-05-02
================== ==================

View file

@ -4,6 +4,8 @@ import contextlib
import os import os
import shlex import shlex
import shutil import shutil
import tempfile
import textwrap
from typing import Generator from typing import Generator
from typing import Sequence from typing import Sequence
@ -21,6 +23,19 @@ get_default_version = lang_base.basic_get_default_version
health_check = lang_base.basic_health_check health_check = lang_base.basic_health_check
@contextlib.contextmanager
def _r_code_in_tempfile(code: str) -> Generator[str, None, None]:
"""
To avoid quoting and escaping issues, avoid `Rscript [options] -e {expr}`
but use `Rscript [options] path/to/file_with_expr.R`
"""
with tempfile.TemporaryDirectory() as tmpdir:
fname = os.path.join(tmpdir, 'script.R')
with open(fname, 'w') as f:
f.write(_inline_r_setup(textwrap.dedent(code)))
yield fname
def get_env_patch(venv: str) -> PatchesT: def get_env_patch(venv: str) -> PatchesT:
return ( return (
('R_PROFILE_USER', os.path.join(venv, 'activate.R')), ('R_PROFILE_USER', os.path.join(venv, 'activate.R')),
@ -93,6 +108,8 @@ def install_environment(
version: str, version: str,
additional_dependencies: Sequence[str], additional_dependencies: Sequence[str],
) -> None: ) -> None:
lang_base.assert_version_default('r', version)
env_dir = lang_base.environment_dir(prefix, ENVIRONMENT_DIR, version) env_dir = lang_base.environment_dir(prefix, ENVIRONMENT_DIR, version)
os.makedirs(env_dir, exist_ok=True) os.makedirs(env_dir, exist_ok=True)
shutil.copy(prefix.path('renv.lock'), env_dir) shutil.copy(prefix.path('renv.lock'), env_dir)
@ -127,20 +144,19 @@ def install_environment(
}} }}
""" """
cmd_output_b( with _r_code_in_tempfile(r_code_inst_environment) as f:
_rscript_exec(), '--vanilla', '-e', cmd_output_b(_rscript_exec(), '--vanilla', f, cwd=env_dir)
_inline_r_setup(r_code_inst_environment),
cwd=env_dir,
)
if additional_dependencies: if additional_dependencies:
r_code_inst_add = 'renv::install(commandArgs(trailingOnly = TRUE))' r_code_inst_add = 'renv::install(commandArgs(trailingOnly = TRUE))'
with in_env(prefix, version): with in_env(prefix, version):
cmd_output_b( with _r_code_in_tempfile(r_code_inst_add) as f:
_rscript_exec(), *RSCRIPT_OPTS, '-e', cmd_output_b(
_inline_r_setup(r_code_inst_add), _rscript_exec(), *RSCRIPT_OPTS,
*additional_dependencies, f,
cwd=env_dir, *additional_dependencies,
) cwd=env_dir,
)
def _inline_r_setup(code: str) -> str: def _inline_r_setup(code: str) -> str:
@ -148,11 +164,16 @@ def _inline_r_setup(code: str) -> str:
Some behaviour of R cannot be configured via env variables, but can Some behaviour of R cannot be configured via env variables, but can
only be configured via R options once R has started. These are set here. only be configured via R options once R has started. These are set here.
""" """
with_option = f"""\ with_option = [
options(install.packages.compile.from.source = "never", pkgType = "binary") textwrap.dedent("""\
{code} options(
""" install.packages.compile.from.source = "never",
return with_option pkgType = "binary"
)
"""),
code,
]
return '\n'.join(with_option)
def run_hook( def run_hook(

View file

@ -1,6 +1,6 @@
[metadata] [metadata]
name = pre_commit name = pre_commit
version = 3.3.1 version = 3.3.2
description = A framework for managing and maintaining multi-language pre-commit hooks. description = A framework for managing and maintaining multi-language pre-commit hooks.
long_description = file: README.md long_description = file: README.md
long_description_content_type = text/markdown long_description_content_type = text/markdown

View file

@ -1,29 +0,0 @@
#!/usr/bin/env bash
# This is a script used in CI to install swift
set -euo pipefail
. /etc/lsb-release
if [ "$DISTRIB_CODENAME" = "jammy" ]; then
SWIFT_URL='https://download.swift.org/swift-5.7.1-release/ubuntu2204/swift-5.7.1-RELEASE/swift-5.7.1-RELEASE-ubuntu22.04.tar.gz'
SWIFT_HASH='7f60291f5088d3e77b0c2364beaabd29616ee7b37260b7b06bdbeb891a7fe161'
else
echo "unknown dist: ${DISTRIB_CODENAME}" 1>&2
exit 1
fi
check() {
echo "$SWIFT_HASH $TGZ" | sha256sum --check
}
TGZ="$HOME/.swift/swift.tar.gz"
mkdir -p "$(dirname "$TGZ")"
if ! check >& /dev/null; then
rm -f "$TGZ"
curl --location --silent --output "$TGZ" "$SWIFT_URL"
check
fi
mkdir -p /tmp/swift
tar -xf "$TGZ" --strip 1 --directory /tmp/swift
echo '/tmp/swift/usr/bin' >> "$GITHUB_PATH"

View file

@ -16,6 +16,15 @@ EXCLUDED = frozenset((
)) ))
def _always_run() -> frozenset[str]:
ret = ['.github/workflows/languages.yaml', 'testing/languages']
ret.extend(
os.path.join('pre_commit/resources', fname)
for fname in os.listdir('pre_commit/resources')
)
return frozenset(ret)
def _lang_files(lang: str) -> frozenset[str]: def _lang_files(lang: str) -> frozenset[str]:
prog = f'''\ prog = f'''\
import json import json
@ -47,10 +56,14 @@ def main() -> int:
if fname.endswith('.py') and fname != '__init__.py' if fname.endswith('.py') and fname != '__init__.py'
] ]
triggers_all = _always_run()
for fname in triggers_all:
assert os.path.exists(fname), fname
if not args.all: if not args.all:
with concurrent.futures.ThreadPoolExecutor(os.cpu_count()) as exe: with concurrent.futures.ThreadPoolExecutor(os.cpu_count()) as exe:
by_lang = { by_lang = {
lang: files lang: files | triggers_all
for lang, files in zip(langs, exe.map(_lang_files, langs)) for lang, files in zip(langs, exe.map(_lang_files, langs))
} }