From f1c501e769ad8fb2df59c35453f92ab1fe790bf9 Mon Sep 17 00:00:00 2001 From: sdegrande Date: Mon, 5 Aug 2024 11:38:49 +0200 Subject: [PATCH 1/2] python-pre-commit: Fix installation of python pre-commit hooks Pre-commit uses python virtualenvs to install python hooks. On Windows, pre-commit uses the Windows's virtualenv directory structure, which install scripts in a 'Scripts' subdir. But, on msys, the standard unix virtualenv is used, which installs scripts in a 'bin' subdir. Fixes #21161 --- .../001-use-linux-virtualenv-dirs.patch | 19 ++++++++++++++++++ mingw-w64-python-pre-commit/PKGBUILD | 20 +++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 mingw-w64-python-pre-commit/001-use-linux-virtualenv-dirs.patch diff --git a/mingw-w64-python-pre-commit/001-use-linux-virtualenv-dirs.patch b/mingw-w64-python-pre-commit/001-use-linux-virtualenv-dirs.patch new file mode 100644 index 0000000000..21431adcae --- /dev/null +++ b/mingw-w64-python-pre-commit/001-use-linux-virtualenv-dirs.patch @@ -0,0 +1,19 @@ +--- pre_commit-3.7.1/pre_commit/languages/python.py.orig 2024-08-05 11:01:55.206420600 +0200 ++++ pre_commit-3.7.1/pre_commit/languages/python.py 2024-08-05 10:53:15.318707500 +0200 +@@ -4,6 +4,7 @@ + import functools + import os + import sys ++import sysconfig + from collections.abc import Generator + from collections.abc import Sequence + +@@ -48,7 +49,7 @@ + + def bin_dir(venv: str) -> str: + """On windows there's a different directory for the virtualenv""" +- bin_part = 'Scripts' if sys.platform == 'win32' else 'bin' ++ bin_part = 'Scripts' if sys.platform == 'win32' and not "mingw" in sysconfig.get_platform() else 'bin' + return os.path.join(venv, bin_part) + + diff --git a/mingw-w64-python-pre-commit/PKGBUILD b/mingw-w64-python-pre-commit/PKGBUILD index 066bffc092..17a58a6178 100644 --- a/mingw-w64-python-pre-commit/PKGBUILD +++ b/mingw-w64-python-pre-commit/PKGBUILD @@ -26,10 +26,26 @@ makedepends=("${MINGW_PACKAGE_PREFIX}-python-build" "${MINGW_PACKAGE_PREFIX}-python-setuptools" "${MINGW_PACKAGE_PREFIX}-python-wheel") options=('!strip') -source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname/-/_}-${pkgver}.tar.gz") -sha256sums=('8ca3ad567bc78a4972a3f1a477e94a79d4597e8140a6e0b651c5e33899c3654a') +source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname/-/_}-${pkgver}.tar.gz" + '001-use-linux-virtualenv-dirs.patch') +sha256sums=('8ca3ad567bc78a4972a3f1a477e94a79d4597e8140a6e0b651c5e33899c3654a' + '9d91c936d7b7449ebbcd3ce841810ae6875f82d2d0366024368d923968c36304') + +# Helper macro to apply patches +apply_patch_with_msg() { + for _patch in "$@" + do + msg2 "Applying $_patch" + patch -Np1 -i "${srcdir}/$_patch" + done +} prepare() { + cd "${srcdir}/${_realname/-/_}-${pkgver}" + apply_patch_with_msg \ + 001-use-linux-virtualenv-dirs.patch + + cd "${srcdir}" rm -rf python-build-${MSYSTEM} | true cp -r "${_realname/-/_}-$pkgver" "python-build-${MSYSTEM}" } From 1b329e14e877fc0d3135af412d79bc340be6be81 Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Mon, 5 Aug 2024 21:58:48 +0200 Subject: [PATCH 2/2] bump pkgrel --- mingw-w64-python-pre-commit/PKGBUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mingw-w64-python-pre-commit/PKGBUILD b/mingw-w64-python-pre-commit/PKGBUILD index 17a58a6178..652101609f 100644 --- a/mingw-w64-python-pre-commit/PKGBUILD +++ b/mingw-w64-python-pre-commit/PKGBUILD @@ -4,7 +4,7 @@ _realname=pre-commit pkgbase=mingw-w64-python-${_realname} pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}") pkgver=3.7.1 -pkgrel=2 +pkgrel=3 pkgdesc="A framework for managing and maintaining multi-language pre-commit hooks. (mingw-w64)" arch=('any') mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')