SikuliX on sonatype

Asked by Stephen

Hi,

I am wrapping Sikuli into a Java BDD framework. The approach we are taking is to make Python calls through Jython.

I appear to need to depend on sikulix.jar and sikulixapi.jar jar. I can find sikulixapi.jar on oss.sonatype.org, but not sikulix.jar. Should I be able to find it, or am I missing some fundamental bit of information?

Many Thanks

Steve Lake.

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

- The approach we are taking is to make Python calls through Jython.
could you be a bit more specific about that?
It would help me to suggest the right solution.

- sikulixapi.jar on MavenCentral/OSSRH
... is only for use in Maven projects as a dependency
The artefact itself is not useable.

- sikulix.jar can only be produced via setup
... as well as sikulixapi.jar as a useable artefact in non-Maven projects.

Version 1.1.0 final is out: http://sikulix.com

Revision history for this message
Stephen (stephen-j-lake) said :
#2

Hi,
Thanks for the speedy response.

Fundamentally we are providing a way for a Java process to enumerate the xxx.sikuli‘s, and then for each sikuli using the Jython reflection to enumerate all the functions. We then provide a facility for the python function to be called.

The thing that we are falling over on is where we try and include the Sikuli base python methods:

pythonInterpreter.exec("from sikuli.Sikuli import *");

When this is executed in the absence of the sikuli.jar we get the following error.

Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named sikuli

 at org.python.core.Py.ImportError(Py.java:296)
 at org.python.core.imp.import_first(imp.java:774)
 at org.python.core.imp.import_module_level(imp.java:856)
 at org.python.core.imp.importName(imp.java:936)
 at org.python.core.ImportFunction.__call__(__builtin__.java:1278)
 at org.python.core.PyObject.__call__(PyObject.java:373)
 at org.python.core.__builtin__.__import__(__builtin__.java:1231)
 at org.python.core.imp.importAll(imp.java:1056)
 at org.python.pycode._pyx11.f$0(<string>:1)
 at org.python.pycode._pyx11.call_function(<string>)
 at org.python.core.PyTableCode.call(PyTableCode.java:165)
 at org.python.core.PyCode.call(PyCode.java:18)
 at org.python.core.Py.runCode(Py.java:1302)
 at org.python.core.Py.exec(Py.java:1346)
 at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:206)
 at org.chorusbdd.chorus.sikulix.SikuliManager.populateSikuliPathFromRootsInPythonInterpretor(SikuliManager.java:44)

You can see the current fork with the early sikuli integration code in:

https://github.com/lakestephen/Chorus/blob/master/chorus-sikulix/src/main/java/org/chorusbdd/chorus/sikulix/SikuliManager.java

look specifically at the populateSikuliPathFromRootsInPythonInterpretor() method

Revision history for this message
Stephen (stephen-j-lake) said :
#3

(Setting Question to 'I Still Need An Answer')

Revision history for this message
Best RaiMan (raimund-hocke) said :
#4

ok, thanks I will have a look.

... but this message usually means, that sikulixapi.jar/Lib is not on Jython's sys.path (In the SikuliX context this is assured internally at start up)

For other usages we have the helper (e.g. running scripts with plain Jython)
import org.sikuli.script.SikulixForJython

... in all cases sikulixapi.jar must be on the java classpath at runtime as well as the Jython stuff.

Revision history for this message
RaiMan (raimund-hocke) said :
#5

I had a short look:

I guess, you have to put the
interpreter.exec("from sikuli.Sikuli import *");

after the sys.path loop (having arranged it according to comment #4

I do not recommend to use sikulix.jar in a Maven project (you have some artefact in your fork).

just add
    <dependency>
      <groupId>org.python</groupId>
      <artifactId>jython-standalone</artifactId>
      <version>2.7.0</version>
    </dependency>

to your pom and you have it on the classpath.

to get what you want you only need
- the sikulxapi.jar containing the Java API and the Python layer
- and the jython jar

Revision history for this message
RaiMan (raimund-hocke) said :
#6

BTW: It will still take me some days to finally get sikulixapi.jar on MavenCentral, so you have to live with the snapshot from OSSRH in the moment (same codebase as the final 1.1.0)

Revision history for this message
Stephen (stephen-j-lake) said :
#7

Thanks again for the response's.

The important part I had missed was the step to initialize through SikulixForJython. I guess when the other jar was on the classpath, some static initialisation was doing that step for me. It all works with the SNAPSHOT jar at the moment, and will switch to the production version when available.

Revision history for this message
Stephen (stephen-j-lake) said :
#8

Thanks RaiMan, that solved my question.