ovalhub / pyicu

The PyICU project repository has moved to https://pyicu.org.
Other
133 stars 49 forks source link

PyICU 2.0.2 fails to build on OS X #70

Closed workflowsguy closed 6 years ago

workflowsguy commented 6 years ago

After having finally figured out how to successfully build PyICU 1.9.8 with ICU 60.2 on OS X with Python 3.6.4, building PyICU 2.0.2 again fails with the following error:

    Complete output from command python setup.py egg_info:

    Building PyICU 2.0.2 for ICU 60.2

    Could not configure CXXFLAGS with icu-config
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/59/18ktbnzd1nq82_537cj3lmj40000gn/T/pip-build-ldpmxq8e/pyicu/setup.py", line 131, in <module>
        _cflags, ('--cxxflags', '--cppflags'), 'CXXFLAGS')
      File "/private/var/folders/59/18ktbnzd1nq82_537cj3lmj40000gn/T/pip-build-ldpmxq8e/pyicu/setup.py", line 30, in configure_with_icu_config
        output = check_output(('icu-config',) + config_args).strip()
      File "/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 336, in check_output
        **kwargs).stdout
      File "/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 403, in run
        with Popen(*popenargs, **kwargs) as process:
      File "/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 709, in __init__
        restore_signals, start_new_session)
      File "/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 1344, in _execute_child
        raise child_exception_type(errno_num, err_msg, err_filename)
    FileNotFoundError: [Errno 2] No such file or directory: 'icu-config': 'icu-config'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/59/18ktbnzd1nq82_537cj3lmj40000gn/T/pip-build-ldpmxq8e/pyicu/

I would be grateful for any information how to get this working again.

ovalhub commented 6 years ago

builds fine for me both with Python 2 and 3. How about a trace ?

ovalhub commented 6 years ago

Either have your installation of ICU make the icu-config program available or setup the env vars below according to your setup:

$ export ICU_VERSION= $ export PYICU_INCLUDES=/include $ export PYICU_LFLAGS=-L/lib $ export PYICU_CFLAGS=-std=c++11

or edit setup.py and set INCLUDES, LFLAGS and CFLAGS accordingly.

workflowsguy commented 6 years ago

Thanks for listing the environment variables. However, PyICU still does not compile. This time, the error message is:

    Building PyICU 2.0.2 for ICU 60.2

    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.11-x86_64-3.6
    copying PyICU.py -> build/lib.macosx-10.11-x86_64-3.6
    creating build/lib.macosx-10.11-x86_64-3.6/icu
    copying icu/__init__.py -> build/lib.macosx-10.11-x86_64-3.6/icu
    running build_ext
    building '_icu' extension
    creating build/temp.macosx-10.11-x86_64-3.6
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/opt/icu4c/include -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/include/python3.6m -c _icu.cpp -o build/temp.macosx-10.11-x86_64-3.6/_icu.o -std=c++11
    _icu.cpp:206:31: error: use of undeclared identifier 'PYICU_VER'
        ver = PyString_FromString(PYICU_VER);
                                  ^
    1 error generated.
    error: command 'clang' failed with exit status 1
ovalhub commented 6 years ago

Add -DPYICU_VER=2.0.2 to your cflags.

Andi..

On Jan 21, 2018, at 12:07, workflowsguy notifications@github.com wrote:

Thanks for listing the environment variables. However, PyICU still does not compile. This time, the error message is:

Building PyICU 2.0.2 for ICU 60.2

running install
running build
running build_py
creating build
creating build/lib.macosx-10.11-x86_64-3.6
copying PyICU.py -> build/lib.macosx-10.11-x86_64-3.6
creating build/lib.macosx-10.11-x86_64-3.6/icu
copying icu/__init__.py -> build/lib.macosx-10.11-x86_64-3.6/icu
running build_ext
building '_icu' extension
creating build/temp.macosx-10.11-x86_64-3.6
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/opt/icu4c/include -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/include/python3.6m -c _icu.cpp -o build/temp.macosx-10.11-x86_64-3.6/_icu.o -std=c++11
_icu.cpp:206:31: error: use of undeclared identifier 'PYICU_VER'
    ver = PyString_FromString(PYICU_VER);
                              ^
1 error generated.
error: command 'clang' failed with exit status 1

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

workflowsguy commented 6 years ago

OK, I initiate the build process with

CFLAGS=-D PYICU_VER=2.0.2 pip3 install pyicu

Now the next errors I get are those:

    Building PyICU 2.0.2 for ICU 60.2

    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.11-x86_64-3.6
    copying PyICU.py -> build/lib.macosx-10.11-x86_64-3.6
    creating build/lib.macosx-10.11-x86_64-3.6/icu
    copying icu/__init__.py -> build/lib.macosx-10.11-x86_64-3.6/icu
    running build_ext
    building '_icu' extension
    creating build/temp.macosx-10.11-x86_64-3.6
    clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -D -I/usr/local/opt/icu4c/include -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/include/python3.6m -c _icu.cpp -o build/temp.macosx-10.11-x86_64-3.6/_icu.o -std=c++11
    In file included from <built-in>:356:
    <command line>:2:9: error: macro name must be an identifier
    #define -I/usr/local/opt/icu4c/include 1
            ^
    In file included from _icu.cpp:27:
    ./common.h:105:10: fatal error: 'unicode/utypes.h' file not found
    #include <unicode/utypes.h>
             ^
    2 errors generated.
    error: command 'clang' failed with exit status 1
ovalhub commented 6 years ago

Don’t use a space character after -D: CFLAGS=-DPYICU_VER=2.0.2 You shouldn’t have to set this, by the way... But if you must, use PYICU_CFLAGS instead.

On Jan 22, 2018, at 05:37, workflowsguy notifications@github.com wrote:

OK, I initiate the build process with

CFLAGS=-D PYICU_VER=2.0.2 pip3 install pyicu

Now the next errors I get are those:

Building PyICU 2.0.2 for ICU 60.2

running install
running build
running build_py
creating build
creating build/lib.macosx-10.11-x86_64-3.6
copying PyICU.py -> build/lib.macosx-10.11-x86_64-3.6
creating build/lib.macosx-10.11-x86_64-3.6/icu
copying icu/__init__.py -> build/lib.macosx-10.11-x86_64-3.6/icu
running build_ext
building '_icu' extension
creating build/temp.macosx-10.11-x86_64-3.6
clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -D -I/usr/local/opt/icu4c/include -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/include/python3.6m -c _icu.cpp -o build/temp.macosx-10.11-x86_64-3.6/_icu.o -std=c++11
In file included from <built-in>:356:
<command line>:2:9: error: macro name must be an identifier
#define -I/usr/local/opt/icu4c/include 1
        ^
In file included from _icu.cpp:27:
./common.h:105:10: fatal error: 'unicode/utypes.h' file not found
#include <unicode/utypes.h>
         ^
2 errors generated.
error: command 'clang' failed with exit status 1

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

workflowsguy commented 6 years ago

When running CFLAGS=-DPYICU_VER=2.0.2 pip3 install pyicu, I get

Collecting pyicu
  Using cached PyICU-2.0.2.tar.gz
Building wheels for collected packages: pyicu
  Running setup.py bdist_wheel for pyicu ... error
  Complete output from command /usr/local/opt/python3/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/private/var/folders/59/18ktbnzd1nq82_537cj3lmj40000gn/T/pip-build-8qbqoukc/pyicu/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /var/folders/59/18ktbnzd1nq82_537cj3lmj40000gn/T/tmpfipy6ld_pip-wheel- --python-tag cp36:

  Building PyICU 2.0.2 for ICU 60.2

  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-10.11-x86_64-3.6
  copying PyICU.py -> build/lib.macosx-10.11-x86_64-3.6
  creating build/lib.macosx-10.11-x86_64-3.6/icu
  copying icu/__init__.py -> build/lib.macosx-10.11-x86_64-3.6/icu
  running build_ext
  building '_icu' extension
  creating build/temp.macosx-10.11-x86_64-3.6
  clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -DPYICU_VER=2.0.2 -I/usr/local/opt/icu4c/include -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/include/python3.6m -c _icu.cpp -o build/temp.macosx-10.11-x86_64-3.6/_icu.o -std=c++11
  _icu.cpp:206:31: error: invalid suffix '.2' on floating constant
      ver = PyString_FromString(PYICU_VER);
                                ^
  <command line>:2:22: note: expanded from here
  #define PYICU_VER 2.0.2
                       ^
  1 error generated.
  error: command 'clang' failed with exit status 1

  ----------------------------------------
  Failed building wheel for pyicu
  Running setup.py clean for pyicu
Failed to build pyicu
Installing collected packages: pyicu
  Running setup.py install for pyicu ... error
    Complete output from command /usr/local/opt/python3/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/private/var/folders/59/18ktbnzd1nq82_537cj3lmj40000gn/T/pip-build-8qbqoukc/pyicu/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/59/18ktbnzd1nq82_537cj3lmj40000gn/T/pip-ntkw1gw_-record/install-record.txt --single-version-externally-managed --compile:

    Building PyICU 2.0.2 for ICU 60.2

    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.11-x86_64-3.6
    copying PyICU.py -> build/lib.macosx-10.11-x86_64-3.6
    creating build/lib.macosx-10.11-x86_64-3.6/icu
    copying icu/__init__.py -> build/lib.macosx-10.11-x86_64-3.6/icu
    running build_ext
    building '_icu' extension
    creating build/temp.macosx-10.11-x86_64-3.6
    clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -DPYICU_VER=2.0.2 -I/usr/local/opt/icu4c/include -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/include/python3.6m -c _icu.cpp -o build/temp.macosx-10.11-x86_64-3.6/_icu.o -std=c++11
    _icu.cpp:206:31: error: invalid suffix '.2' on floating constant
        ver = PyString_FromString(PYICU_VER);
                                  ^
    <command line>:2:22: note: expanded from here
    #define PYICU_VER 2.0.2
                         ^
    1 error generated.
    error: command 'clang' failed with exit status 1

I do not understand what you mean by

But if you must, use PYICU_CFLAGS instead.

If I enter export PYICU_CFLAGS="-std=c++11 -DPYICU_VER=2.0.2" and then pip3 install pyicu, I get an error error: invalid value 'c++11 -DPYICU_VER=2.0.2' in '-std=c++11 -DPYICU_VER=2.0.2

ovalhub commented 6 years ago

Use CFLAGS='-DPYICU_VER="2.0.2"'

But really, you shouldn't have to set this. You should be getting this set automatically from the CFLAGS dict at line 78 in setup.py.

I'd be very curious as to why setting this var is necessary.

Andi..

On Tue, 23 Jan 2018, workflowsguy wrote:

When running CFLAGS=-DPYICU_VER=2.0.2 pip3 install pyicu, I get

Collecting pyicu
 Using cached PyICU-2.0.2.tar.gz
Building wheels for collected packages: pyicu
 Running setup.py bdist_wheel for pyicu ... error
 Complete output from command /usr/local/opt/python3/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/private/var/folders/59/18ktbnzd1nq82_537cj3lmj40000gn/T/pip-build-8qbqoukc/pyicu/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /var/folders/59/18ktbnzd1nq82_537cj3lmj40000gn/T/tmpfipy6ld_pip-wheel- --python-tag cp36:

 Building PyICU 2.0.2 for ICU 60.2

 running bdist_wheel
 running build
 running build_py
 creating build
 creating build/lib.macosx-10.11-x86_64-3.6
 copying PyICU.py -> build/lib.macosx-10.11-x86_64-3.6
 creating build/lib.macosx-10.11-x86_64-3.6/icu
 copying icu/__init__.py -> build/lib.macosx-10.11-x86_64-3.6/icu
 running build_ext
 building '_icu' extension
 creating build/temp.macosx-10.11-x86_64-3.6
 clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -DPYICU_VER=2.0.2 -I/usr/local/opt/icu4c/include -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/include/python3.6m -c _icu.cpp -o build/temp.macosx-10.11-x86_64-3.6/_icu.o -std=c++11
 _icu.cpp:206:31: error: invalid suffix '.2' on floating constant
     ver = PyString_FromString(PYICU_VER);
                               ^
 <command line>:2:22: note: expanded from here
 #define PYICU_VER 2.0.2
                      ^
 1 error generated.
 error: command 'clang' failed with exit status 1

 ----------------------------------------
 Failed building wheel for pyicu
 Running setup.py clean for pyicu
Failed to build pyicu
Installing collected packages: pyicu
 Running setup.py install for pyicu ... error
   Complete output from command /usr/local/opt/python3/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/private/var/folders/59/18ktbnzd1nq82_537cj3lmj40000gn/T/pip-build-8qbqoukc/pyicu/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/59/18ktbnzd1nq82_537cj3lmj40000gn/T/pip-ntkw1gw_-record/install-record.txt --single-version-externally-managed --compile:

   Building PyICU 2.0.2 for ICU 60.2

   running install
   running build
   running build_py
   creating build
   creating build/lib.macosx-10.11-x86_64-3.6
   copying PyICU.py -> build/lib.macosx-10.11-x86_64-3.6
   creating build/lib.macosx-10.11-x86_64-3.6/icu
   copying icu/__init__.py -> build/lib.macosx-10.11-x86_64-3.6/icu
   running build_ext
   building '_icu' extension
   creating build/temp.macosx-10.11-x86_64-3.6
   clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -DPYICU_VER=2.0.2 -I/usr/local/opt/icu4c/include -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/include/python3.6m -c _icu.cpp -o build/temp.macosx-10.11-x86_64-3.6/_icu.o -std=c++11
   _icu.cpp:206:31: error: invalid suffix '.2' on floating constant
       ver = PyString_FromString(PYICU_VER);
                                 ^
   <command line>:2:22: note: expanded from here
   #define PYICU_VER 2.0.2
                        ^
   1 error generated.
   error: command 'clang' failed with exit status 1

I do not understand what you mean by

But if you must, use PYICU_CFLAGS instead.

If I enter export PYICU_CFLAGS="-std=c++11 -DPYICU_VER=2.0.2" and then pip3 install pyicu, I get an error error: invalid value 'c++11 -DPYICU_VER=2.0.2' in '-std=c++11 -DPYICU_VER=2.0.2

-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/ovalhub/pyicu/issues/70#issuecomment-359900014

workflowsguy commented 6 years ago

Regardless of whether I enter CFLAGS='-DPYICU_VER="2.0.2"' pip3 install pyicu or just pip3 install pyicu,

PYICU simply does not build, giving different error messages based on the command entered, as mentioned above.

The environment variables are set as per your answers:

ICU_VERSION=60.2
PYICU_CFLAGS=-std=c++11
PYICU_INCLUDES=/usr/local/opt/icu4c/include
PYICU_LFLAGS=-L/usr/local/opt/icu4c/lib
ovalhub commented 6 years ago

On Fri, 26 Jan 2018, workflowsguy wrote:

Regardless of whether I enter CFLAGS='-DPYICU_VER="2.0.2"' pip3 install pyicu or just pip3 install pyicu,

PYICU simply does not build, giving different error messages based on the command entered, as mentioned above.

The environment variables are set as per your answers:

ICU_VERSION=60.2
PYICU_CFLAGS=-std=c++11
PYICU_INCLUDES=/usr/local/opt/icu4c/include
PYICU_LFLAGS=-L/usr/local/opt/icu4c/lib

Sorry, I can't help you better. I suggest you get help from someone more familiar with the issues at hand.

Andi..

-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/ovalhub/pyicu/issues/70#issuecomment-360758210

antislice commented 6 years ago

I'm having the same series of issues that @workflowsguy had.

If I install with CFLAGS=-I/usr/local/opt/icu4c/include LDFLAGS=-L/usr/local/opt/icu4c/lib pip install pyicu, it installed successfully (this is all over the internet but mainly for ICU versions < 60 as far as I can tell). However, running my script that depends on pyicu (via polyglot) after that gives

Traceback (most recent call last):
  File "scrubber.py", line 14, in <module>
    from polyglot.text import Text
  File "/Users/homeslice/work/scrubber/venv/lib/python2.7/site-packages/polyglot/text.py", line 9, in <module>
    from polyglot.detect import Detector, Language
  File "/Users/homeslice/work/scrubber/venv/lib/python2.7/site-packages/polyglot/detect/__init__.py", line 1, in <module>
    from .base import Detector, Language
  File "/Users/homeslice/work/scrubber/venv/lib/python2.7/site-packages/polyglot/detect/base.py", line 11, in <module>
    from icu import Locale
  File "/Users/homeslice/work/scrubber/venv/lib/python2.7/site-packages/icu/__init__.py", line 37, in <module>
    from _icu import *
ImportError: dlopen(/Users/homeslice/work/scrubber/venv/lib/python2.7/site-packages/_icu.so, 2): Symbol not found: __ZNK6icu_6014Transliterator12getTargetSetERNS_10UnicodeSetE
  Referenced from: /Users/homeslice/work/scrubber/venv/lib/python2.7/site-packages/_icu.so
  Expected in: flat namespace
 in /Users/homeslice/work/scrubber/venv/lib/python2.7/site-packages/_icu.so

Which according to this stackoverflow question implies something was compiled incorrectly, so I tried the solutions offered above. And I'm at the same error: invalid suffix '.3' on floating constant error.

ICU_VERSION=60.2
PYICU_CFLAGS='-std=c++11 -DPYICU_VER=2.0.3'
PYICU_INCLUDES=/usr/local/opt/icu4c/include
PYICU_LFLAGS=-L/usr/local/opt/icu4c/lib
ovalhub commented 6 years ago

On Wed, 31 Jan 2018, GA wrote:

I'm having the same series of issues that @workflowsguy had.

I don't think you do, you were able to do a build whereas @workflowguy, for some strange reason, doesn't have PYICU_VER set - you do, otherwise your build would have failed.

If I install with CFLAGS=-I/usr/local/opt/icu4c/include LDFLAGS=-L/usr/local/opt/icu4c/lib pip install pyicu, it installed successfully (this is all over the internet but mainly for ICU versions < 60 as far as I can tell). However, running my script that depends on pyicu (via polyglot) after that gives

Why are you doing this instead of having icu-config do this for you ? If you don't have icu-config installed, then install it. On linux, it seems to come with the icu-dev package. If you build ICU from sources on Mac, it's installed with it. If you use homebrew or something else, there may be another package you need to install, ask them.

Whichever way you installed ICU, there is an icu-config program that comes with it on unix (linux, mac, etc..) that remembers where and how it was configured. PyICU uses icu-config to set all the necessary c++ compiler and linker flags accordingly.

If you don't have / can't install icu-config, then you need to ensure that the ICU header files and the ICU libs you compile and link against are the same as the ICU shared libs you are going to run with.

Traceback (most recent call last):
 File "scrubber.py", line 14, in <module>
   from polyglot.text import Text
 File "/Users/homeslice/work/scrubber/venv/lib/python2.7/site-packages/polyglot/text.py", line 9, in <module>
   from polyglot.detect import Detector, Language
 File "/Users/homeslice/work/scrubber/venv/lib/python2.7/site-packages/polyglot/detect/__init__.py", line 1, in <module>
   from .base import Detector, Language
 File "/Users/homeslice/work/scrubber/venv/lib/python2.7/site-packages/polyglot/detect/base.py", line 11, in <module>
   from icu import Locale
 File "/Users/homeslice/work/scrubber/venv/lib/python2.7/site-packages/icu/__init__.py", line 37, in <module>
   from _icu import * ImportError: 
dlopen(/Users/homeslice/work/scrubber/venv/lib/python2.7/site-packages/_icu.so, 
2): Symbol not found: 
__ZNK6icu_6014Transliterator12getTargetSetERNS_10UnicodeSetE
 Referenced from: /Users/homeslice/work/scrubber/venv/lib/python2.7/site-packages/_icu.so
 Expected in: flat namespace
in /Users/homeslice/work/scrubber/venv/lib/python2.7/site-packages/_icu.so

The missing __ZNK6icu_6014Transliterator12getTargetSetERNS_10UnicodeSetE is a symptom of a mismatch between the ICU version you built PyICU with and the one you then running with. You probably have multiple versions of ICU installed. Check that you don't have DYLD_LIBRARY_PATH set to an old ICU version or that you are compiling and linking against the correct version of ICU. You can use the 'otool' utility to find which actuall shared ICU library your _icu.so python extension is going to try to load: For me, this looks like: $ otool -L _icu.so libicui18n.60.dylib (compatibility version 60.0.0, current version 60.2.0) libicuuc.60.dylib (compatibility version 60.0.0, current version 60.2.0) ../lib/libicudata.60.2.dylib (compatibility version 60.0.0, current version 60.2.0) /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 104.1.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.50.2) /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 489.0.0) For you, it better reflect where you built and installed ICU to.

Which according to this stackoverflow question implies something was compiled incorrectly, so I tried the solutions offered above. And I'm at the same error: invalid suffix '.3' on floating constant error.

No, this is irrelevant. You do not need to set PYICU_VER manually, this is done for you in PyICU's setup.py. If you must continue setting it, you must ensure it's enclosed in "". PYICU_CFLAGS='-std=c++11 -DPYICU_VER="2.0.3"' but this is not the issue you're facing.

Andi..

ICU_VERSION=60.2
PYICU_CFLAGS='-std=c++11 -DPYICU_VER=2.0.3'
PYICU_INCLUDES=/usr/local/opt/icu4c/include
PYICU_LFLAGS=-L/usr/local/opt/icu4c/lib

-- You are receiving this because you modified the open/close state. Reply to this email directly or view it on GitHub: https://github.com/ovalhub/pyicu/issues/70#issuecomment-361842541

workflowsguy commented 6 years ago

The brew ICU package contains icu-config in /usr/local/Cellar/icu4c/60.2/bin/icu-config, which is not included in the standard path.

I have linked it into a standard path with ln -s /usr/local/Cellar/icu4c/60.2/bin/icu-config /usr/local/bin/icu-config.

Now, with sudo pip3 install pyicu, it finally builds successfully!

As icu-config is obviously a required precondition for building PyICU, it should not be assumed that it is found in the path. Instead, the PyICU setup script should check for it's presence and show an appropriate error message if not found.

ovalhub commented 6 years ago

On Thu, 1 Feb 2018, workflowsguy wrote:

The brew ICU package contains icu-config in /usr/local/Cellar/icu4c/60.2/bin/icu-config, which is not included in the standard path.

I have linked it into a standard path with ln -s /usr/local/Cellar/icu4c/60.2/bin/icu-config /usr/local/bin/icu-config.

Now, with sudo pip3 install pyicu, it finally builds successfully!

As icu-config is obviously a required precondition for building PyICU, it should not be assumed that it is found in the path. Instead, the PyICU setup script should check for it's presence and show an appropriate error message if not found.

The configure_with_icu_config function starting at line 28 in setup.py does this. It prints an error message and re-raises the exception raised by the check_output() function above it.

In other words, if you don't have icu-config or it can be found or it fails to run, you're back to doing what is asked of you line 26 in README.md, that is, manually setting the the INCLUDES, LFLAGS, CFLAGS and LIBRARIES dictionaries in setup.py with the values for your platform.

Andi..

akhudek commented 6 years ago

It turns out that the right env var is:

export PYICU_CFLAGS=-std=c++11:-DPYICU_VER='"2.0.3"'

The : causes the arguments to be treated separately and the single quotes cause the double quotes to be included in the define.

wachmann commented 6 years ago

Don’t use a space character after -D: CFLAGS=-DPYICU_VER=2.0.2 You shouldn’t have to set this, by the way... But if you must, use PYICU_CFLAGS instead.

Thanks! This worked for me!

will3216 commented 6 years ago

This did the trick for me. No environment variables at all!

brew install intltool icu4c gettext
brew link icu4c gettext --force
pip3 install pyicu
nmooman commented 6 years ago

On Mac: %brew install intltool icu4c gettext %brew link icu4c gettext --force %ls -arlt /usr/local/opt/icu4c/bin/icu-config %git clone https://github.com/ovalhub/pyicu.git %cd pyicu check your icu4c version by %ls /usr/local/Cellar/icu4c/ i.e., 59.1_1 61.1 62.1 %sudo ICU_VERSION='62.1' python3.6 setup.py build %sudo ICU_VERSION='62.1' python3.6 setup.py install %sudo pip3.6 install polyglot --upgrade

You might need if you encountered issues: %export PYICU_INCLUDES=/include %export PYICU_LFLAGS=-L/lib %export PYICU_CFLAGS=-std=c++11

and in your setup.py try: ICU_VERSION = os.environ['ICU_VERSION']

ICU_VERSION = '62.1'

except: try:

ICU_VERSION = check_output(('icu-config', '--version')).strip()

       **_ICU_VERSION = '62.1'_**
       if sys.version_info >= (3,):
           ICU_VERSION = str(ICU_VERSION, 'ascii')
   except:
       raise RuntimeError('''

Please set the ICU_VERSION environment variable to the version of ICU you have installed. ''') Good luck. Nasser

Hultner commented 6 years ago

@will3216 I'm not able to get it to work with your solution, the only way for me to install it is to set up the path or link icu-config manually.

I can get it to install successfully on my machine with some hassle but it's hard for me to be able to create a reproducible setup.py so that other developers in my team are able to install the package without to much hassle.

Brew won't let me force link icu4c and gives the following output if I try.

$ brew link icu4c                                                                                                                                                                                                                                                                              
Warning: Refusing to link macOS-provided software: icu4c
If you need to have icu4c first in your PATH run:
  echo 'export PATH="/usr/local/opt/icu4c/bin:$PATH"' >> ~/.zshrc
  echo 'export PATH="/usr/local/opt/icu4c/sbin:$PATH"' >> ~/.zshrc

For compilers to find icu4c you may need to set:
  export LDFLAGS="-L/usr/local/opt/icu4c/lib"
  export CPPFLAGS="-I/usr/local/opt/icu4c/include"

For pkg-config to find icu4c you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig"
will3216 commented 6 years ago

@Hultner did you install icu4c with brew? It seems like that warning is indicating it was installed directly on your OS. This has become a requirement for each person on our team that needs to load our ecosystem and the solution provided above worked for each of us thus far. That said, your setup could easily be different in some way. What version of macOS are running?

echo-phantom commented 6 years ago

Nice bits of info a bit sparse/scattered. In summary what worked for future references: I have MacOS 10.13. My project required PyICU-1.8 and the only icu4c that worked was version 57.1 $ brew remove icu4c $ cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core $ git checkout 1e62c645b2fc2d82042d9f7c364c6a246f2e11ed Formula/icu4c.rb #this is the latest commit with 57.1 $ brew install icu4c $ ln -s /usr/local/Cellar/icu4c/57.1/bin/icu-config /usr/local/bin/icu-config My .bash_profile

 22 export ICU_VERSION=57.1
 23 export PYICU_INCLUDES=/usr/local/Cellar/icu4c/${ICU_VERSION}/include
 24 export PYICU_LFLAGS=-L/usr/local/Cellar/icu4c/${ICU_VERSION}/lib
 25 export PYICU_CFLAGS=-std=c++11:-DPYICU_VER='"1.8"'

$ source ~/.bash_profile && pip install PyICU==1.8 --ignore-installed

Hultner commented 6 years ago

@will3216 Yep, I installed it through brew. I've never knowingly installed it directly through my OS. It might have been installed previously by some other software, may it be bundled with xcode or similar?

will3216 commented 6 years ago

@Hultner I'm not sure then. What I do know is that the command you listed above was brew link icu4c not brew link icu4c --force. If that doesn't work, I'd recommend going with @diegocoder's solution (being sure to change the ICU_VERSION to whatever version you have installed).

Hultner commented 6 years ago

@will3216 I tried both with the same result. I did get it to work when setting up the path manually and defining ICU_VERSION in my environment before running pipenv install on the project. It's just a bit more cumbersome for our developers this way since we need to set up new PATH variables etc.

will3216 commented 6 years ago

@Hultner Yeah, that approach is definitely a bit cumbersome and easy to forget down the line when you onboard new team members, but I suspect that the issue you are running into might be specific to your particular environment. It may be possible for other members of your team to use the brew link force approach (unless of course the issue is derived from a tool your whole team uses)

yu-imu commented 6 years ago

I also experienced this problem.

[Errno 2] No such file or directory: 'icu-config': 'icu-config'

I fixed as follow and finally installed pyicu I already installed icu4c as follow $ brew install icu4c $ brew link icu4c So, make to a path to .bash_profile echo 'export PATH="/usr/local/opt/icu4c/bin:$PATH"' >> ~/.bash_profile echo 'export PATH="/usr/local/opt/icu4c/sbin:$PATH"' >> ~/.bash_profile source ~/.bash_profile pip3 install pyicu

loretoparisi commented 5 years ago

In my case I just did

export ICU_VERSION=63.1
export PYICU_INCLUDES=/usr/local/Cellar/icu4c/63.1/include
export PYICU_LFLAGS=-L/usr/local/Cellar/icu4c/63.1/lib
export PYICU_CFLAGS=-std=c++11
pip install pyicu

https://gist.github.com/loretoparisi/294b8f536750a18746fc6f43f7859928

the problem is when importing the library!

ip-192-168-22-157:~ loretoparisi$ python -c "import icu"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/icu/__init__.py", line 37, in <module>
    from _icu import *
ImportError: dlopen(/usr/local/lib/python2.7/site-packages/_icu.so, 2): Symbol not found: __ZN6icu_638ByteSink15GetAppendBufferEiiPciPi
  Referenced from: /usr/local/lib/python2.7/site-packages/_icu.so
  Expected in: flat namespace
 in /usr/local/lib/python2.7/site-packages/_icu.so
wilfredcho commented 5 years ago

@loretoparisi Were you able to resolve this problem? I just ran into it.

piyiotisk commented 3 years ago

In my case I just did

export ICU_VERSION=63.1
export PYICU_INCLUDES=/usr/local/Cellar/icu4c/63.1/include
export PYICU_LFLAGS=-L/usr/local/Cellar/icu4c/63.1/lib
export PYICU_CFLAGS=-std=c++11
pip install pyicu

https://gist.github.com/loretoparisi/294b8f536750a18746fc6f43f7859928

the problem is when importing the library!

ip-192-168-22-157:~ loretoparisi$ python -c "import icu"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/icu/__init__.py", line 37, in <module>
    from _icu import *
ImportError: dlopen(/usr/local/lib/python2.7/site-packages/_icu.so, 2): Symbol not found: __ZN6icu_638ByteSink15GetAppendBufferEiiPciPi
  Referenced from: /usr/local/lib/python2.7/site-packages/_icu.so
  Expected in: flat namespace
 in /usr/local/lib/python2.7/site-packages/_icu.so

Yes, I was able to resolve this. Basically, reading this guide https://docs.brew.sh/Homebrew-and-Python you will need to run CFLAGS=-I$(brew --prefix)/include LDFLAGS=-L$(brew --prefix)/lib pip install pyicu` without using a virtualenv. This will pass the correct compiler parameters so the brew icu4c could communicate with the python lib. After that enable the virtualenv and you will be good to go