Not finding icu header files when running pyicu/setup.py
Created by: maveryKearney
Problem: I cannot seem to run the pyicu setup.py script successfully these days. It terminates promptly as shown in the log below: (python:3.6.2, icu:59.2, pyicu: 1.9.7. I am running on Linux-mint _18.2) an ubuntu derivative.
I suspect I am missing an fundamental detail. I am experiencing this with other versions of: icu (55,57) pyicu (1.9.2, 1.9.3), python (3.5*. 3.6), and on MacOS-sierra.
I have been able to create working icu/pyicu/python ntegrations in the past.
Details:
A log of a setup.py. I set ICU_VERSION=’59’
`$ /home//opt/python_/3_6_2_v/bin/python setup.py build
Building PyICU 1.9.7 for ICU 59
running build running build_py creating build creating build/lib.linux-x86_64-3.6 copying PyICU.py -> build/lib.linux-x86_64-3.6 creating build/lib.linux-x86_64-3.6/icu copying icu/docs.py -> build/lib.linux-x86_64-3.6/icu copying icu/init.py -> build/lib.linux-x86_64-3.6/icu running build_ext building 'icu' extension creating build/temp.linux-x86_64-3.6 gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home//opt/icu/59_2/source/common -I//bryllyg/opt/python_/3_6_2_v/include -I/home//bryllyg/opt/python_/3_6_2/Include -I//bryllyg/opt/python_/3_6_2 -c _icu.cpp -o build/temp.linux-x86_64-3.6/_icu.o -DPYICU_VER="1.9.7" -std=c++11 cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ In file included from _icu.cpp:27:0: common.h:111:30: fatal error: unicode/calendar.h: No such file or directory compilation terminated. error: command 'gcc' failed with exit status `
I built python 3.6.2 from source. I have not installed it. I am developing an app and will be modifying python internals, I don't want to muck up the system python version with my experiments so I am using a virtual env folder structure as is currently recommended.
------------------------------- python detail $ /home//opt/python_/3_6_2_v/bin/python Python 3.6.2 (default, Jul 26 2017, 15:06:33) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information.
I have built and checked ICU 59.2 without error.
The symptom suggests to me that I don't have my pyicu include directory correct. Here are the pertinent lines of my setup.py. Only the linux line is pertinent.
INCLUDES = { 'darwin': ['/usr/local/include'], 'linux': ['/home//opt/icu_/59_2/source/common'], 'freebsd': ['/usr/local/include'], 'win32': ['c:/icu/include'], 'sunos5': [], }
The error is correct: common.h:111:30: fatal error: unicode/calendar.h: No such file or directory
calendar.h is not in /home//opt/icu_/59_2/source/common/unicode
However, calendar.h IS in /home//opt/icu_/59_2/source/common/i18n, and when I move it over to .../common, the build just complains about another "misplaced" file.
I've tried changing 'linux': ['/home//opt/icu_/59_2/source/common'], to 'linux': ['/home//opt/icu_/59_2/source/i18n'],
And the build just fails on other files.
Given those clues, I saved a copy of the .../common folder and copied all the files of .../i18n into the original .../common. Much to my surprise, pyicu/setup.py completed the compilation phase but failed at "ld". Here is the end of the log.
. . .
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home//opt/icu_/59_2/source/common -I/home//opt/python_/3_6_2_v/include -I/home//opt/python_/3_6_2/Include -I/home//opt/python_/3_6_2 -c tzinfo.cpp -o build/temp.linux-x86_64-3.6/tzinfo.o -DPYICU_VER="1.9.7" -std=c++11 cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home//opt/icu_/59_2/source/common -I/home//opt/python_/3_6_2_v/include -I/home//opt/python_/3_6_2/Include -I/home//opt/python_/3_6_2 -c unicodeset.cpp -o build/temp.linux-x86_64-3.6/unicodeset.o -DPYICU_VER="1.9.7" -std=c++11 cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
g++ -pthread -shared build/temp.linux-x86_64-3.6/icu.o build/temp.linux-x86_64-3.6/bases.o build/temp.linux-x86_64-3.6/calendar.o build/temp.linux-x86_64-3.6/char.o build/temp.linux-x86_64-3.6/charset.o build/temp.linux-x86_64-3.6/collator.o build/temp.linux-x86_64-3.6/common.o build/temp.linux-x86_64-3.6/dateformat.o build/temp.linux-x86_64-3.6/errors.o build/temp.linux-x86_64-3.6/format.o build/temp.linux-x86_64-3.6/idna.o build/temp.linux-x86_64-3.6/iterators.o build/temp.linux-x86_64-3.6/layoutengine.o build/temp.linux-x86_64-3.6/locale.o build/temp.linux-x86_64-3.6/normalizer.o build/temp.linux-x86_64-3.6/numberformat.o build/temp.linux-x86_64-3.6/regex.o build/temp.linux-x86_64-3.6/script.o build/temp.linux-x86_64-3.6/search.o build/temp.linux-x86_64-3.6/shape.o build/temp.linux-x86_64-3.6/spoof.o build/temp.linux-x86_64-3.6/transliterator.o build/temp.linux-x86_64-3.6/tzinfo.o build/temp.linux-x86_64-3.6/unicodeset.o -licui18n -licuuc -licudata -o build/lib.linux-x86_64-3.6/icu.cpython-36m-x86_64-linux-gnu.so /home//opt/icu/59_2/source/lib /usr/bin/ld: cannot find -licui18n /usr/bin/ld: cannot find -licuuc /usr/bin/ld: cannot find -licudata /usr/bin/ld: cannot find /home//opt/icu/59_2/source/lib: File format not recognized collect2: error: ld returned 1 exit status error: command 'g++' failed with exit status 1
This suggests that the path I supply for finding the libraries is wrong. The complaint "file format not recognized" is cryptic.
Have I configured ICU incorrectly perhaps? Can I only integrate with the root of the virtualenv tree? I haven't tried that yet.