optapy / optapy

OptaPy is an AI constraint solver for Python to optimize planning and scheduling problems.

Home Page:https://www.optapy.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JPyInterpreter wheel cannot be built locally

mmmvvvppp opened this issue · comments

I'm trying to execute JpyInterpreter's unit tests locally to confirm a potential bug we're having with type conversion. I am unable to build the wheel with the steps found in /jpyinterpreter/README.doc.

With JAVA_HOME configured:

  1. Navigate to /jpyinterpreter (although behavior is similar from the root directory).
  2. Install python build module.
  3. Run python -m build

I receive the following error:

* Building wheel...
running bdist_wheel
running build
running build_py
[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] 'dependencies.dependency.version' for org.ow2.asm:asm:jar is missing. @ line 34, column 17
[ERROR] 'dependencies.dependency.version' for org.apache.commons:commons-collections4:jar is missing. @ line 48, column 17
[ERROR] 'dependencies.dependency.version' for org.slf4j:slf4j-api:jar is missing. @ line 54, column 17
[ERROR] 'dependencies.dependency.version' for ch.qos.logback:logback-classic:jar is missing. @ line 58, column 17
[ERROR] 'dependencies.dependency.version' for org.junit.jupiter:junit-jupiter-api:jar is missing. @ line 65, column 17
[ERROR] 'dependencies.dependency.version' for org.junit.jupiter:junit-jupiter-engine:jar is missing. @ line 70, column 17
[ERROR] 'dependencies.dependency.version' for org.junit.jupiter:junit-jupiter-params:jar is missing. @ line 75, column 17
[ERROR] 'dependencies.dependency.version' for org.assertj:assertj-core:jar is missing. @ line 80, column 17
[ERROR] 'dependencies.dependency.version' for org.mockito:mockito-core:jar is missing. @ line 85, column 17
 @ 
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]   
[ERROR]   The project org.optaplanner:jpyinterpreter:8.31.1.Final (/private/var/folders/z4/q41vbbyj6mlgjkjlbqfg37700000gn/T/build-via-sdist-wubq27oo/jpyinterpreter-8.31.1b0/pom.xml) has 9 errors
[ERROR]     'dependencies.dependency.version' for org.ow2.asm:asm:jar is missing. @ line 34, column 17
[ERROR]     'dependencies.dependency.version' for org.apache.commons:commons-collections4:jar is missing. @ line 48, column 17
[ERROR]     'dependencies.dependency.version' for org.slf4j:slf4j-api:jar is missing. @ line 54, column 17
[ERROR]     'dependencies.dependency.version' for ch.qos.logback:logback-classic:jar is missing. @ line 58, column 17
[ERROR]     'dependencies.dependency.version' for org.junit.jupiter:junit-jupiter-api:jar is missing. @ line 65, column 17
[ERROR]     'dependencies.dependency.version' for org.junit.jupiter:junit-jupiter-engine:jar is missing. @ line 70, column 17
[ERROR]     'dependencies.dependency.version' for org.junit.jupiter:junit-jupiter-params:jar is missing. @ line 75, column 17
[ERROR]     'dependencies.dependency.version' for org.assertj:assertj-core:jar is missing. @ line 80, column 17
[ERROR]     'dependencies.dependency.version' for org.mockito:mockito-core:jar is missing. @ line 85, column 17
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException


A similar issue happens when trying to install the package using `pyproject.toml`

Try doing a ./mvnw clean install in the root directory of optapy first. That should install the parent pom locally, allowing python -m build to use it. The problem is the poms for this project are not in maven central, which means maven cannot find the parent pom (which contains the dependency versions) when processing the pom of jpyinterpreter (which has optapy-parent as the parent pom).

Thank you Christopher. Following your steps I was able to build the wheels for optapy and jpyinterpreter.

I'm still having issues getting to the point of running the pytest unit tests. After installing venv, activating it, installing pytest into the venv, and restarting the venv, I attempt to run pytest tests from the jpyinterpreter directory, but get a Java exception about org.optaplanner import failing.

(venv) ➜  jpyinterpreter git:(main) ✗ pytest                    
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "org.jpype.JPypeContext.java", line -1, in org.jpype.JPypeContext.callMethod
INTERNALERROR> Exception: Java Exception
INTERNALERROR> 
INTERNALERROR> The above exception was the direct cause of the following exception:
INTERNALERROR> 
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/Users/mmmvvvppp/workspaces/optapy/jpyinterpreter/venv/lib/python3.10/site-packages/jpype/imports.py", line 195, in find_spec
INTERNALERROR>     cls = _jpype._java_lang_Class.forName(name, True, _jpype.JPypeClassLoader)
INTERNALERROR> java.lang.java.lang.ClassNotFoundException: java.lang.ClassNotFoundException: org.optaplanner
INTERNALERROR> 
INTERNALERROR> The above exception was the direct cause of the following exception:
INTERNALERROR> 
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/Users/mmmvvvppp/workspaces/optapy/jpyinterpreter/venv/lib/python3.10/site-packages/_pytest/main.py", line 268, in wrap_session
INTERNALERROR>     config.hook.pytest_sessionstart(session=session)
INTERNALERROR>   File "/Users/mmmvvvppp/workspaces/optapy/jpyinterpreter/venv/lib/python3.10/site-packages/pluggy/_hooks.py", line 265, in __call__
INTERNALERROR>     return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
INTERNALERROR>   File "/Users/mmmvvvppp/workspaces/optapy/jpyinterpreter/venv/lib/python3.10/site-packages/pluggy/_manager.py", line 80, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>   File "/Users/mmmvvvppp/workspaces/optapy/jpyinterpreter/venv/lib/python3.10/site-packages/pluggy/_callers.py", line 60, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/Users/mmmvvvppp/workspaces/optapy/jpyinterpreter/venv/lib/python3.10/site-packages/pluggy/_result.py", line 60, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/Users/mmmvvvppp/workspaces/optapy/jpyinterpreter/venv/lib/python3.10/site-packages/pluggy/_callers.py", line 39, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/Users/mmmvvvppp/workspaces/optapy/jpyinterpreter/tests/conftest.py", line 172, in pytest_sessionstart
INTERNALERROR>     jpyinterpreter.init(class_output_path=class_output_path)
INTERNALERROR>   File "/Users/mmmvvvppp/workspaces/optapy/jpyinterpreter/venv/lib/python3.10/site-packages/jpyinterpreter/jvm_setup.py", line 45, in init
INTERNALERROR>     from org.optaplanner.jpyinterpreter import CPythonBackedPythonInterpreter
INTERNALERROR>   File "/Users/mmmvvvppp/workspaces/optapy/jpyinterpreter/venv/lib/python3.10/site-packages/jpype/imports.py", line 203, in find_spec
INTERNALERROR>     raise ImportError("Failed to import '%s'" % name) from ex
INTERNALERROR> ImportError: Failed to import 'org.optaplanner'

Any further assistance you could provide would be appreciated.

Run tests using pytest --import-mode=importlib or tox; the default import mode for pytest does not work well with JPype

Thanks, that did the trick! I really appreciate the timely support.