Adding upstream version 3.3.2.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
00f36ec412
commit
05acda6fb8
7 changed files with 63 additions and 52 deletions
2
.github/workflows/languages.yaml
vendored
2
.github/workflows/languages.yaml
vendored
|
@ -63,8 +63,6 @@ jobs:
|
|||
echo 'C:\Strawberry\c\bin' >> "$GITHUB_PATH"
|
||||
shell: bash
|
||||
if: matrix.os == 'windows-latest' && matrix.language == 'perl'
|
||||
- run: testing/get-swift.sh
|
||||
if: matrix.os == 'ubuntu-latest' && matrix.language == 'swift'
|
||||
|
||||
- name: install deps
|
||||
run: python -mpip install -e . -r requirements-dev.txt
|
||||
|
|
|
@ -13,7 +13,7 @@ repos:
|
|||
rev: v2.2.0
|
||||
hooks:
|
||||
- id: setup-cfg-fmt
|
||||
- repo: https://github.com/asottile/reorder_python_imports
|
||||
- repo: https://github.com/asottile/reorder-python-imports
|
||||
rev: v3.9.0
|
||||
hooks:
|
||||
- id: reorder-python-imports
|
||||
|
@ -25,7 +25,7 @@ repos:
|
|||
- id: add-trailing-comma
|
||||
args: [--py36-plus]
|
||||
- repo: https://github.com/asottile/pyupgrade
|
||||
rev: v3.3.2
|
||||
rev: v3.4.0
|
||||
hooks:
|
||||
- id: pyupgrade
|
||||
args: [--py38-plus]
|
||||
|
@ -38,7 +38,7 @@ repos:
|
|||
hooks:
|
||||
- id: flake8
|
||||
- repo: https://github.com/pre-commit/mirrors-mypy
|
||||
rev: v1.2.0
|
||||
rev: v1.3.0
|
||||
hooks:
|
||||
- id: mypy
|
||||
additional_dependencies: [types-all]
|
||||
|
|
|
@ -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
|
||||
==================
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@ import contextlib
|
|||
import os
|
||||
import shlex
|
||||
import shutil
|
||||
import tempfile
|
||||
import textwrap
|
||||
from typing import Generator
|
||||
from typing import Sequence
|
||||
|
||||
|
@ -21,6 +23,19 @@ get_default_version = lang_base.basic_get_default_version
|
|||
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:
|
||||
return (
|
||||
('R_PROFILE_USER', os.path.join(venv, 'activate.R')),
|
||||
|
@ -93,6 +108,8 @@ def install_environment(
|
|||
version: str,
|
||||
additional_dependencies: Sequence[str],
|
||||
) -> None:
|
||||
lang_base.assert_version_default('r', version)
|
||||
|
||||
env_dir = lang_base.environment_dir(prefix, ENVIRONMENT_DIR, version)
|
||||
os.makedirs(env_dir, exist_ok=True)
|
||||
shutil.copy(prefix.path('renv.lock'), env_dir)
|
||||
|
@ -127,20 +144,19 @@ def install_environment(
|
|||
}}
|
||||
"""
|
||||
|
||||
cmd_output_b(
|
||||
_rscript_exec(), '--vanilla', '-e',
|
||||
_inline_r_setup(r_code_inst_environment),
|
||||
cwd=env_dir,
|
||||
)
|
||||
with _r_code_in_tempfile(r_code_inst_environment) as f:
|
||||
cmd_output_b(_rscript_exec(), '--vanilla', f, cwd=env_dir)
|
||||
|
||||
if additional_dependencies:
|
||||
r_code_inst_add = 'renv::install(commandArgs(trailingOnly = TRUE))'
|
||||
with in_env(prefix, version):
|
||||
cmd_output_b(
|
||||
_rscript_exec(), *RSCRIPT_OPTS, '-e',
|
||||
_inline_r_setup(r_code_inst_add),
|
||||
*additional_dependencies,
|
||||
cwd=env_dir,
|
||||
)
|
||||
with _r_code_in_tempfile(r_code_inst_add) as f:
|
||||
cmd_output_b(
|
||||
_rscript_exec(), *RSCRIPT_OPTS,
|
||||
f,
|
||||
*additional_dependencies,
|
||||
cwd=env_dir,
|
||||
)
|
||||
|
||||
|
||||
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
|
||||
only be configured via R options once R has started. These are set here.
|
||||
"""
|
||||
with_option = f"""\
|
||||
options(install.packages.compile.from.source = "never", pkgType = "binary")
|
||||
{code}
|
||||
"""
|
||||
return with_option
|
||||
with_option = [
|
||||
textwrap.dedent("""\
|
||||
options(
|
||||
install.packages.compile.from.source = "never",
|
||||
pkgType = "binary"
|
||||
)
|
||||
"""),
|
||||
code,
|
||||
]
|
||||
return '\n'.join(with_option)
|
||||
|
||||
|
||||
def run_hook(
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[metadata]
|
||||
name = pre_commit
|
||||
version = 3.3.1
|
||||
version = 3.3.2
|
||||
description = A framework for managing and maintaining multi-language pre-commit hooks.
|
||||
long_description = file: README.md
|
||||
long_description_content_type = text/markdown
|
||||
|
|
|
@ -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"
|
|
@ -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]:
|
||||
prog = f'''\
|
||||
import json
|
||||
|
@ -47,10 +56,14 @@ def main() -> int:
|
|||
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:
|
||||
with concurrent.futures.ThreadPoolExecutor(os.cpu_count()) as exe:
|
||||
by_lang = {
|
||||
lang: files
|
||||
lang: files | triggers_all
|
||||
for lang, files in zip(langs, exe.map(_lang_files, langs))
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue