diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 527b55e..090b6ee 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ repos: - id: check-added-large-files - id: check-case-conflict - id: check-merge-conflict - - id: check-shebang-scripts-are-executable + - id: check-executables-have-shebangs - id: check-symlinks - id: check-toml - id: check-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.1 + rev: v0.15.2 hooks: - id: ruff-check args: ["--fix", "--show-fixes", "--unsafe-fixes"] diff --git a/ci/bump-version.sh b/ci/bump-version.sh index 9810dde..1513673 100755 --- a/ci/bump-version.sh +++ b/ci/bump-version.sh @@ -84,6 +84,9 @@ git commit -m "Bump version: ${VERSION} → ${NEW_VERSION} [ci skip]" -a git log -1 if ! [ "$CI" == "true" ]; then git push origin "$(git branch --show-current)" - git push origin "$(git branch --show-current)" --tags + if ! (echo "$NEW_VERSION" | grep -q "\.dev"); then + git tag -s "$NEW_VERSION" -m "Bump version: ${NEW_VERSION}" + git push origin "$(git branch --show-current)" --tags + fi fi echo "::endgroup::" diff --git a/ci/install-tools.sh b/ci/install-tools.sh index 8d1d636..595cc29 100755 --- a/ci/install-tools.sh +++ b/ci/install-tools.sh @@ -1,20 +1,5 @@ #!/bin/bash -INSTALL_DIR="$HOME/bin" -mkdir -p "$INSTALL_DIR" - -if which python &>/dev/null; then - PY_PLATFORM=$(python -c "import sysconfig; print(sysconfig.get_platform(), end='')") -elif [ -z "$MINGW_PACKAGE_PREFIX" ]; then - PY_PLATFORM="mingw" -else - PY_PLATFORM="" -fi - -IS_CONDA=$([ -n "$CONDA_EXE" ] && echo "1") -IS_MINGW=$([[ $PY_PLATFORM == mingw* ]] && echo "1") -IS_WINDOWS=$([[ $PY_PLATFORM == win* ]] && echo "1") - # Usage if [ -n "$1" ] && [ "$1" == "--help" ]; then echo "Usage:" @@ -25,6 +10,26 @@ if [ -n "$1" ] && [ "$1" == "--help" ]; then exit 1 fi +# Detect environment +IS_CONDA="0" +IS_MINGW="0" +IS_WINDOWS="0" +if [ -n "$CONDA_EXE" ]; then + IS_CONDA="1" +elif [ -n "$MINGW_PACKAGE_PREFIX" ]; then + IS_MINGW="1" +elif which python &>/dev/null; then + PY_PLATFORM=$(python -c "import sysconfig; print(sysconfig.get_platform(), end='')") + IS_WINDOWS=$([[ $PY_PLATFORM == win* ]] && echo "1") +else + echo "error: Python is required." + exit 1 +fi + +# Install/update dev tools (including uv if required) +INSTALL_DIR="$HOME/bin" +mkdir -p "$INSTALL_DIR" + INSTALL_DEV="" INSTALL_TESTS="" while [ -n "$1" ]; do @@ -39,28 +44,28 @@ while [ -n "$1" ]; do done echo "::group::Install dependencies and build tools" -# Install/update uv and dev tools if [ "$IS_CONDA" == "1" ]; then - # Conda Python 3.14: python-msilib is not available yet - PY_VERSION=$(python -c "import sysconfig; print(sysconfig.get_python_version(), end='')") - SYS_PLATFORM=$(python -c "import sys; print(sys.platform, end='')") - # Packages to install - pkgs=("uv" "python-build") + # Install libmamba-solver and use it to speed up packages installation + echo "Update conda to use libmamba-solver" + $CONDA_EXE clean --index-cache --logfiles --quiet --yes + $CONDA_EXE update -n base conda --quiet --yes + $CONDA_EXE install -n base conda-libmamba-solver --quiet --yes + $CONDA_EXE config --set solver libmamba if ! which python &>/dev/null; then - pkgs+=("python=3.13") + $CONDA_EXE install -c conda-forge python -S -q -y fi + # Packages to install + pkgs=("python-build") # Dependencies of the project if [ -f requirements.txt ]; then + SYS_PLATFORM=$(python -c "import sys; print(sys.platform, end='')") while read -r line; do if [[ $line != *sys_platform* ]] || \ [[ $line == *sys_platform*==*${SYS_PLATFORM}* ]]; then name=$(echo "$line" | awk -F '[><=]+' '{ print $1 }') if [ "$name" == "cx-logging" ]; then name="cx_logging"; fi if [ "$name" == "lief" ]; then name="py-lief"; fi - if [ "$name" == "python-msilib" ] && [ "$PY_VERSION" == "3.14" ]; then - continue - fi if ! printf '%s\0' "${pkgs[@]}" | grep -Fxqz -- "$name"; then pkgs+=("$name") fi @@ -76,18 +81,12 @@ if [ "$IS_CONDA" == "1" ]; then done < tests/requirements.txt fi - # Install libmamba-solver and use it to speed up packages installation - echo "Update conda to use libmamba-solver" - $CONDA_EXE clean --index-cache --logfiles --quiet --yes - $CONDA_EXE update -n base conda --quiet --yes - $CONDA_EXE install -n base conda-libmamba-solver --quiet --yes - $CONDA_EXE config --set solver libmamba echo "Install packages" echo "${pkgs[@]}" $CONDA_EXE install -c conda-forge "${pkgs[@]}" -S -q -y elif [ "$IS_MINGW" == "1" ]; then # Packages to install - pkgs=("$MINGW_PACKAGE_PREFIX-uv" "$MINGW_PACKAGE_PREFIX-python-build") + pkgs=("$MINGW_PACKAGE_PREFIX-python-build") if ! which python &>/dev/null; then pkgs+=("$MINGW_PACKAGE_PREFIX-python") fi diff --git a/pyproject.toml b/pyproject.toml index 9f8de3d..0d55d31 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.2", + "prek==0.3.3", ] tests = [ "coverage==7.13.4", diff --git a/requirements-dev.txt b/requirements-dev.txt index 2a65e1f..6fc640e 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,2 +1,2 @@ cibuildwheel==3.3.1 -prek==0.3.2 +prek==0.3.3