summary refs log tree commit diff
path: root/pkgs/development/python-modules
diff options
context:
space:
mode:
authorBenjamin Staffin <benley@gmail.com>2019-01-18 21:01:19 -0500
committerGitHub <noreply@github.com>2019-01-18 21:01:19 -0500
commitc7677d93008450543ab8639dc08e75084ec9639d (patch)
treed22d3d973ecf039b55293126e3ee0f39a674f251 /pkgs/development/python-modules
parent8e20de1d52010d716ddb4858f5c53b566e09d313 (diff)
downloadnixpkgs-c7677d93008450543ab8639dc08e75084ec9639d.tar
nixpkgs-c7677d93008450543ab8639dc08e75084ec9639d.tar.gz
nixpkgs-c7677d93008450543ab8639dc08e75084ec9639d.tar.bz2
nixpkgs-c7677d93008450543ab8639dc08e75084ec9639d.tar.lz
nixpkgs-c7677d93008450543ab8639dc08e75084ec9639d.tar.xz
nixpkgs-c7677d93008450543ab8639dc08e75084ec9639d.tar.zst
nixpkgs-c7677d93008450543ab8639dc08e75084ec9639d.zip
pythonPackages.jq: init at 0.1.6 (#54014)
Diffstat (limited to 'pkgs/development/python-modules')
-rw-r--r--pkgs/development/python-modules/jq/default.nix27
-rw-r--r--pkgs/development/python-modules/jq/jq-py-setup.patch130
2 files changed, 157 insertions, 0 deletions
diff --git a/pkgs/development/python-modules/jq/default.nix b/pkgs/development/python-modules/jq/default.nix
new file mode 100644
index 00000000000..adcdd2b9d82
--- /dev/null
+++ b/pkgs/development/python-modules/jq/default.nix
@@ -0,0 +1,27 @@
+{ buildPythonPackage, fetchPypi, lib, cython, jq }:
+
+buildPythonPackage rec {
+  pname = "jq";
+  version = "0.1.6";
+
+  srcs = fetchPypi {
+    inherit pname version;
+    sha256 = "34bdf9f9e49e522e1790afc03f3584c6b57329215ea0567fb2157867d6d6f602";
+  };
+  patches = [ ./jq-py-setup.patch ];
+
+  nativeBuildInputs = [ cython ];
+
+  preBuild = ''
+    cython jq.pyx
+  '';
+
+  buildInputs = [ jq ];
+
+  meta = {
+    description = "Python bindings for jq, the flexible JSON processor";
+    homepage = "https://github.com/mwilliamson/jq.py";
+    license = lib.licenses.bsd2;
+    maintainers = with lib.maintainers; [ benley ];
+  };
+}
diff --git a/pkgs/development/python-modules/jq/jq-py-setup.patch b/pkgs/development/python-modules/jq/jq-py-setup.patch
new file mode 100644
index 00000000000..7d7d825e9f1
--- /dev/null
+++ b/pkgs/development/python-modules/jq/jq-py-setup.patch
@@ -0,0 +1,130 @@
+From 3f369cf8b9f7134d0792f6b141d39b5342a8274f Mon Sep 17 00:00:00 2001
+From: Benjamin Staffin <benley@gmail.com>
+Date: Mon, 14 Jan 2019 17:27:06 -0500
+Subject: [PATCH] Vastly simplify setup.py for distro compatibility
+
+---
+ setup.py | 81 +-------------------------------------------------------
+ 1 file changed, 1 insertion(+), 80 deletions(-)
+
+diff --git a/setup.py b/setup.py
+index 77933f2..2b71e25 100644
+--- a/setup.py
++++ b/setup.py
+@@ -1,10 +1,6 @@
+ #!/usr/bin/env python
+ 
+ import os
+-import platform
+-import subprocess
+-import tarfile
+-import shutil
+ 
+ try:
+     import sysconfig
+@@ -14,88 +10,15 @@ except ImportError:
+ 
+ from setuptools import setup
+ from distutils.extension import Extension
+-from distutils.command.build_ext import build_ext
+-
+-try:
+-    from urllib import urlretrieve
+-except ImportError:
+-    from urllib.request import urlretrieve
+-
+-def path_in_dir(relative_path):
+-    return os.path.abspath(os.path.join(os.path.dirname(__file__), relative_path))
+ 
+ def read(fname):
+     return open(os.path.join(os.path.dirname(__file__), fname)).read()
+ 
+ 
+-jq_lib_tarball_path = path_in_dir("_jq-lib-1.5.tar.gz")
+-jq_lib_dir = path_in_dir("jq-jq-1.5")
+-
+-oniguruma_lib_tarball_path = path_in_dir("_onig-5.9.6.tar.gz")
+-oniguruma_lib_build_dir = path_in_dir("onig-5.9.6")
+-oniguruma_lib_install_dir = path_in_dir("onig-install-5.9.6")
+-
+-class jq_build_ext(build_ext):
+-    def run(self):
+-        self._build_oniguruma()
+-        self._build_libjq()
+-        build_ext.run(self)
+-    
+-    def _build_oniguruma(self):
+-        self._build_lib(
+-            source_url="https://github.com/kkos/oniguruma/releases/download/v5.9.6/onig-5.9.6.tar.gz",
+-            tarball_path=oniguruma_lib_tarball_path,
+-            lib_dir=oniguruma_lib_build_dir,
+-            commands=[
+-                ["./configure", "CFLAGS=-fPIC", "--prefix=" + oniguruma_lib_install_dir],
+-                ["make"],
+-                ["make", "install"],
+-            ])
+-        
+-    
+-    def _build_libjq(self):
+-        self._build_lib(
+-            source_url="https://github.com/stedolan/jq/archive/jq-1.5.tar.gz",
+-            tarball_path=jq_lib_tarball_path,
+-            lib_dir=jq_lib_dir,
+-            commands=[
+-                ["autoreconf", "-i"],
+-                ["./configure", "CFLAGS=-fPIC", "--disable-maintainer-mode", "--with-oniguruma=" + oniguruma_lib_install_dir],
+-                ["make"],
+-            ])
+-        
+-    def _build_lib(self, source_url, tarball_path, lib_dir, commands):
+-        self._download_tarball(source_url, tarball_path)
+-
+-        macosx_deployment_target = sysconfig.get_config_var("MACOSX_DEPLOYMENT_TARGET")
+-        if macosx_deployment_target:
+-            os.environ['MACOSX_DEPLOYMENT_TARGET'] = macosx_deployment_target
+-
+-        def run_command(args):
+-            print("Executing: %s" % ' '.join(args))
+-            subprocess.check_call(args, cwd=lib_dir)
+-            
+-        for command in commands:
+-            run_command(command)
+-    
+-    def _download_tarball(self, source_url, tarball_path):
+-        if os.path.exists(tarball_path):
+-            os.unlink(tarball_path)
+-        urlretrieve(source_url, tarball_path)
+-        
+-        if os.path.exists(jq_lib_dir):
+-            shutil.rmtree(jq_lib_dir)
+-        tarfile.open(tarball_path, "r:gz").extractall(path_in_dir("."))
+-
+-
+ jq_extension = Extension(
+     "jq",
+     sources=["jq.c"],
+-    include_dirs=[jq_lib_dir],
+-    extra_objects=[
+-        os.path.join(jq_lib_dir, ".libs/libjq.a"),
+-        os.path.join(oniguruma_lib_install_dir, "lib/libonig.a"),
+-    ],
++    libraries=["jq"],
+ )
+ 
+ setup(
+@@ -107,7 +30,6 @@ setup(
+     url='http://github.com/mwilliamson/jq.py',
+     license='BSD 2-Clause',
+     ext_modules = [jq_extension],
+-    cmdclass={"build_ext": jq_build_ext},
+     classifiers=[
+         'Development Status :: 4 - Beta',
+         'Intended Audience :: Developers',
+@@ -123,4 +45,3 @@ setup(
+         'Programming Language :: Python :: 3.5',
+     ],
+ )
+-
+-- 
+2.19.2
+