Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle utf-8 netcdf.h from netcdf 4.3.1.1 in python3 #232

Closed
opoplawski opened this issue Mar 7, 2014 · 4 comments
Closed

Handle utf-8 netcdf.h from netcdf 4.3.1.1 in python3 #232

opoplawski opened this issue Mar 7, 2014 · 4 comments

Comments

@opoplawski
Copy link
Contributor

For the Fedora netcdf4-python package, we are building with python3 support. With netcdf 4.3.1.1 we are getting:

+ /usr/bin/python3 setup.py build
HDF5_DIR environment variable not set, checking some standard locations ..
checking /builddir ...
checking /usr/local ...
checking /sw ...
checking /opt ...
checking /opt/local ...
checking /usr ...
HDF5 found in /usr
NETCDF4_DIR environment variable not set, checking standard locations.. 
checking /builddir ...
checking /usr/local ...
checking /sw ...
checking /opt ...
checking /opt/local ...
checking /usr ...
Traceback (most recent call last):
  File "setup.py", line 223, in <module>
    isnetcdf4 = check_ifnetcdf4(os.path.join(direc, 'include'))
  File "setup.py", line 37, in check_ifnetcdf4
    for line in f:
  File "/usr/lib64/python3.3/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 6698: ordinal not in range(128)

This is because netcdf.h is now a utf-8 file. Unfortunately I have not yet found a way to handle this that works with both python2 and python3.

@jswhit
Copy link
Collaborator

jswhit commented Mar 7, 2014

I'm looking at the version of netcdf.h in github master and I don't see any utf-8 characters in there. Building also works for me with both python2.7 and python3.3 (and all tests pass). I wonder where those non-ascii characters came from? Perhaps your netcdf.h is corrupted somehow?

@opoplawski
Copy link
Contributor Author

The file is utf-8:

$ find -name netcdf.h | xargs file
./netcdf-c/include/netcdf.h:         C++ source, UTF-8 Unicode text
./netcdf-c-4.3.1.1/include/netcdf.h: C++ source, UTF-8 Unicode text

the line is here:

 *  underlying data‥

My paste ere changed the character it seems - the original has a '.' in the middle of the line. I'll report that to netcdf.

@jswhit
Copy link
Collaborator

jswhit commented Mar 7, 2014

I see it now. I still don't understand why you're getting that error. python2.7 is happy to read that line in as a string without raising a UnicodeDecodeError for me (on MacOS and Ubuntu). Maybe it has something to do with the Fedora environment.

It should be fixed in netcdf-c though.

@jswhit
Copy link
Collaborator

jswhit commented Mar 7, 2014

The header is now fixed in netcdf-c master.

@jswhit jswhit closed this as completed Mar 30, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants