From 4932480af9989f2d0e27f48d9bd299a886d92831 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Fri, 29 Aug 2025 00:45:58 +0200 Subject: [PATCH] vim-vint: fix --- pkgs/by-name/vi/vim-vint/package.nix | 46 ++++++++++++------- .../vi/vim-vint/remove-pkg-resources.patch | 28 +++++++++++ 2 files changed, 58 insertions(+), 16 deletions(-) create mode 100644 pkgs/by-name/vi/vim-vint/remove-pkg-resources.patch diff --git a/pkgs/by-name/vi/vim-vint/package.nix b/pkgs/by-name/vi/vim-vint/package.nix index 2b5006e5ee91..b1bf0757f078 100644 --- a/pkgs/by-name/vi/vim-vint/package.nix +++ b/pkgs/by-name/vi/vim-vint/package.nix @@ -2,6 +2,8 @@ lib, python3Packages, fetchFromGitHub, + replaceVars, + versionCheckHook, }: python3Packages.buildPythonApplication rec { @@ -16,21 +18,16 @@ python3Packages.buildPythonApplication rec { hash = "sha256-A0yXDkB/b9kEEXSoLeqVdmdm4p2PYL2QHqbF4FgAn30="; }; - build-system = with python3Packages; [ setuptools ]; - - dependencies = with python3Packages; [ - ansicolor - chardet - pyyaml - setuptools # pkg_resources is imported during runtime + patches = [ + # Otherwise, the following warning appears each time the binary is run: + # UserWarning: pkg_resources is deprecated as an API. + # This leads the `test/acceptance/test_cli.py::TestCLI::*` tests to fail + (replaceVars ./remove-pkg-resources.patch { + inherit version; + }) ]; - nativeCheckInputs = with python3Packages; [ - pytestCheckHook - pytest-cov-stub - ]; - - preCheck = '' + postPatch = '' substituteInPlace \ test/acceptance/test_cli.py \ test/acceptance/test_cli_vital.py \ @@ -39,12 +36,29 @@ python3Packages.buildPythonApplication rec { "cmd = ['$out/bin/vint'" ''; - meta = with lib; { + build-system = with python3Packages; [ setuptools ]; + + dependencies = with python3Packages; [ + ansicolor + chardet + pyyaml + ]; + + nativeCheckInputs = [ + versionCheckHook + ] + ++ (with python3Packages; [ + pytestCheckHook + pytest-cov-stub + ]); + versionCheckProgramArg = "--version"; + + meta = { description = "Fast and Highly Extensible Vim script Language Lint implemented by Python"; homepage = "https://github.com/Kuniwak/vint"; - license = licenses.mit; + license = lib.licenses.mit; mainProgram = "vint"; maintainers = [ ]; - platforms = platforms.all; + platforms = lib.platforms.all; }; } diff --git a/pkgs/by-name/vi/vim-vint/remove-pkg-resources.patch b/pkgs/by-name/vi/vim-vint/remove-pkg-resources.patch new file mode 100644 index 000000000000..2613a1ef6a72 --- /dev/null +++ b/pkgs/by-name/vi/vim-vint/remove-pkg-resources.patch @@ -0,0 +1,28 @@ +diff --git a/vint/linting/cli.py b/vint/linting/cli.py +index 55db52e..97f33e1 100644 +--- a/vint/linting/cli.py ++++ b/vint/linting/cli.py +@@ -1,7 +1,6 @@ + import sys + from argparse import ArgumentParser + from pathlib import PosixPath +-import pkg_resources + import logging + + from vint.linting.linter import Linter +@@ -150,14 +149,7 @@ class CLI(object): + + + def _get_version(self): +- # In unit tests, pkg_resources cannot find vim-vint. +- # So, I decided to return dummy version +- try: +- version = pkg_resources.require('vim-vint')[0].version +- except pkg_resources.DistributionNotFound: +- version = 'test_mode' +- +- return version ++ return "@version@" + + + def _adjust_log_level(self, env):