diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 090b6ee..9b7fe55 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -30,7 +30,7 @@ repos: - validate-pyproject-schema-store[all]>=2025.11.14 - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.15.2 + rev: v0.15.4 hooks: - id: ruff-check args: ["--fix", "--show-fixes", "--unsafe-fixes"] @@ -45,7 +45,7 @@ repos: args: ["--ignore-words-list=lief,LIEF", "-w", "--skip=*.rtf"] - repo: https://github.com/pre-commit/mirrors-clang-format - rev: v21.1.8 + rev: v22.1.0 hooks: - id: clang-format exclude: (?x)^(src/msilib/include/pythoncapi_compat.h)$ diff --git a/ci/install-tools.sh b/ci/install-tools.sh index 595cc29..520dba9 100755 --- a/ci/install-tools.sh +++ b/ci/install-tools.sh @@ -13,6 +13,7 @@ fi # Detect environment IS_CONDA="0" IS_MINGW="0" +IS_UV="0" IS_WINDOWS="0" if [ -n "$CONDA_EXE" ]; then IS_CONDA="1" @@ -21,6 +22,7 @@ elif [ -n "$MINGW_PACKAGE_PREFIX" ]; then elif which python &>/dev/null; then PY_PLATFORM=$(python -c "import sysconfig; print(sysconfig.get_platform(), end='')") IS_WINDOWS=$([[ $PY_PLATFORM == win* ]] && echo "1") + IS_UV="1" else echo "error: Python is required." exit 1 @@ -128,12 +130,9 @@ else env UV_INSTALL_DIR="$INSTALL_DIR" sh fi - # Lief is not available for Python 3.13t and 3.14t - PY_VERSION=$(python -c "import sysconfig; print(sysconfig.get_python_version(), end='')") + # Lief is not available for Python free-threaded PY_ABI_THREAD=$(python -c "import sysconfig; print(sysconfig.get_config_var('abi_thread') or '', end='')") - PY_VER_ABI="$PY_VERSION$PY_ABI_THREAD" - if [ "$IS_WINDOWS" == "1" ] && \ - { [ "$PY_VER_ABI" == "3.13t" ] || [ "$PY_VER_ABI" == "3.14t" ]; }; then + if [ "$IS_WINDOWS" == "1" ] && [ "$PY_ABI_THREAD" == "t" ]; then # Packages to install pkgs=() @@ -182,11 +181,18 @@ if [ "$INSTALL_DEV" == "1" ]; then PY_VER_ABI="$PY_VERSION$PY_ABI_THREAD" while read -r line; do name=$(echo "$line" | awk -F '[><=]+' '{ print $1 }') - filename=$INSTALL_DIR/$name - echo "Create $filename" - echo "#!/bin/sh"> "$filename" - echo "uvx -p $PY_VER_ABI \"$line\" \$@">> "$filename" - chmod +x "$filename" + # prek has no dependencies (doesn't bloat the installed packages) + if [ "$name" == "prek" ] && [ "$IS_CONDA" == "1" ]; then + $CONDA_EXE install -c conda-forge "$name" -S -q -y + elif [ "$name" == "prek" ] && [ "$IS_UV" == "1" ]; then + uv pip install --upgrade "$name" + else + filename=$INSTALL_DIR/$name + echo "Create $filename" + echo "#!/bin/sh"> "$filename" + echo "uvx -p $PY_VER_ABI \"$line\" \$@">> "$filename" + chmod +x "$filename" + fi done < requirements-dev.txt fi fi diff --git a/pyproject.toml b/pyproject.toml index 0d55d31..4f63df4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -47,7 +47,7 @@ Documentation = "https://docs.python.org/3.12/library/msilib.html" [dependency-groups] dev = [ "cibuildwheel==3.3.1", - "prek==0.3.3", + "prek==0.3.4", ] tests = [ "coverage==7.13.4", diff --git a/requirements-dev.txt b/requirements-dev.txt index 6fc640e..0a2e1db 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,2 +1,2 @@ cibuildwheel==3.3.1 -prek==0.3.3 +prek==0.3.4