Code Monkey home page Code Monkey logo

Comments (15)

msabramo avatar msabramo commented on July 29, 2024

I have a newer bison installed with Homebrew but it's not on the PATH.

I think I've gotten it to use the newer bison by doing:

YACC=/usr/local/Cellar/bison/3.0.3/bin/yacc pip install jq

but then I get a linker error:

...
    ld: targeted OS version does not support use of thread local variables in _jv_nomem_handler for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    error: command 'gcc' failed with exit status 1
    Complete output from command /Users/marca/python/virtualenvs/jq.py/bin/python -c "import setuptools, tokenize; __file__='/Users/marca/dev/git-repos/jq.py/setup.py'; exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" develop --no-deps:
...

from jq.py.

mwilliamson avatar mwilliamson commented on July 29, 2024

Do you get that error when jq is being built, or the Python bindings? If it's jq, then it's probably best to try to build jq 1.4 separately to see if you get any errors. If you do, then the jq maintainers themselves can probably help more than I can.

from jq.py.

msabramo avatar msabramo commented on July 29, 2024

It's when building the Python bindings - let me share more of the output:

...
    building 'jq' extension
    gcc -fno-strict-aliasing -fno-common -dynamic -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/marca/dev/git-repos/jq.py/jq-jq-1.4 -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c jq.c -o build/temp.macosx-10.4-x86_64-2.7/jq.o
    jq.c:1242:104: warning: passing 'const char *' to parameter of type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
        ((struct __pyx_vtabstruct_2jq__ErrorStore *)__pyx_v_store->__pyx_vtab)->store_error(__pyx_v_store, jv_string_value(__pyx_v_error));
                                                                                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
    jq.c:4579:42: warning: function '__Pyx_PyInt_AsSignedLongLong' is not needed and will not be emitted [-Wunneeded-internal-declaration]
    static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* x) {
                                             ^
    22 warnings generated.
    gcc -bundle -undefined dynamic_lookup build/temp.macosx-10.4-x86_64-2.7/jq.o /Users/marca/dev/git-repos/jq.py/jq-jq-1.4/.libs/libjq.a -o /Users/marca/dev/git-repos/jq.py/jq.so
    ld: targeted OS version does not support use of thread local variables in _jv_nomem_handler for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    error: command 'gcc' failed with exit status 1
    Complete output from command /Users/marca/python/virtualenvs/jq.py/bin/python -c "import setuptools, tokenize; __file__='/Users/marca/dev/git-repos/jq.py/setup.py'; exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" develop --no-deps:
...

jq itself has already built OK:

[marca@marca-mac2 jq.py]$ ll jq-jq-1.4/jq
-rwxr-xr-x+ 1 marca  staff   274K Jan 16 19:09 jq-jq-1.4/jq*
[marca@marca-mac2 jq.py]$ file jq-jq-1.4/jq
jq-jq-1.4/jq: Mach-O 64-bit executable x86_64

from jq.py.

msabramo avatar msabramo commented on July 29, 2024

Note to self: A nicer way to reproduce this that result in less junky output is:

$ YACC=/usr/local/Cellar/bison/3.0.3/bin/yacc python setup.py build
...
creating build/lib.macosx-10.4-x86_64-2.7
gcc -bundle -undefined dynamic_lookup build/temp.macosx-10.4-x86_64-2.7/jq.o jq-jq-1.4/.libs/libjq.a -o build/lib.macosx-10.4-x86_64-2.7/jq.so
ld: targeted OS version does not support use of thread local variables in _jv_nomem_handler for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'gcc' failed with exit status 1

from jq.py.

msabramo avatar msabramo commented on July 29, 2024

I wondered if it had to do with the fact that it was using gcc and recent OS X versions prefer clang.

$ YACC=/usr/local/Cellar/bison/3.0.3/bin/yacc CC=clang python setup.py build
...
clang -bundle -undefined dynamic_lookup build/temp.macosx-10.4-x86_64-2.7/jq.o jq-jq-1.4/.libs/libjq.a -o build/lib.macosx-10.4-x86_64-2.7/jq.so
ld: targeted OS version does not support use of thread local variables in _jv_nomem_handler for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'clang' failed with exit status 1

No dice.

from jq.py.

msabramo avatar msabramo commented on July 29, 2024

Huh? It works when I do the clang link command manually from the shell; it just doesn't work within python setup.py build?

[marca@marca-mac2 jq.py]$ clang -bundle -undefined dynamic_lookup build/temp.macosx-10.4-x86_64-2.7/jq.o jq-jq-1.4/.libs/libjq.a -o build/lib.macosx-10.4-x86_64-2.7/jq.so
[marca@marca-mac2 jq.py]$ echo $?
0
[marca@marca-mac2 jq.py]$ ls -l build/lib.macosx-10.4-x86_64-2.7/jq.so
-rwxr-xr-x+ 1 marca  staff  304424 Jan 17 09:26 build/lib.macosx-10.4-x86_64-2.7/jq.so*
[marca@marca-mac2 jq.py]$ cp build/lib.macosx-10.4-x86_64-2.7/jq.so .
[marca@marca-mac2 jq.py]$ ipython --no-banner

In [1]: from jq import jq

In [2]: jq(".[]+1").transform([1, 2, 3], multiple_output=True)
Out[2]: [2, 3, 4]

from jq.py.

msabramo avatar msabramo commented on July 29, 2024

I wonder if this has something to do with MACOSX_DEPLOYMENT_TARGET ?

from jq.py.

msabramo avatar msabramo commented on July 29, 2024

Ooh. The following appears to work:

MACOSX_DEPLOYMENT_TARGET="10.5" YACC=/usr/local/Cellar/bison/3.0.3/bin/yacc CC=clang python setup.py build

Later on, I'll try to formulate this into a PR so that it's automatic. Or failing that I'll send a PR to add a note to the README.

from jq.py.

mwilliamson avatar mwilliamson commented on July 29, 2024

Thanks for investigating! I'm not at all familiar with building on a Mac: do you know why the default deployment target doesn't work?

from jq.py.

msabramo avatar msabramo commented on July 29, 2024

Good question. I'm not too familiar with OS X build stuff easier but I found this in the python-spidermonkey project at http://python-spidermonkey.googlecode.com/svn/trunk/setup.py:

try:
    # For some reason, importing Pyrex appears to change the value of
    # the MACOSX_DEPLOYMENT_TARGET to something that may be
    # inaccurate.  So we'll make sure that it's set to whatever it was
    # before we imported Pyrex.
    oldTarget = os.environ.get("MACOSX_DEPLOYMENT_TARGET", "")

    from Pyrex.Distutils import build_ext

    os.environ["MACOSX_DEPLOYMENT_TARGET"] = oldTarget

I'll play with this later.

from jq.py.

msabramo avatar msabramo commented on July 29, 2024

Docs on MACOSX_DEPLOYMENT_TARGET

from jq.py.

msabramo avatar msabramo commented on July 29, 2024

This likely depends on what Python installation one is using and on what version of OS X (as they come with different Python versions in /usr/bin/python.

For example, on my OS X 10.9.5 system:

[marca@marca-mac2 ~]$ which python
/Library/Frameworks/Python.framework/Versions/2.7/bin/python
[marca@marca-mac2 ~]$ /Library/Frameworks/Python.framework/Versions/2.7/bin/python -c 'import sysconfig; print(sysconfig.get_config_var("MACOSX_DEPLOYMENT_TARGET"))'
10.4
[marca@marca-mac2 ~]$ /usr/bin/python -c 'import sysconfig; print(sysconfig.get_config_var("MACOSX_DEPLOYMENT_TARGET"))'
10.9

Some more info on my Python installation; I am not sure if it came like this or I hacked it at some point:

[marca@marca-mac2 ~]$ ag 'MACOSX_DEPLOYMENT_TARGET.*10\.4' /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_sysconfigdata.py
393: 'MACOSX_DEPLOYMENT_TARGET': '10.4',

/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config/Makefile
139:MACOSX_DEPLOYMENT_TARGET=10.4

/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/test/test_sysconfig.py
178:        get_config_vars()['MACOSX_DEPLOYMENT_TARGET'] = '10.4'

from jq.py.

msabramo avatar msabramo commented on July 29, 2024

I upgraded from Python 2.7.6 to Python 2.7.9 and now I have:

[marca@marca-mac2 ~]$ /Library/Frameworks/Python.framework/Versions/2.7/bin/python -c 'import sysconfig; print(sysconfig.get_config_var("MACOSX_DEPLOYMENT_TARGET"))'
10.6

from jq.py.

mwilliamson avatar mwilliamson commented on July 29, 2024

Thanks for the pull requests! I've merged them in and released version 0.1.2 to PyPI, which should hopefully fix the issues.

from jq.py.

msabramo avatar msabramo commented on July 29, 2024

Looks great! Thank you!

❯ workon jq.py
...
❯ pip install jq
Collecting jq
  Downloading jq-0.1.2.tar.gz
Installing collected packages: jq
...
    22 warnings generated.
    /usr/bin/clang -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -g build/temp.macosx-10.6-intel-2.7/jq.o /var/folders/gw/w0clrs515zx9x_55zgtpv4mm0000gp/T/pip-build-RTXOyh/jq/jq-jq-1.4/.libs/libjq.a -o build/lib.macosx-10.6-intel-2.7/jq.so
    ld: warning: ignoring file /var/folders/gw/w0clrs515zx9x_55zgtpv4mm0000gp/T/pip-build-RTXOyh/jq/jq-jq-1.4/.libs/libjq.a, file was built for archive which is not the architecture being linked (i386): /var/folders/gw/w0clrs515zx9x_55zgtpv4mm0000gp/T/pip-build-RTXOyh/jq/jq-jq-1.4/.libs/libjq.a
Successfully installed jq-0.1.2

❯ ipython --no-banner

In [1]: from jq import jq

In [2]: jq(".[]+1").transform([1, 2, 3], multiple_output=True)
Out[2]: [2, 3, 4]

Thanks!

from jq.py.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.