Merge pull request #21574 from sdegrande/fix-virtualenv-dirs

python-pre-commit: Fix installation of python pre-commit hooks
This commit is contained in:
Christoph Reiter
2024-08-05 22:06:29 +02:00
committed by GitHub
2 changed files with 38 additions and 3 deletions

View File

@@ -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)

View File

@@ -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')
@@ -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}"
}