LeeKamentsky / python-javabridge

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

pip install using Cython 3.0.0 fails with "Function signature does not match previous declaration" error #210

Open patkaehuaea opened 11 months ago

patkaehuaea commented 11 months ago

A few previous issues reference pip install from master to resolve errors. I'm installing from master, but seeing a new error since Cython 3.0.0 was released on July 17th - _javabridge_mac.pyx:34:5: Function signature does not match previous declaration.

Attempting the same install using Cython 0.29.36 works as expected.

environment details

$ python --version
Python 3.10.12

$ java -version
openjdk version "20.0.1" 2023-04-18
OpenJDK Runtime Environment Homebrew (build 20.0.1)
OpenJDK 64-Bit Server VM Homebrew (build 20.0.1, mixed mode, sharing)

$ echo $JAVA_HOME
/opt/homebrew/Cellar/openjdk/20.0.1/libexec/openjdk.jdk/Contents/Home

$ sw_vers -productVersion 
13.4.1

$ system_profiler SPSoftwareDataType
Software:

    System Software Overview:

      System Version: macOS 13.4.1 (c) (22F770820d)
      Kernel Version: Darwin 22.5.0
      Boot Volume: Macintosh HD
      Boot Mode: Normal
      Computer Name: MacBook Pro
      User Name: pat
      Secure Virtual Memory: Enabled
      System Integrity Protection: Enabled
      Time since boot: 2 days, 10 hours, 7 minutes

steps to reproduce

show cython version

$ pip show cython
Name: Cython
Version: 3.0.0
Summary: The Cython compiler for writing C extensions in the Python language.
Home-page: https://cython.org/
Author: Robert Bradshaw, Stefan Behnel, Dag Seljebotn, Greg Ewing, et al.
Author-email: cython-devel@python.org
License: Apache-2.0
Location: /Users/pat/temp/foo/.venv/lib/python3.10/site-packages
Requires: 
Required-by: 

attempt javabridge install from master

$ pip install https://github.com/LeeKamentsky/python-javabridge/archive/master.zip#egg=javabridge

...

Error compiling Cython file:
      ------------------------------------------------------------
      ...
          void MacRunLoopStop() nogil
          void MacRunLoopReset() nogil
          int MacIsMainThread() nogil
          void MacRunLoopRunInMode(double) nogil

      cdef void StopVM(JavaVM *vm):
           ^
      ------------------------------------------------------------

      _javabridge_mac.pyx:34:5: Function signature does not match previous declaration

...

subprocess.CalledProcessError: Command '['/Users/pat/temp/foo/.venv/bin/python3.10', '-m', 'cython', '-3', '/private/var/folders/zp/yc7pxt6x7zj01_vr01sqznx00000gp/T/pip-install-h8pjccy7/javabridge_fc0d7b9f2f59493a8e3e5116191f8cb4/_javabridge.pyx', '/private/var/folders/zp/yc7pxt6x7zj01_vr01sqznx00000gp/T/pip-install-h8pjccy7/javabridge_fc0d7b9f2f59493a8e3e5116191f8cb4/_javabridge_mac.pyx', '/private/var/folders/zp/yc7pxt6x7zj01_vr01sqznx00000gp/T/pip-install-h8pjccy7/javabridge_fc0d7b9f2f59493a8e3e5116191f8cb4/_javabridge_nomac.pyx']' returned non-zero exit status 1.

install cython 0.29.36

$ pip uninstall cython
Found existing installation: Cython 3.0.0
Uninstalling Cython-3.0.0:
  Would remove:
    /Users/pat/temp/foo/.venv/bin/cygdb
    /Users/pat/temp/foo/.venv/bin/cython
    /Users/pat/temp/foo/.venv/bin/cythonize
    /Users/pat/temp/foo/.venv/lib/python3.10/site-packages/Cython-3.0.0.dist-info/*
    /Users/pat/temp/foo/.venv/lib/python3.10/site-packages/Cython/*
    /Users/pat/temp/foo/.venv/lib/python3.10/site-packages/cython.py
    /Users/pat/temp/foo/.venv/lib/python3.10/site-packages/pyximport/*
Proceed (Y/n)? y
  Successfully uninstalled Cython-3.0.0

$ pip install Cython==0.29.36
Collecting Cython==0.29.36
  Obtaining dependency information for Cython==0.29.36 from https://files.pythonhosted.org/packages/3f/d6/9eed523aeaca42acbaa3e6d3850edae780dc7f8da9df1bf6a2ceb851839c/Cython-0.29.36-py2.py3-none-any.whl.metadata
  Using cached Cython-0.29.36-py2.py3-none-any.whl.metadata (3.1 kB)
Using cached Cython-0.29.36-py2.py3-none-any.whl (988 kB)
Installing collected packages: Cython

attempt javabridge install from master again - SUCCESS

$ pip install https://github.com/LeeKamentsky/python-javabridge/archive/master.zip#egg=javabridge
Collecting javabridge
  Using cached https://github.com/LeeKamentsky/python-javabridge/archive/master.zip
  Preparing metadata (setup.py) ... done
Requirement already satisfied: numpy in ./.venv/lib/python3.10/site-packages (from javabridge) (1.25.1)
Installing collected packages: javabridge
  DEPRECATION: javabridge is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/8559
  Running setup.py install for javabridge ... done
Successfully installed javabridge-0.0.0

[notice] A new release of pip is available: 23.0.1 -> 23.2.1
[notice] To update, run: pip install --upgrade pip

run test

$ cat test_javabridge.py 
#!/Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8
import os
import javabridge

javabridge.start_vm(run_headless=True)
try:
        print(javabridge.run_script('java.lang.String.format("Hello, %s!", greetee);', dict(greetee='world')))
finally:
        javabridge.kill_vm()

$ python test_javabridge.py 
Hello, world!
LeeKamentsky commented 11 months ago

Hi Pat, thanks for reporting this. I'll put together the environment today to reproduce the problem and see what the fix is. Usually these things are a warning in a previous version that's become an error in the current and are easy to fix. Will reference this issue with the check in.

benjamin-asdf commented 6 months ago

HI, I am trying

pip3 install https://github.com/LeeKamentsky/python-javabridge/archive/master.zip#egg=javabridge

to get around #209 and get the error reported here.

Is there perhaps a working version other than master? Cheers.