LeeKamentsky / python-javabridge

Python wrapper for the Java Native Interface
Other
116 stars 62 forks source link

error: incompatible pointer to integer conversion returning 'void *' from a function with result type 'int' [-Wint-conversion] #212

Open PlumpMath opened 10 months ago

PlumpMath commented 10 months ago

hello. I'm nix(nix-darwin) user.

mac intel sonoma, python 3.10

The build log is as follows: Sourcing python-remove-tests-dir-hook Sourcing python-catch-conflicts-hook.sh Sourcing python-remove-bin-bytecode-hook.sh Sourcing setuptools-build-hook Using setuptoolsShellHook Sourcing pypa-install-hook Sourcing python-imports-check-hook.sh Using pythonImportsCheckPhase Sourcing python-namespaces-hook Sourcing python-catch-conflicts-hook.sh @nix { "action": "setPhase", "phase": "unpackPhase" } unpacking sources unpacking source archive /nix/store/mc0lzh2rpsh54hwd6vasnd064ikndbbk-source source root is source setting SOURCE_DATE_EPOCH to timestamp 315619200 of file source/strtoull.c @nix { "action": "setPhase", "phase": "patchPhase" } patching sources @nix { "action": "setPhase", "phase": "configurePhase" } configuring no configure script, doing nothing @nix { "action": "setPhase", "phase": "buildPhase" } building /private/tmp/nix-build-python3.10-python-javabridge-master.drv-0/source/./setup.py:24: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives import distutils.log /nix/store/1paa9m6vzp84fjjxs1ja8wi6nbnl9isg-python3.10-setuptools-68.2.2/lib/python3.10/site-packages/_distutils_hack/__init__.py:18: UserWarning: Distutils was imported before Setuptool s, but importing Setuptools also replaces thedistutilsmodule insys.modules`. This may lead to undesirable behaviors or errors. To avoid these issues, avoid using distutils directly , ensure that setuptools is installed in the traditional way (e.g. not an editable install), and/or make sure that setuptools is always imported before distutils. warnings.warn( /nix/store/1paa9m6vzp84fjjxs1ja8wi6nbnl9isg-python3.10-setuptools-68.2.2/lib/python3.10/site-packages/_distutils_hack/init.py:33: UserWarning: Setuptools is replacing distutils. warnings.warn("Setuptools is replacing distutils.") /nix/store/1paa9m6vzp84fjjxs1ja8wi6nbnl9isg-python3.10-setuptools-68.2.2/lib/python3.10/site-packages/setuptools/init.py:80: _DeprecatedInstaller: setuptools.installer and fetch_buil d_eggs are deprecated. !!

    ********************************************************************************
    Requirements should be satisfied by a PEP 517 installer.
    If you are using pip, you can try `pip install --use-pep517`.
    ********************************************************************************

!! dist.fetch_build_eggs(dist.setup_requires) running build running build_py creating build creating build/lib.macosx-10.12-x86_64-cpython-310 creating build/lib.macosx-10.12-x86_64-cpython-310/javabridge copying javabridge/jutil.py -> build/lib.macosx-10.12-x86_64-cpython-310/javabridge copying javabridge/locate.py -> build/lib.macosx-10.12-x86_64-cpython-310/javabridge copying javabridge/init.py -> build/lib.macosx-10.12-x86_64-cpython-310/javabridge copying javabridge/wrappers.py -> build/lib.macosx-10.12-x86_64-cpython-310/javabridge copying javabridge/noseplugin.py -> build/lib.macosx-10.12-x86_64-cpython-310/javabridge creating build/lib.macosx-10.12-x86_64-cpython-310/javabridge/tests copying javabridge/tests/init.py -> build/lib.macosx-10.12-x86_64-cpython-310/javabridge/tests copying javabridge/tests/test_cpython.py -> build/lib.macosx-10.12-x86_64-cpython-310/javabridge/tests copying javabridge/tests/test_javabridge.py -> build/lib.macosx-10.12-x86_64-cpython-310/javabridge/tests copying javabridge/tests/test_jutil.py -> build/lib.macosx-10.12-x86_64-cpython-310/javabridge/tests copying javabridge/tests/test_wrappers.py -> build/lib.macosx-10.12-x86_64-cpython-310/javabridge/tests creating build/lib.macosx-10.12-x86_64-cpython-310/javabridge/jars copying javabridge/jars/rhino-1.7R4.jar -> build/lib.macosx-10.12-x86_64-cpython-310/javabridge/jars running build_ext javac /private/tmp/nix-build-python3.10-python-javabridge-master.drv-0/source/java/org/cellprofiler/runnablequeue/RunnableQueue.java jar cf /private/tmp/nix-build-python3.10-python-javabridge-master.drv-0/source/build/lib.macosx-10.12-x86_64-cpython-310/javabridge/jars/runnablequeue.jar -C /private/tmp/nix-build-pytho n3.10-python-javabridge-master.drv-0/source/java org/cellprofiler/runnablequeue/RunnableQueue.class -C /private/tmp/nix-build-python3.10-python-javabridge-master.drv-0/source/java org/ce llprofiler/runnablequeue/RunnableQueue$1.class javac /private/tmp/nix-build-python3.10-python-javabridge-master.drv-0/source/java/org/cellprofiler/javabridge/test/RealRect.java jar cf /private/tmp/nix-build-python3.10-python-javabridge-master.drv-0/source/build/lib.macosx-10.12-x86_64-cpython-310/javabridge/jars/test.jar -C /private/tmp/nix-build-python3.10-pyt hon-javabridge-master.drv-0/source/java org/cellprofiler/javabridge/test/RealRect.class javac /private/tmp/nix-build-python3.10-python-javabridge-master.drv-0/source/java/org/cellprofiler/javabridge/CPython.java /private/tmp/nix-build-python3.10-python-javabridge-master.drv -0/source/java/org/cellprofiler/javabridge/CPythonInvocationHandler.java Note: /private/tmp/nix-build-python3.10-python-javabridge-master.drv-0/source/java/org/cellprofiler/javabridge/CPythonInvocationHandler.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. jar cf /private/tmp/nix-build-python3.10-python-javabridge-master.drv-0/source/build/lib.macosx-10.12-x86_64-cpython-310/javabridge/jars/cpython.jar -C /private/tmp/nix-build-python3.10- python-javabridge-master.drv-0/source/java org/cellprofiler/javabridge/CPythonInvocationHandler.class -C /private/tmp/nix-build-python3.10-python-javabridge-master.drv-0/source/java org/ cellprofiler/javabridge/CPython.class -C /private/tmp/nix-build-python3.10-python-javabridge-master.drv-0/source/java org/cellprofiler/javabridge/CPython$WrappedException.class -C /priva te/tmp/nix-build-python3.10-python-javabridge-master.drv-0/source/java org/cellprofiler/javabridge/CPython$StackFrame.class -C /private/tmp/nix-build-python3.10-python-javabridge-master. drv-0/source/java org/cellprofiler/javabridge/CPythonInvocationHandler.class warning: _javabridge_osspecific.pxd:12:4: 'JavaVMOption' redeclared warning: _javabridge_osspecific.pxd:19:4: 'JavaVMInitArgs' redeclared warning: _javabridge.pyx:94:4: 'jvalue' redeclared warning: _javabridge.pyx:112:4: 'JavaVMOption' redeclared warning: _javabridge.pyx:119:4: 'JavaVMInitArgs' redeclared warning: _javabridge_osspecific.pxd:12:4: 'JavaVMOption' redeclared warning: _javabridge_osspecific.pxd:19:4: 'JavaVMInitArgs' redeclared warning: _javabridge_mac.pyx:4:4: 'jint' redeclared warning: _javabridge_mac.pyx:5:4: 'jboolean' redeclared warning: _javabridge_mac.pyx:9:4: 'JavaVM' redeclared warning: _javabridge_mac.pyx:14:4: 'JavaVMOption' redeclared warning: _javabridge_mac.pyx:21:4: 'JavaVMInitArgs' redeclared warning: _javabridge_nomac.pxd:15:4: 'JavaVMInitArgs' redeclared warning: _javabridge_nomac.pxd:20:4: 'JavaVMOption' redeclared warning: _javabridge_nomac.pyx:4:4: 'jint' redeclared warning: _javabridge_nomac.pyx:5:4: 'jboolean' redeclared warning: _javabridge_nomac.pyx:9:4: 'JavaVM' redeclared building 'javabridge._javabridge' extension creating build/temp.macosx-10.12-x86_64-cpython-310 clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/nix/store/d4la433q1g4r3hqqxgwgnvzz24l4rqvr-libxcrypt-4.4.36/include -I/nix/store/qlwc7ymlnafhw 368vwwn4bbqcl06xqbc-graalvm-ce-21.0.1/include -I/nix/store/qlwc7ymlnafhw368vwwn4bbqcl06xqbc-graalvm-ce-21.0.1/include/darwin -I/nix/store/fs4cr3wkp63vlmi64k63hqrrfh6jvm79-python3.10-nump y-1.26.1/lib/python3.10/site-packages/numpy/core/include -I/nix/store/c7s2h40q4wqxfxwzbj5g9c3126wz6ryg-python3-3.10.13/include/python3.10 -c javabridge.c -o build/temp.macosx-10.12-x86 64-cpython-310/_javabridge.o In file included from _javabridge.c:752: In file included from /nix/store/fs4cr3wkp63vlmi64k63hqrrfh6jvm79-python3.10-numpy-1.26.1/lib/python3.10/site-packages/numpy/core/include/numpy/arrayobject.h:5: In file included from /nix/store/fs4cr3wkp63vlmi64k63hqrrfh6jvm79-python3.10-numpy-1.26.1/lib/python3.10/site-packages/numpy/core/include/numpy/ndarrayobject.h:12: In file included from /nix/store/fs4cr3wkp63vlmi64k63hqrrfh6jvm79-python3.10-numpy-1.26.1/lib/python3.10/site-packages/numpy/core/include/numpy/ndarraytypes.h:1929: /nix/store/fs4cr3wkp63vlmi64k63hqrrfh6jvm79-python3.10-numpy-1.26.1/lib/python3.10/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-W#warnings]

warning "Using deprecated NumPy API, disable it with " \

^ _javabridge.c:5367:37: warning: cast to smaller integer type 'int' from 'jobject' (aka 'struct _jobject ') [-Wpointer-to-int-cast] pyx_t_1 = Pyx_PyInt_From_int(((int)pyx_v_self->o)); if (unlikely(!pyx_t_1)) __PYX_ERR(0, 475, __pyx_L1_error) ^~~~~~~~ _javabridge.c:5658:37: warning: cast to smaller integer type 'int' from 'jobject' (aka 'struct _jobject ') [-Wpointer-to-int-cast] pyx_t_1 = Pyx_PyInt_From_int(((int)pyx_v_self->o)); if (unlikely(!pyx_t_1)) PYX_ERR(0, 493, pyx_L1_error) ^~~~~~~~ _javabridge.c:5891:37: warning: cast to smaller integer type 'int' from 'jclass' (aka 'struct _jobject *') [-Wpointer-to-int-cast] pyx_t_1 = __Pyx_PyInt_From_int(((int)pyx_v_self->c)); if (unlikely(!pyx_t_1)) PYX_ERR(0, 502, pyx_L1_error) ^~~~~~~~ _javabridge.c:6257:41: warning: cast to smaller integer type 'int' from 'jmethodID' (aka 'struct _jmethodID *') [-Wpointer-to-int-cast] pyx_t_4 = Pyx_PyUnicode_From_int(((int)pyx_v_self->id), 0, ' ', 'x'); if (unlikely(!pyx_t_4)) __PYX_ERR(0, 521, pyx_L1_error) ^~~~~ _javabridge.c:6545:41: warning: cast to smaller integer type 'int' from 'jfieldID' (aka 'struct _jfieldID ') [-Wpointer-to-int-cast] pyx_t_4 = Pyx_PyUnicode_From_int(((int)pyx_v_self->id), 0, ' ', 'x'); if (unlikely(!pyx_t_4)) __PYX_ERR(0, 535, __pyx_L1_error) ^~~~~ _javabridge.c:21286:18: warning: cast to smaller integer type 'int' from 'jobject' (aka 'struct _jobject ') [-Wpointer-to-int-cast] pyx_t_1 = ((((int)pyx_v_s->o) == 0) != 0); ^~~~~ _javabridge.c:21420:18: warning: cast to smaller integer type 'int' from 'jobject' (aka 'struct _jobject ') [-Wpointer-to-int-cast] pyx_t_1 = ((((int)pyx_v_s->o) == 0) != 0); ^~~~~ _javabridge.c:29032:3: error: incompatible pointer to integer conversion returning 'void ' from a function with result type 'int' [-Wint-conversion] import_array(); ^~~~~~ /nix/store/fs4cr3wkp63vlmi64k63hqrrfh6jvm79-python3.10-numpy-1.26.1/lib/python3.10/site-packages/numpy/core/include/numpy/__multiarray_api.h:1559:151: note: expanded from macro 'import_a rray'

define import_array() {if (_import_array() < 0) {PyErr_Print(); PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import"); return NULL; } }

                                                                                                                                                  ^~~~

/nix/store/dgmdis15d7s7vlkfkz5w5b2wnna2syfz-clang-wrapper-16.0.6/resource-root/include/stddef.h:89:16: note: expanded from macro 'NULL'

define NULL ((void*)0)

           ^~~~~~~~~~

8 warnings and 1 error generated. error: command '/nix/store/dgmdis15d7s7vlkfkz5w5b2wnna2syfz-clang-wrapper-16.0.6/bin/clang' failed with exit code 1

`

The build used to work fine before, but it has started failing recently, and the same is true for the CellProfiler repository. I suspect this might be due to updates from Apple causing changes in nixpkgs, but I'm not exactly sure why. Does anyone know the reason for this?

Thanks

yoda-vid commented 5 months ago

I'm also seeing this error when compiling on Mac arm64. Did you find a workaround?

PlumpMath commented 5 months ago

@yoda-vid I'm not looking at Python at all right now, so I'm completely excluding it from installation. I'm not sure about the current state, but I remember that a few months ago, it was not possible to build on Mac. It should only be possible on Linux.

yoda-vid commented 5 months ago

Thanks so much, @PlumpMath! I can compile it on an Intel Mac with Ventura, but it looks like we got the same error on Sonoma (your mac intel sonoma, my mac arm64 sonoma), so maybe something in Sonoma is the culprit here.

LeeKamentsky commented 5 months ago

If anyone has a Mac and can submit a PR that fixes this, I can accept it. This looks like a similar error.

PlumpMath commented 5 months ago

I wish Apple would completely eliminate the use of pointers related to C/C++ in their integration with other languages, just like Steve Jobs, who is in his grave, once eliminated Flash. It would be great if he could rise from the grave and appear saying, 'Don’t use C/C++ anymore!'

PlumpMath commented 4 months ago

Sorry for the off-topic ramble... Every time Mac updates, various Python packages related to C++ always seem to encounter error issues, which is really frustrating. Anyway, with the upgrade to Python version 3.11 as the default on NixOS Linux, builds that used to work are no longer going through. There's something about Cython, and well, it looks like I'll have to go through it stitch by stitch later, but currently, I'm not interested in Python-related projects (I'm tired and sick, just resting and having fun). Someday it'll work again~~, right?

It's pretty obvious that builds like javabridge within nixpkgs might have changed, leading to build failures with the following type of nix code that used to work... However, keeping up with the latest build methods is the most serious issue in python-nix, so I probably won't try it yet. I need to fix it someday and give it a go, but everything is just errors, Huh~.

  JAVABRIDGE-CellProfiler =  with pkgs; buildPythonPackage rec {    
    pname = "python-javabridge";
    version = "master";
    src = inputs.python-javabridge2;
    requirements = '' numpy Cython '';
      nativeBuildInputs = [ graalvm-ce ];
    propagatedBuildInputs = [  numpy  ];
    buildInputs = [ cython  ];
    buildPhase = "  ${python3.interpreter} ./setup.py build  ";
    doCheck = false;
    installPhase = ''
    ${python3.interpreter} setup.py install \
    --install-lib=$out/lib/${python3.libPrefix}/site-packages \
    --prefix="$out"
    cp -rf $out/lib/${python3.libPrefix}/site-packages/python_javabridge-*/javabridge $out/lib/${python3.libPrefix}/site-packages/
    rm -rf $out/bin
  '';
  };

  JAVABRIDGE-LeeKamentsky =  with pkgs; buildPythonPackage rec {        
    pname = "python-javabridge";
    version = "master";
    src = inputs.python-javabridge1;
    requirements = '' numpy Cython '';
      nativeBuildInputs = [ graalvm-ce ];
    propagatedBuildInputs = [  numpy   ];
    buildInputs = [  cython  ];
    buildPhase = "  ${python3.interpreter} ./setup.py build  ";
    doCheck = false;
    installPhase = ''
        ${python3.interpreter} setup.py install \
        --install-lib=$out/lib/${python3.libPrefix}/site-packages \
        --prefix="$out"
        rm -rf $out/bin
        cp -rf $out/lib/${python3.libPrefix}/site-packages/javabridge-*/javabridge $out/lib/${python3.libPrefix}/site-packages/
      '';
  };