Jpy Python-Java bridge version

I am trying to install the snappy Python binding on a MacBook Pro and the installer is looking for jpy.macosx-10.6-x86_64-2.7.zip, which is not contained in the distribution jar file. Can I use an alternate jpy file (compiled locally from source) with the snappy installer?

Many thanks.

Hi Gary, sorry for this! Unfortunately the standard libraries for Mac OS come in a number of partly incompatible flavours and we only have to two of them here for testing. If your time allows for, you could try building the file itself. (This would also be a great contribution to SNAP!). This is what you would have to do:

  1. Make sure an up-to-date JDK 8 is installed, preferably the Oracle distribution, because this is the one we use in SNAP

  2. Make the JDK_HOME env var points to the JDK installation directory. If this variable is already in use, you can also set JPY_JDK_HOME

  3. Make sure Apache Maven 3 is installed

  4. Then build jpy as follows

    git clone https://github.com/bcdev/jpy.git
    cd jpy
    python setup.py --maven build

If this succeeds, there will be the file jpy.macosx-10.6-x86_64-2.7.zip in the jpy/build directory. I will then tell you, how to proceed with it.

Hi Norman,

Thanks for the reply – I understand the number of combinations is not straight forward!

I have created the file jpy.macosx-10.6-x86_64-2.7.zip using the instructions below.

Cheers,

Gary

Thanks Gary! Now unpack the zip into your ~/.snap/snap-python/snappy directory (which should have been already created) so that you have jpy.so, jdl.so, and jpyutil.py in there. Then cd into snappy and type

> python ./jpyutil.py -j -p

assuming JDK_HOME is still set to the JDK you’ve used to build jpy. You can also use

> python ./jpyutil.py -j -p --java_home <jdk-or-jre-8-path>

In order to make all this easier, I’ve also just created https://senbox.atlassian.net/browse/SNAP-199: Allow custom SNAP-Python configurations by manual jpy builds. Note that all this only happens, if we don’t have precompiled binaries for the target platform.

Thanks Norman.

The snappy module is now installed.

Cheers,

Gary

So you can successfully run the examples?

Hi Norma,

No, I haven’t tried the examples. I loaded the module and read in one SLSTR TDS band.

Are there specific test files to run the examples on?

Cheers,

Gary

  • snappy/examples/*.py --> Python sample scripts, API usage demos
  • snappy/testdata/MER_FRS_L1B_SUBSET.dim --> test dataset (BEAM-DIMAP
    format) to be used for sample code, pass as 1st argument to scripts

Hi Forman,

thanks for developing this stuff that I learned during the Hackathon. I was trying to using snappy from an isolated virtualenv environment but when I attempted to install jpy by running PIP then it failed. I filed a ticket on github https://github.com/bcdev/jpy/issues/65

Please let me know if I can be useful to solve this.

Many thanks,
Francesco

HI Norman,

Mac OS 10.11.5

I have installed apache maven 3.3.9, and jdk "/Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home/ ". However the build fails with this error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project jpy: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test failed: The forked VM terminated without saying properly goodbye. VM crash or System.exit called ? -> [Help 1]

This means that it does not successfully create the jpy zip file you mentioned in the jpy/build directory.
I do get these files:
dist/jpy-0.9_SNAPSHOT-cp27-none-macosx_10_5_x86_64.whl
build/lib.macosx-10.5-x86_64-2.7

A little concerned with the 10.5 not 10.6 as in your example.

Any help very much appreciated!

Hi Mark,

Thanks for reporting this, and sorry - such build errors are always annoying. However, I’ll need the test logs to see where the error actually originated. Can you pls attach them or just copy+paste the outputs of the failing tests. Also the JVM dump file (hs_err_pid.log or so) would be helpful.

Norman

Hi Norman!
My zip file is not created after running “python setup.py --maven build”.

The process stops with following message:
error: command ‘cl.exe’ failed: No such file or directory

In my jpy/build directory i can only find the following files:
lib.win-amd64-3.5
temp.win-amd64-3.5
…I can’t find the needed zip file here

I don’t know how to resolve this problem.
I would be very thankful if you could help me!

Thanks in advance,
Phil

@Phil, cl.exe is the Windows C/C++ compiler which you’ll need for building jpy. See notes in README.rst file.

Regards
Norman

@Phil, update: just tried to build jpy for Python 3.5 on Windows 10 for the first time. It seems that some features of the Python 3.5 setuptools module changed in an incompatible way, at least for the Windows platform. The first thing I recognized was that the goal bdist_wheeldidn’t work anymore so I had to pip install wheel. But then I failed having the same error as you, see below. This is a pitty, because we seem to need a customized build step for Python 3.5, therefore fixing this will take some time, sorry for this.


…
creating build\temp.win32-3.5\Release\Users\Norman\JavaProjects\jpy\src
creating build\temp.win32-3.5\Release\Users\Norman\JavaProjects\jpy\src\main
creating build\temp.win32-3.5\Release\Users\Norman\JavaProjects\jpy\src\main\c
creating build\temp.win32-3.5\Release\Users\Norman\JavaProjects\jpy\src\main\c\jni
cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -DWIN32=1 -IC:\Users\Norman\JavaProjects\jpy\src\main\c “-IC:\Program Files\Java\jdk1.8.0_112\include” “-IC:\Program Files\Java\jdk1.8.0_112\include\win32” -ID:\jpy\Python35\include -ID:\jpy\Python35\include /TcC:\Users\Norman\JavaProjects\jpy\src\main\c\jpy_module.c /Fobuild\temp.win32-3.5\Release\Users\Norman\JavaProjects\jpy\src\main\c\jpy_module.obj
error: command ‘cl.exe’ failed: No such file or directory

Hi Norman, thanks for your answers!

how long do you think fixing will take?
is there a way to avoid this problem? (Maybe doing the same on a windows 7 PC or with an older python version?)
I want to use snappy on python for my bachelor thesis, so I don´t know if its better to use the SNAP toolbox instead.
I have 51 satellite images, do you know another way to “automate” the preprocessing process?

Thanks for your helpfulness :slight_smile:
Best regards,
Phil

What kind of pre-processing do you need to do? Which Satellite(s)?

Cheers
Andreas

Hi Andreas,

I am working with Sentinel-1-Data (IW and VV/VH), and want to preprocess it with following steps:

  1. Read (Import)
  2. TOPSAR Split
  3. Apply Orbitfile
  4. Multilooking
  5. TOPSAR Deburst
  6. Speckle Filtering
  7. Range Doppler Geocoding

Thanks,
Philipp

Hi Philipp

Sorry, if it would have been Sentinel-2 or other Optical data then I could have helped you. But with radar I have no experience with alternative approaches. :wink:

Cheers,
Andreas

PS: Did you try it with the command window prompt? Write “gpt” in your command window to see all tools. Or if you know the name of the tool you are going to use e.g. “gpt -h Multi-Temporal-Speckle-Filter” or “gpt -h TOPSAR-Split”. These command window prompts you can also automatize in Python.

Hi Andreas,

ok I will give it a try!
But could you show me how to automate this command window prompts in python without a snappy installation?

Thanks for your help,
Best regards,
Philipp

In python you also can call the command prompt. e.g.:

import os
cmd = “gpt -h TOPSAR-Split”
os.system(cmd)

There are also other functions which allows you to search for files or folders in a certain directory and give you back a list of strings. With these you can iterate through your 51 files and adjust the “cmd” string/prompt or do whatever you need (e.g. adjust the XML-File).

Cheers,
Andreas