jep icon indicating copy to clipboard operation
jep copied to clipboard

Trying to package jep for nixpkgs yields ModuleNotFoundError: No module named 'jep'

Open scalavision opened this issue 4 years ago • 3 comments

nixpkgs uses absolute paths and symlinks, and I try to patch the jep script as follows:

#!/bin/sh

VIRTUAL_ENV=
export VIRTUAL_ENV

LD_LIBRARY_PATH=/nix/store/wkw6fsjasr7jbbrlakxxpbiapa8hws42-python3-3.8.7/lib:/nix/store/wkw6fsjasr7jbbrlakxxpbiapa8hws42-python3-3.8.7/lib/python3.8/site-packages:/nix/store/b71ldqi7p76f12rs6px69vba1przxzil-jep-3.9.1/lib/python3.8/site-packages/jep; export LD_LIBRARY_PATH
LD_PRELOAD="/nix/store/wkw6fsjasr7jbbrlakxxpbiapa8hws42-python3-3.8.7/lib/libpython3.8.so"; export LD_PRELOAD

if test "x$VIRTUAL_ENV" != "x"; then
  PATH="$VIRTUAL_ENV/bin:$PATH"
  export PATH
fi

cp="/nix/store/b71ldqi7p76f12rs6px69vba1przxzil-jep-3.9.1/lib/python3.8/site-packages/jep/jep-3.9.1.jar"
if test "x$CLASSPATH" != "x"; then
    cp="$cp":"$CLASSPATH"
fi

jni_path="/nix/store/b71ldqi7p76f12rs6px69vba1przxzil-jep-3.9.1/lib/python3.8/site-packages/jep"

args=$*
if test "x$args" = "x"; then
  args="/nix/store/b71ldqi7p76f12rs6px69vba1przxzil-jep-3.9.1/lib/python3.8/site-packages/jep/console.py"
fi

exec java -classpath "$cp" -Djava.library.path="$jni_path" jep.Run $args```

The exact command run by the jep script is:

exec java \
  -classpath /nix/store/b71ldqi7p76f12rs6px69vba1przxzil-jep-3.9.1/lib/python3.8/site-packages/jep/jep-3.9.1.jar \
  -Djava.library.path=/nix/store/b71ldqi7p76f12rs6px69vba1przxzil-jep-3.9.1/lib/python3.8/site-packages/jep \
     jep.Run \
     /nix/store/b71ldqi7p76f12rs6px69vba1przxzil-jep-3.9.1/lib/python3.8/site-packages/jep/console.py

I have checked that these paths are actual paths on my system.

The content of site-packages/jep is the following:

ls ./lib/python3.8/site-packages/jep
console.py
java_import_hook.py
jep-3.9.1.jar
libjep.so 
redirect_streams.py 
version.py
__init__.py
jdbc.py
jep.cpython-38-x86_64-linux-gnu.so
 __pycache__ 
shared_modules_hook.py

The stacktrace:

jep.JepException: <class 'ModuleNotFoundError'>: No module named 'jep'
        at <string>.<module>(<string>:1)
        at jep.Jep.eval(Native Method)
        at jep.Jep.eval(Jep.java:451)
        at jep.Jep.configureInterpreter(Jep.java:302)
        at jep.SharedInterpreter.configureInterpreter(SharedInterpreter.java:64)
        at jep.Jep.<init>(Jep.java:282)
        at jep.SharedInterpreter.<init>(SharedInterpreter.java:56)
        at jep.Run.run(Run.java:49)
        at jep.Run.main(Run.java:146)

what does this actually mean? Is it that java starts up the python interpreter inside the jvm, but it is not able to set the correct PYTHONPATH? I tried setting the PYTHONHOME in the script as described in another issue, but that is not working, probably, since the virtualenv here only contains jep libs.

nixpkgs is reproducible, so if I manage this to work, it would always work kind of :-)

scalavision avatar Jan 30 '21 17:01 scalavision

The build is defined here for reference: https://github.com/scalavision/nixpkgs/blob/add-jep-lib/pkgs/development/tools/jep/default.nix

scalavision avatar Jan 30 '21 17:01 scalavision

That error indicates you have successfully loaded libjep and started a python interpreter but the python interpreter cannot find jep. It is looking for the jep directory with init.py in it. The directory you indicate looks correct and should be in the site-packages directory but something about your virtualenv must prevent python from finding it.

bsteffensmeier avatar Jan 30 '21 17:01 bsteffensmeier

oki, thanks a lot for the feedback :-) I will dive deeper into the python stuff then.

scalavision avatar Jan 31 '21 11:01 scalavision

Closing due to inactivity, please reopen if someone is still actively trying to package jep for nixpkgs.

bsteffensmeier avatar Nov 01 '22 21:11 bsteffensmeier