python3Packages.jq: 0.1.8 -> 1.0.2

This commit is contained in:
William Kral 2020-09-08 22:18:08 -07:00 committed by Jon
parent b5118540bf
commit cf54ef99b6
2 changed files with 67 additions and 56 deletions

View File

@ -1,21 +1,15 @@
{ buildPythonPackage, fetchPypi, lib, cython, jq }: { buildPythonPackage, fetchPypi, lib, jq }:
buildPythonPackage rec { buildPythonPackage rec {
pname = "jq"; pname = "jq";
version = "0.1.8"; version = "1.0.2";
src = fetchPypi { src = fetchPypi {
inherit pname version; inherit pname version;
sha256 = "9b6bb376237133080185ab556ca2a724e8be5b31946eb2053d4a1f17ae9df9a8"; sha256 = "9fe6ce07bc8d209c385d8ba132a2971c69aef015103c46bea87a73a16c5ec147";
}; };
patches = [ ./jq-py-setup.patch ]; patches = [ ./jq-py-setup.patch ];
nativeBuildInputs = [ cython ];
preBuild = ''
cython jq.pyx
'';
buildInputs = [ jq ]; buildInputs = [ jq ];
meta = { meta = {

View File

@ -1,61 +1,69 @@
From 3f369cf8b9f7134d0792f6b141d39b5342a8274f Mon Sep 17 00:00:00 2001 From 968ddf2bd773e800e46737fced743bd00af9aa0d Mon Sep 17 00:00:00 2001
From: Benjamin Staffin <benley@gmail.com> From: William Kral <william.kral@gmail.com>
Date: Mon, 14 Jan 2019 17:27:06 -0500 Date: Tue, 8 Sep 2020 22:04:24 -0700
Subject: [PATCH] Vastly simplify setup.py for distro compatibility Subject: [PATCH] Vastly simplify setup.py for distro compatibility
--- ---
setup.py | 81 +------------------------------------------------------- setup.py | 101 ++-----------------------------------------------------
1 file changed, 1 insertion(+), 80 deletions(-) 1 file changed, 2 insertions(+), 99 deletions(-)
diff --git a/setup.py b/setup.py diff --git a/setup.py b/setup.py
index 77933f2..2b71e25 100644 index cb63f60..87380ed 100644
--- a/setup.py --- a/setup.py
+++ b/setup.py +++ b/setup.py
@@ -1,10 +1,6 @@ @@ -1,114 +1,19 @@
#!/usr/bin/env python #!/usr/bin/env python
import os import os
-import platform
-import subprocess -import subprocess
-import tarfile -import tarfile
-import shutil -import shutil
-import sysconfig
try: -import requests
import sysconfig
@@ -14,88 +10,15 @@ except ImportError:
from setuptools import setup from setuptools import setup
from distutils.extension import Extension -from setuptools.command.build_ext import build_ext
-from distutils.command.build_ext import build_ext from setuptools.extension import Extension
-def urlretrieve(source_url, destination_path):
- response = requests.get(source_url, stream=True)
- if response.status_code != 200:
- raise Exception("status code was: {}".format(response.status_code))
- -
-try: - with open(destination_path, "wb") as fileobj:
- from urllib import urlretrieve - for chunk in response.iter_content(chunk_size=128):
-except ImportError: - fileobj.write(chunk)
- from urllib.request import urlretrieve
- -
-def path_in_dir(relative_path): -def path_in_dir(relative_path):
- return os.path.abspath(os.path.join(os.path.dirname(__file__), relative_path)) - return os.path.abspath(os.path.join(os.path.dirname(__file__), relative_path))
-
-def dependency_path(relative_path):
- return os.path.join(path_in_dir("_deps"), relative_path)
-
def read(fname): def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read() 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_tarball_path = dependency_path("jq-lib-1.6.tar.gz")
-jq_lib_dir = path_in_dir("jq-jq-1.5") -jq_lib_dir = dependency_path("jq-1.6")
- -
-oniguruma_lib_tarball_path = path_in_dir("_onig-5.9.6.tar.gz") -oniguruma_version = "6.9.4"
-oniguruma_lib_build_dir = path_in_dir("onig-5.9.6") -oniguruma_lib_tarball_path = dependency_path("onig-{}.tar.gz".format(oniguruma_version))
-oniguruma_lib_install_dir = path_in_dir("onig-install-5.9.6") -oniguruma_lib_build_dir = dependency_path("onig-{}".format(oniguruma_version))
-oniguruma_lib_install_dir = dependency_path("onig-install-{}".format(oniguruma_version))
- -
-class jq_build_ext(build_ext): -class jq_build_ext(build_ext):
- def run(self): - def run(self):
- if not os.path.exists(dependency_path(".")):
- os.makedirs(dependency_path("."))
- self._build_oniguruma() - self._build_oniguruma()
- self._build_libjq() - self._build_libjq()
- build_ext.run(self) - build_ext.run(self)
- -
- def _build_oniguruma(self): - def _build_oniguruma(self):
- self._build_lib( - self._build_lib(
- source_url="https://github.com/kkos/oniguruma/releases/download/v5.9.6/onig-5.9.6.tar.gz", - source_url="https://github.com/kkos/oniguruma/releases/download/v{0}/onig-{0}.tar.gz".format(oniguruma_version),
- tarball_path=oniguruma_lib_tarball_path, - tarball_path=oniguruma_lib_tarball_path,
- lib_dir=oniguruma_lib_build_dir, - lib_dir=oniguruma_lib_build_dir,
- commands=[ - commands=[
@ -63,11 +71,11 @@ index 77933f2..2b71e25 100644
- ["make"], - ["make"],
- ["make", "install"], - ["make", "install"],
- ]) - ])
- -
- -
- def _build_libjq(self): - def _build_libjq(self):
- self._build_lib( - self._build_lib(
- source_url="https://github.com/stedolan/jq/archive/jq-1.5.tar.gz", - source_url="https://github.com/stedolan/jq/releases/download/jq-1.6/jq-1.6.tar.gz",
- tarball_path=jq_lib_tarball_path, - tarball_path=jq_lib_tarball_path,
- lib_dir=jq_lib_dir, - lib_dir=jq_lib_dir,
- commands=[ - commands=[
@ -75,9 +83,13 @@ index 77933f2..2b71e25 100644
- ["./configure", "CFLAGS=-fPIC", "--disable-maintainer-mode", "--with-oniguruma=" + oniguruma_lib_install_dir], - ["./configure", "CFLAGS=-fPIC", "--disable-maintainer-mode", "--with-oniguruma=" + oniguruma_lib_install_dir],
- ["make"], - ["make"],
- ]) - ])
- -
- def _build_lib(self, source_url, tarball_path, lib_dir, commands): - def _build_lib(self, source_url, tarball_path, lib_dir, commands):
- self._download_tarball(source_url, tarball_path) - self._download_tarball(
- source_url=source_url,
- tarball_path=tarball_path,
- lib_dir=lib_dir,
- )
- -
- macosx_deployment_target = sysconfig.get_config_var("MACOSX_DEPLOYMENT_TARGET") - macosx_deployment_target = sysconfig.get_config_var("MACOSX_DEPLOYMENT_TARGET")
- if macosx_deployment_target: - if macosx_deployment_target:
@ -86,45 +98,50 @@ index 77933f2..2b71e25 100644
- def run_command(args): - def run_command(args):
- print("Executing: %s" % ' '.join(args)) - print("Executing: %s" % ' '.join(args))
- subprocess.check_call(args, cwd=lib_dir) - subprocess.check_call(args, cwd=lib_dir)
- -
- for command in commands: - for command in commands:
- run_command(command) - run_command(command)
- -
- def _download_tarball(self, source_url, tarball_path): - def _download_tarball(self, source_url, tarball_path, lib_dir):
- if os.path.exists(tarball_path): - if os.path.exists(tarball_path):
- os.unlink(tarball_path) - os.unlink(tarball_path)
- print("Downloading {}".format(source_url))
- urlretrieve(source_url, tarball_path) - urlretrieve(source_url, tarball_path)
- - print("Downloaded {}".format(source_url))
- if os.path.exists(jq_lib_dir): -
- shutil.rmtree(jq_lib_dir) - if os.path.exists(lib_dir):
- tarfile.open(tarball_path, "r:gz").extractall(path_in_dir(".")) - shutil.rmtree(lib_dir)
- tarfile.open(tarball_path, "r:gz").extractall(dependency_path("."))
- -
- -
jq_extension = Extension( jq_extension = Extension(
"jq", "jq",
sources=["jq.c"], sources=["jq.c"],
- include_dirs=[jq_lib_dir], - include_dirs=[os.path.join(jq_lib_dir, "src")],
- extra_link_args=["-lm"],
- extra_objects=[ - extra_objects=[
- os.path.join(jq_lib_dir, ".libs/libjq.a"), - os.path.join(jq_lib_dir, ".libs/libjq.a"),
- os.path.join(oniguruma_lib_install_dir, "lib/libonig.a"), - os.path.join(oniguruma_lib_install_dir, "lib/libonig.a"),
- ], - ],
+ libraries=["jq"], + libraries=["jq"]
) )
setup( setup(
@@ -107,7 +30,6 @@ setup( @@ -120,8 +25,7 @@ setup(
url='https://github.com/mwilliamson/jq.py', url='http://github.com/mwilliamson/jq.py',
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',
license='BSD 2-Clause', license='BSD 2-Clause',
ext_modules = [jq_extension], - ext_modules = [jq_extension],
- cmdclass={"build_ext": jq_build_ext}, - cmdclass={"build_ext": jq_build_ext},
+ ext_modules=[jq_extension],
classifiers=[ classifiers=[
'Development Status :: 4 - Beta', 'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers', 'Intended Audience :: Developers',
@@ -123,4 +45,3 @@ setup( @@ -137,4 +41,3 @@ setup(
'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.8',
], ],
) )
- -
-- --
2.19.2 2.28.0