← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #688984]: IDE: imported helper.py files are not automatically reimported if changed

 

Question #688984 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/688984

RaiMan proposed the following answer:
This is a temporary solution until it works with plain .py files as
well.

For development use the working .sikuli structure (what you already do
in the IDE).

In main.py add before the imports (it does nothing during development,
but does the trick when running the jar)

if not getBundlePath() in sys.path: sys.path.insert(0, getBundlePath())


For distribution make an extra folder containing (copies!):

- main.sikuli
  - main.py
  - helper.py
  - images.py
  - copies of all images from images.sikuli

open this main.sikuli in the IDE (to not get confused no other tabs,
only this one)

run exportAsJar from the file menu, which should produce the
main_sikuli.jar.

Now you can test the jar:

java -jar <path-to>\sikulix.jar -r <path-to>\main_sikuli.jar.

The magic behind:
- helper .py are created and compiled (__main__.py and __run__.py)
- all .py files are compiled to the internal form
- the stuff is packed into the jar
- when running the jar:
   - everything is exported to a temp-folder
   - now the temp-folder is the bundle-path (but not added to sys.path automatically)
   - hence the one-liner above does the trick

Hope it helps

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.