lol

python310Packages.jq: 1.2.3 -> 1.3.0

+39 -62
+17 -7
pkgs/development/python-modules/jq/default.nix
··· 1 - { buildPythonPackage, fetchPypi, lib, jq }: 1 + { lib, buildPythonPackage, fetchFromGitHub, cython, jq, pytestCheckHook }: 2 2 3 3 buildPythonPackage rec { 4 4 pname = "jq"; 5 - version = "1.2.3"; 5 + version = "1.3.0"; 6 6 7 - src = fetchPypi { 8 - inherit pname version; 9 - sha256 = "sha256-15bXqaa6c6RMoHKqUAcOhPrhMBbqYHrDdnZAaFaHElc="; 7 + src = fetchFromGitHub { 8 + owner = "mwilliamson"; 9 + repo = "jq.py"; 10 + rev = version; 11 + sha256 = "sha256-1EQm5ShjFHbO1IO5QD42fsGHFGDBrJulLrcl+WeU7wo="; 10 12 }; 11 13 12 14 patches = [ ··· 14 16 ./jq-py-setup.patch 15 17 ]; 16 18 19 + nativeBuildInputs = [ cython ]; 20 + 17 21 buildInputs = [ jq ]; 18 22 19 - # no tests executed 20 - doCheck = false; 23 + preBuild = '' 24 + cython jq.pyx 25 + ''; 26 + 27 + checkInputs = [ 28 + pytestCheckHook 29 + ]; 30 + 21 31 pythonImportsCheck = [ "jq" ]; 22 32 23 33 meta = {
+22 -55
pkgs/development/python-modules/jq/jq-py-setup.patch
··· 1 - From bef841b73ba7c9a79211146798ac888fce9bb55a Mon Sep 17 00:00:00 2001 2 - From: "Robert T. McGibbon" <rmcgibbo@gmail.com> 3 - Date: Fri, 7 May 2021 19:14:20 -0400 4 - Subject: [PATCH 1/1] Vastly simplify setup.py for distro compatibility 5 - 6 - --- 7 - setup.py | 98 +------------------------------------------------------- 8 - 1 file changed, 1 insertion(+), 97 deletions(-) 9 - 10 1 diff --git a/setup.py b/setup.py 11 - index 663792c..3ebcabe 100644 2 + index 01cc813..15e9048 100644 12 3 --- a/setup.py 13 4 +++ b/setup.py 14 - @@ -1,113 +1,19 @@ 5 + @@ -1,97 +1,18 @@ 15 6 #!/usr/bin/env python 16 7 17 8 import os ··· 20 11 -import shutil 21 12 -import sysconfig 22 13 23 - -import requests 24 14 from setuptools import setup 25 15 -from setuptools.command.build_ext import build_ext 26 16 from setuptools.extension import Extension 27 17 28 - 29 - -def urlretrieve(source_url, destination_path): 30 - - response = requests.get(source_url, stream=True) 31 - - if response.status_code != 200: 32 - - raise Exception("status code was: {}".format(response.status_code)) 33 18 - 34 - - with open(destination_path, "wb") as fileobj: 35 - - for chunk in response.iter_content(chunk_size=128): 36 - - fileobj.write(chunk) 37 - - 38 - -def path_in_dir(relative_path): 19 + -def _path_in_dir(relative_path): 39 20 - return os.path.abspath(os.path.join(os.path.dirname(__file__), relative_path)) 40 21 - 41 - -def dependency_path(relative_path): 42 - - return os.path.join(path_in_dir("_deps"), relative_path) 22 + -def _dep_source_path(relative_path): 23 + - return os.path.join(_path_in_dir("deps"), relative_path) 24 + - 25 + -def _dep_build_path(relative_path): 26 + - return os.path.join(_path_in_dir("_deps/build"), relative_path) 43 27 - 44 - def read(fname): 28 + def _read(fname): 45 29 return open(os.path.join(os.path.dirname(__file__), fname)).read() 46 30 47 31 48 - -jq_lib_tarball_path = dependency_path("jq-lib-1.6.tar.gz") 49 - -jq_lib_dir = dependency_path("jq-1.6") 32 + -jq_lib_tarball_path = _dep_source_path("jq-1.6.tar.gz") 33 + -jq_lib_dir = _dep_build_path("jq-1.6") 50 34 - 51 35 -oniguruma_version = "6.9.4" 52 - -oniguruma_lib_tarball_path = dependency_path("onig-{}.tar.gz".format(oniguruma_version)) 53 - -oniguruma_lib_build_dir = dependency_path("onig-{}".format(oniguruma_version)) 54 - -oniguruma_lib_install_dir = dependency_path("onig-install-{}".format(oniguruma_version)) 36 + -oniguruma_lib_tarball_path = _dep_source_path("onig-{}.tar.gz".format(oniguruma_version)) 37 + -oniguruma_lib_build_dir = _dep_build_path("onig-{}".format(oniguruma_version)) 38 + -oniguruma_lib_install_dir = _dep_build_path("onig-install-{}".format(oniguruma_version)) 55 39 - 56 40 -class jq_build_ext(build_ext): 57 41 - def run(self): 58 - - if not os.path.exists(dependency_path(".")): 59 - - os.makedirs(dependency_path(".")) 42 + - if not os.path.exists(_dep_build_path(".")): 43 + - os.makedirs(_dep_build_path(".")) 60 44 - self._build_oniguruma() 61 45 - self._build_libjq() 62 46 - build_ext.run(self) 63 47 - 64 48 - def _build_oniguruma(self): 65 49 - self._build_lib( 66 - - source_url="https://github.com/kkos/oniguruma/releases/download/v{0}/onig-{0}.tar.gz".format(oniguruma_version), 67 50 - tarball_path=oniguruma_lib_tarball_path, 68 51 - lib_dir=oniguruma_lib_build_dir, 69 52 - commands=[ ··· 75 58 - 76 59 - def _build_libjq(self): 77 60 - self._build_lib( 78 - - source_url="https://github.com/stedolan/jq/releases/download/jq-1.6/jq-1.6.tar.gz", 79 61 - tarball_path=jq_lib_tarball_path, 80 62 - lib_dir=jq_lib_dir, 81 63 - commands=[ ··· 83 65 - ["make"], 84 66 - ]) 85 67 - 86 - - def _build_lib(self, source_url, tarball_path, lib_dir, commands): 87 - - self._download_tarball( 88 - - source_url=source_url, 68 + - def _build_lib(self, tarball_path, lib_dir, commands): 69 + - self._extract_tarball( 89 70 - tarball_path=tarball_path, 90 71 - lib_dir=lib_dir, 91 72 - ) ··· 101 82 - for command in commands: 102 83 - run_command(command) 103 84 - 104 - - def _download_tarball(self, source_url, tarball_path, lib_dir): 105 - - if os.path.exists(tarball_path): 106 - - os.unlink(tarball_path) 107 - - print("Downloading {}".format(source_url)) 108 - - urlretrieve(source_url, tarball_path) 109 - - print("Downloaded {}".format(source_url)) 110 - - 85 + - def _extract_tarball(self, tarball_path, lib_dir): 111 86 - if os.path.exists(lib_dir): 112 87 - shutil.rmtree(lib_dir) 113 - - tarfile.open(tarball_path, "r:gz").extractall(dependency_path(".")) 88 + - tarfile.open(tarball_path, "r:gz").extractall(_dep_build_path(".")) 114 89 - 115 90 - 116 91 jq_extension = Extension( ··· 126 101 ) 127 102 128 103 setup( 129 - @@ -120,7 +26,6 @@ setup( 130 - python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*', 104 + @@ -104,7 +25,6 @@ def _extract_tarball(self, tarball_path, lib_dir): 105 + python_requires='>=3.5', 131 106 license='BSD 2-Clause', 132 107 ext_modules = [jq_extension], 133 108 - cmdclass={"build_ext": jq_build_ext}, 134 109 classifiers=[ 135 110 'Development Status :: 5 - Production/Stable', 136 111 'Intended Audience :: Developers', 137 - @@ -137,4 +42,3 @@ setup( 138 - 'Programming Language :: Python :: 3.9', 139 - ], 140 - ) 141 - - 142 - -- 143 - 2.29.3 144 -