Skip to content
Commits on Source (6)
python-hdf4 (0.9.2-1) unstable; urgency=medium
* New upstream release.
* debian/patches
- drop 0001-Use-hdf4-alt.patch: no longer necessary
- drop 0002-Do-not-pass-empty-arguments-to-setup.patch:
no longer necessary
-- Antonio Valentino <antonio.valentino@tiscali.it> Wed, 20 Feb 2019 07:04:19 +0000
python-hdf4 (0.9.1-1) unstable; urgency=medium
* Initial version (Closes: #917254)
......
From: Antonio Valentino <antonio.valentino@tiscali.it>
Date: Mon, 24 Dec 2018 19:02:31 +0000
Subject: Use hdf4-alt
---
setup.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/setup.py b/setup.py
index 77987e4..e847a51 100644
--- a/setup.py
+++ b/setup.py
@@ -125,7 +125,7 @@ if sys.platform == 'win32':
if sys.platform == 'win32':
libraries = ["hm423m", "hd423m", "xdr_for_dll" ]
else:
- libraries = ["mfhdf", "df"]
+ libraries = ["mfhdfalt", "dfalt"]
if szip_installed:
extra_compile_args = []
From: Antonio Valentino <antonio.valentino@tiscali.it>
Date: Sun, 30 Dec 2018 16:37:26 +0000
Subject: Do not pass empty arguments to setup
---
setup.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/setup.py b/setup.py
index e847a51..d8d2570 100644
--- a/setup.py
+++ b/setup.py
@@ -148,7 +148,7 @@ _hdfext = Extension('pyhdf._hdfext',
include_dirs = include_dirs,
extra_compile_args = extra_compile_args,
library_dirs = library_dirs,
- extra_link_args=[extra_link_args],
+ extra_link_args=[extra_link_args] if extra_link_args else [],
libraries = libraries,
)
0001-Use-hdf4-alt.patch
0002-Do-not-pass-empty-arguments-to-setup.patch
......@@ -30,9 +30,9 @@ The following packages are required to build and install Python-HDF4:
- `libjpeg <http://www.ijg.org/>`_
On Debian and Debian-based Linux distributions (e.g. Ubuntu), you can install
all the requirements using this command::
all the requirements for Python 3 using this command::
apt-get install python-dev python-numpy libhdf4-dev -y
apt-get install build-essential python3-dev python3-numpy libhdf4-dev -y
OS X users can obtain jpeg libraries `here
<http://ethan.tira-thompson.com/Mac%20OS%20X%20Ports.html>`_.
......
......@@ -1304,21 +1304,7 @@ class SDAttr(object):
buf = _C.array_byte(n_values)
elif data_type == SDC.INT8:
# SWIG refuses negative values here. We found that if we
# pass them as byte values, it will work.
buf = _C.array_int8(n_values)
values = list(values)
for n in range(n_values):
v = values[n]
if v >= 0:
v &= 0x7f
else:
v = abs(v) & 0x7f
if v:
v = 256 - v
else:
v = 128 # -128 in 2s complement
values[n] = v
elif data_type == SDC.INT16:
buf = _C.array_int16(n_values)
......@@ -2538,17 +2524,7 @@ class SDS(object):
buf = _C.array_byte(n_values)
elif data_type == SDC.INT8:
# SWIG refuses negative values here. We found that if we
# pass them as byte values, it will work.
buf = _C.array_int8(n_values)
if fill_val >= 0:
fill_val &= 0x7f
else:
fill_val = abs(fill_val) & 0x7f
if fill_val:
fill_val = 256 - fill_val
else:
fill_val = 128 # -128 in 2's complement
elif data_type == SDC.INT16:
buf = _C.array_int16(n_values)
......@@ -2617,30 +2593,8 @@ class SDS(object):
buf2 = _C.array_byte(n_values)
elif data_type == SDC.INT8:
# SWIG refuses negative values here. We found that if we
# pass them as byte values, it will work.
buf1 = _C.array_int8(n_values)
buf2 = _C.array_int8(n_values)
v = min
if v >= 0:
v &= 0x7f
else:
v = abs(v) & 0x7f
if v:
v = 256 - v
else:
v = 128 # -128 in 2's complement
min = v
v = max
if v >= 0:
v &= 0x7f
else:
v = abs(v) & 0x7f
if v:
v = 256 - v
else:
v = 128 # -128 in 2's complement
max = v
elif data_type == SDC.INT16:
buf1 = _C.array_int16(n_values)
......@@ -3113,21 +3067,7 @@ class SDim(object):
buf = _C.array_byte(n_values)
elif data_type == SDC.INT8:
# SWIG refuses negative values here. We found that if we
# pass them as byte values, it will work.
buf = _C.array_int8(n_values)
scale = list(scale)
for n in range(n_values):
v = scale[n]
if v >= 0:
v &= 0x7f
else:
v = abs(v) & 0x7f
if v:
v = 256 - v
else:
v = 128 # -128 in 2's complement
scale[n] = v
elif data_type == SDC.INT16:
buf = _C.array_int16(n_values)
......
This diff is collapsed.
This diff is collapsed.
......@@ -5,6 +5,7 @@ import os
import pyhdf.SD
import tempfile
from nose.tools import eq_
from numpy.testing import assert_array_equal
from pyhdf.SD import SDC
def test_long_varname():
......@@ -28,3 +29,31 @@ def test_long_varname():
eq_(sds_name, name)
finally:
os.unlink(path)
def test_negative_int8():
_, path = tempfile.mkstemp(suffix='.hdf', prefix='pyhdf_')
try:
sd = pyhdf.SD.SD(path, SDC.WRITE|SDC.CREATE|SDC.TRUNC)
data = np.zeros(shape=(20,20), dtype=np.int8)
sds = sd.create("testsds", SDC.INT8, data.shape)
sds.setfillvalue(-1)
eq_(sds.getfillvalue(), -1)
sds.setrange(-50, -30)
min, max = sds.getrange()
eq_(min, -50)
eq_(max, -30)
attr = sds.attr("testattr")
attr.set(SDC.INT8, -1)
eq_(attr.get(), -1)
dim = sds.dim(0)
scale = [-1]*20
dim.setscale(SDC.INT8, scale)
assert_array_equal(dim.getscale(), scale)
sds[:,:] = -40
sd.end()
finally:
os.unlink(path)
......@@ -27,6 +27,7 @@ from numpy.distutils.core import setup, Extension
import sys
import os
import os.path as path
import shlex
CLASSIFIERS = """\
Development Status :: 5 - Production/Stable
......@@ -57,11 +58,29 @@ def _find_args(pat, env):
pass
return val
# A Debian based linux distribution might be using libhdf4 (contains netcdf
# routines) or libhdf4-alt (does not contain netcdf routines). This function
# tries to detect if the alt version should be used.
def _use_hdf4alt(libdirs):
if not sys.platform.startswith("linux"):
return False
libdirs.extend(os.environ.get("LD_LIBRARY_PATH", "").split(os.pathsep))
libdirs.append("/usr/lib")
libdirs.append("/usr/local/lib")
libdirs.append("/lib")
for d in libdirs:
if os.path.exists(os.path.join(d, "libdfalt.so")) and \
os.path.exists(os.path.join(d, "libmfhdfalt.so")):
return True
return False
include_dirs = _find_args('-i', 'INCLUDE_DIRS')
library_dirs = _find_args('-l', 'LIBRARY_DIRS')
szip_installed = 'SZIP' in os.environ
compress = 'NO_COMPRESS' not in os.environ
extra_link_args = os.environ.get('LINK_ARGS', '')
extra_link_args = None
if "LINK_ARGS" in os.environ:
extra_link_args = shlex.split(os.environ["LINK_ARGS"])
msg = 'Cannot proceed without the HDF4 library. Please ' \
......@@ -124,6 +143,8 @@ if sys.platform == 'win32':
if sys.platform == 'win32':
libraries = ["hm423m", "hd423m", "xdr_for_dll" ]
elif _use_hdf4alt(library_dirs):
libraries = ["mfhdfalt", "dfalt"]
else:
libraries = ["mfhdf", "df"]
......@@ -148,7 +169,7 @@ _hdfext = Extension('pyhdf._hdfext',
include_dirs = include_dirs,
extra_compile_args = extra_compile_args,
library_dirs = library_dirs,
extra_link_args=[extra_link_args],
extra_link_args=extra_link_args,
libraries = libraries,
)
......@@ -166,7 +187,7 @@ setup(name = 'python-hdf4',
license = 'MIT',
long_description = "\n".join(DOCLINES[2:]),
url = 'https://github.com/fhs/python-hdf4',
version = '0.9.1',
version = '0.9.2',
packages = ['pyhdf'],
ext_modules = [_hdfext],
data_files = data_files,
......