Add patches to fix build on s390x and ppc64le

This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2019-07-12 19:03:22 +02:00
commit 0b2db4436c
4 changed files with 150 additions and 0 deletions

View file

@ -0,0 +1,69 @@
From b92e5f1264fb53bbaa975c15682cb2293a16508b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Fri, 12 Jul 2019 18:40:47 +0200
Subject: [PATCH 1/2] blosc_extenion: constify char pointers for Py_BuildValue
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This fixes warnings from the compiler:
blosc/blosc_extension.c: In function PyBlosc_compressor_list:
blosc/blosc_extension.c:104:8: warning: assignment discards const qualifier from pointer target type [-Wdiscarded-qualifiers]
104 | list = blosc_list_compressors();
| ^
blosc/blosc_extension.c: In function PyBlosc_code_to_name:
blosc/blosc_extension.c:123:40: warning: passing argument 2 of blosc_compcode_to_compname from incompatible pointer type [-Wincompatible-pointer-types]
123 | if (blosc_compcode_to_compname(code, &name) < 0)
| ^~~~~
| |
| char **
In file included from blosc/blosc_extension.c:13:
/usr/include/blosc.h:389:72: note: expected const char ** but argument is of type char **
389 | BLOSC_EXPORT int blosc_compcode_to_compname(int compcode, const char **compname);
| ~~~~~~~~~~~~~^~~~~~~~
blosc/blosc_extension.c: In function PyBlosc_get_clib:
blosc/blosc_extension.c:345:8: warning: assignment discards const qualifier from pointer target type [-Wdiscarded-qualifiers]
345 | clib = blosc_cbuffer_complib(input);
| ^
https://docs.python.org/3/c-api/arg.html#c.Py_BuildValue
> When memory buffers are passed as parameters to supply data to build
> objects, as for the s and s# formats, the required data is
> copied. Buffers provided by the caller are never referenced by the
> objects created by Py_BuildValue().
---
blosc/blosc_extension.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/blosc/blosc_extension.c b/blosc/blosc_extension.c
index 870581a217..237f2e46a7 100644
--- a/blosc/blosc_extension.c
+++ b/blosc/blosc_extension.c
@@ -99,7 +99,7 @@ PyDoc_STRVAR(compressor_list__doc__,
static PyObject *
PyBlosc_compressor_list(PyObject *self)
{
- char *list;
+ const char *list;
list = blosc_list_compressors();
@@ -115,7 +115,7 @@ static PyObject *
PyBlosc_code_to_name(PyObject *self, PyObject *args)
{
int code;
- char *name;
+ const char *name;
if (!PyArg_ParseTuple(args, "i:code_to_name", &code))
return NULL;
@@ -341,7 +341,7 @@ PyBlosc_get_clib(PyObject *self, PyObject *args)
{
void *input;
size_t cbytes;
- char *clib;
+ const char *clib;
/* require Python string object, typesize, clevel and shuffle agrs */
if (!PyArg_ParseTuple(args, "s#:get_clib", &input, &cbytes))

View file

@ -0,0 +1,38 @@
From b4bac67a4ad842c76e4ec10cbee8dac01abcfad0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Fri, 12 Jul 2019 18:46:44 +0200
Subject: [PATCH 2/2] setup.py: unbreak build on architectures which don't have
cpu flags
ppc64le and s390x would fail with:
BUILDSTDERR: Traceback (most recent call last):
BUILDSTDERR: File "setup.py", line 241, in <module>
BUILDSTDERR: if 'DISABLE_BLOSC_SSE2' not in os.environ and (cpu_info != None) and ('sse2' in cpu_info['flags']):
BUILDSTDERR: KeyError: 'flags'
BUILDSTDERR: error: Bad exit status from /var/tmp/rpm-tmp.xbprqV (%install)
---
setup.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/setup.py b/setup.py
index 1d8ebe86eb..468b970588 100644
--- a/setup.py
+++ b/setup.py
@@ -238,7 +238,7 @@ if __name__ == '__main__':
# Guess SSE2 or AVX2 capabilities
# SSE2
- if 'DISABLE_BLOSC_SSE2' not in os.environ and (cpu_info != None) and ('sse2' in cpu_info['flags']):
+ if 'DISABLE_BLOSC_SSE2' not in os.environ and cpu_info != None and 'sse2' in cpu_info.get('flags', {}):
print('SSE2 detected')
CFLAGS.append('-DSHUFFLE_SSE2_ENABLED')
sources += [f for f in glob('c-blosc/blosc/*.c') if 'sse2' in f]
@@ -247,7 +247,7 @@ if __name__ == '__main__':
elif os.name == 'nt':
def_macros += [('__SSE2__', 1)]
# AVX2
- if 'DISABLE_BLOSC_AVX2' not in os.environ and (cpu_info != None) and ('avx2' in cpu_info['flags']):
+ if 'DISABLE_BLOSC_AVX2' not in os.environ and cpu_info != None and 'sse2' in cpu_info.get('flags', {}):
if os.name == 'posix':
print("AVX2 detected")
avx2_defs = {

View file

@ -0,0 +1,38 @@
From 8c8cf1a2a09ba8b6b02be5a69bb8cbf5ff2a4838 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Fri, 12 Jul 2019 18:54:36 +0200
Subject: [PATCH] setup.py: catch import error for cpuinfo
BUILDSTDERR: Traceback (most recent call last):
BUILDSTDERR: File "setup.py", line 112, in <module>
BUILDSTDERR: import cpuinfo
BUILDSTDERR: File "/usr/lib/python3.7/site-packages/cpuinfo/__init__.py", line 7, in <module>
BUILDSTDERR: from cpuinfo.cpuinfo import *
BUILDSTDERR: File "/usr/lib/python3.7/site-packages/cpuinfo/cpuinfo.py", line 2256, in <module>
BUILDSTDERR: _check_arch()
BUILDSTDERR: File "/usr/lib/python3.7/site-packages/cpuinfo/cpuinfo.py", line 231, in _check_arch
BUILDSTDERR: raise Exception("py-cpuinfo currently only works on X86 and some PPC and ARM CPUs.")
BUILDSTDERR: Exception: py-cpuinfo currently only works on X86 and some PPC and ARM CPUs.
---
setup.py | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/setup.py b/setup.py
index 468b970588..2508a94fbe 100644
--- a/setup.py
+++ b/setup.py
@@ -109,8 +109,12 @@ if __name__ == '__main__':
with io.open('README.rst', encoding='utf-8') as f:
long_description = f.read()
- import cpuinfo
- cpu_info = cpuinfo.get_cpu_info()
+ try:
+ import cpuinfo
+ cpu_info = cpuinfo.get_cpu_info()
+ except Exception:
+ # newer cpuinfo versions fail to import on unsupported architectures
+ cpu_info = None
########### Check versions ##########
def exit_with_error(message):

View file

@ -6,6 +6,11 @@ License: MIT
URL: https://github.com/Blosc/python-blosc
Source0: https://github.com/Blosc/python-blosc/archive/v%{version}/blosc-%{version}.tar.gz
# https://github.com/Blosc/python-blosc/pull/200
Patch1: 0001-blosc_extenion-constify-char-pointers-for-Py_BuildVa.patch
Patch2: 0002-setup.py-unbreak-build-on-architectures-which-don-t-.patch
Patch3: 0003-setup.py-catch-import-error-for-cpuinfo.patch
BuildRequires: gcc
BuildRequires: blosc-devel >= 1.16.0
BuildRequires: numpy