jpype-project / jpype

JPype is cross language bridge to allow Python programs full access to Java class libraries.
http://www.jpype.org
Apache License 2.0
1.12k stars 181 forks source link

PyInstaller support? #876

Closed altendky closed 3 years ago

altendky commented 4 years ago

Is there existing PyInstaller support or might it be added? I am of course hoping this is a trivial thing to debug for someone with actual Java and JPype knowledge. :] I have been using javabridge for a few years but might be switching to JPype. I don't do much to care about 'advanced' features but having the wheels would be nice. I am presently working in Linux but would use this on both Linux and Windows. I am getting the following SystemError.

Traceback (most recent call last):
  File "j.py", line 6, in <module>
    jpype.startJVM()
  File "jpype/_core.py", line 221, in startJVM
    _jpype.startup(jvmpath, tuple(args),
SystemError: java.lang.ClassNotFoundException: org.jpype.classloader.DynamicClassLoader

As some probably irrelevant reference, this is for a private project I have that uses https://github.com/altendky/ccstudiodss for access to TI's Code Composer Studio DSS debugging tooling.

Here are some commands to recreate a trivial example failure from within a clone of the JPype repository. I don't like to leave recursive delete commands laying around but maybe remove build/, dist/, and venv/ before each run.

git rev-parse HEAD
git status
python3.8 -m venv venv
venv/bin/python --version --version
venv/bin/pip install --upgrade pip setuptools wheel
venv/bin/pip install . pyinstaller
venv/bin/pip freeze
cat > j.py << EOF
import os

import jpype
import jpype.imports
from jpype.types import *

for key, value in sorted(os.environ.items()):
    print(f'{key!r}: {value!r}')

print('+++ about to start JVM')
jpype.startJVM()
print('+++ JVM started')
EOF
venv/bin/pyinstaller j.py
venv/bin/python j.py
dist/j/j
Expand for full console session ```bash $ git rev-parse HEAD b6d3996fe8d0ac58695aa9867ecf141dfc3196ec ``` ```bash $ git status On branch master Your branch is up to date with 'origin/master'. Untracked files: (use "git add ..." to include in what will be committed) j.py nothing added to commit but untracked files present (use "git add" to track) ``` ```bash $ python3.8 -m venv venv ``` ```bash $ venv/bin/python --version --version Python 3.8.6 (default, Oct 8 2020, 19:34:05) [GCC 9.3.0] ``` ```bash $ venv/bin/pip install --upgrade pip setuptools wheel Requirement already satisfied: pip in ./venv/lib/python3.8/site-packages (20.2.1) Requirement already satisfied: setuptools in ./venv/lib/python3.8/site-packages (49.2.1) Collecting wheel Using cached wheel-0.35.1-py2.py3-none-any.whl (33 kB) Collecting pip Using cached pip-20.2.4-py2.py3-none-any.whl (1.5 MB) Collecting setuptools Using cached setuptools-50.3.2-py3-none-any.whl (785 kB) Installing collected packages: wheel, setuptools, pip Attempting uninstall: setuptools Found existing installation: setuptools 49.2.1 Uninstalling setuptools-49.2.1: Successfully uninstalled setuptools-49.2.1 Attempting uninstall: pip Found existing installation: pip 20.2.1 Uninstalling pip-20.2.1: Successfully uninstalled pip-20.2.1 Successfully installed pip-20.2.4 setuptools-50.3.2 wheel-0.35.1 ``` ```bash $ venv/bin/pip install . pyinstaller Processing /home/altendky/repos/jpype Processing /home/altendky/.cache/pip/wheels/9b/28/8f/f51ae22c4391bbeb36c8fdc68203b0c094445b4db824a6ab7d/pyinstaller-4.0-py3-none-any.whl Requirement already satisfied: setuptools in ./venv/lib/python3.8/site-packages (from pyinstaller) (50.3.2) Collecting pyinstaller-hooks-contrib>=2020.6 Using cached pyinstaller_hooks_contrib-2020.9-py2.py3-none-any.whl (163 kB) Collecting altgraph Using cached altgraph-0.17-py2.py3-none-any.whl (21 kB) Building wheels for collected packages: JPype1 Building wheel for JPype1 (setup.py) ... done Created wheel for JPype1: filename=JPype1-1.1.3.dev0-cp38-cp38-linux_x86_64.whl size=451491 sha256=b09ef42bd6f310b11aeb99bfb29938f87d4815411efd28240d73fba9219c557f Stored in directory: /tmp/pip-ephem-wheel-cache-1lmkh8c4/wheels/87/d2/c6/414694c51d7bb4bed8a6e03be991234b54c4ab0b79eed2c037 Successfully built JPype1 Installing collected packages: pyinstaller-hooks-contrib, altgraph, pyinstaller, JPype1 Successfully installed JPype1-1.1.3.dev0 altgraph-0.17 pyinstaller-4.0 pyinstaller-hooks-contrib-2020.9 ``` ```bash $ venv/bin/pip freeze altgraph==0.17 JPype1 @ file:///home/altendky/repos/jpype pyinstaller==4.0 pyinstaller-hooks-contrib==2020.9 ``` ```bash $ cat > j.py << EOF > import os > > import jpype > import jpype.imports > from jpype.types import * > > for key, value in sorted(os.environ.items()): > print(f'{key!r}: {value!r}') > > print('+++ about to start JVM') > jpype.startJVM() > print('+++ JVM started') > EOF ``` ```bash $ venv/bin/pyinstaller j.py 35 INFO: PyInstaller: 4.0 35 INFO: Python: 3.8.6 36 INFO: Platform: Linux-5.4.0-52-generic-x86_64-with-glibc2.2.5 36 INFO: wrote /home/altendky/repos/jpype/j.spec 38 INFO: UPX is not available. 39 INFO: Extending PYTHONPATH with paths ['/home/altendky/repos/jpype', '/home/altendky/repos/jpype'] 41 INFO: checking Analysis 41 INFO: Building Analysis because Analysis-00.toc is non existent 41 INFO: Initializing module dependency graph... 42 INFO: Caching module graph hooks... 47 INFO: Analyzing base_library.zip ... 2206 INFO: Processing pre-find module path hook distutils from '/home/altendky/repos/jpype/venv/lib/python3.8/site-packages/PyInstaller/hooks/pre_find_module_path/hook-distutils.py'. 2207 INFO: distutils: retargeting to non-venv dir '/home/altendky/.pyenv/versions/3.8.6/lib/python3.8' 4378 INFO: Caching module dependency graph... 4471 INFO: running Analysis Analysis-00.toc 4486 INFO: Analyzing /home/altendky/repos/jpype/j.py 4562 INFO: Processing module hooks... 4562 INFO: Loading module hook 'hook-lib2to3.py' from '/home/altendky/repos/jpype/venv/lib/python3.8/site-packages/PyInstaller/hooks'... 4599 INFO: Loading module hook 'hook-sysconfig.py' from '/home/altendky/repos/jpype/venv/lib/python3.8/site-packages/PyInstaller/hooks'... 4607 INFO: Loading module hook 'hook-xml.etree.cElementTree.py' from '/home/altendky/repos/jpype/venv/lib/python3.8/site-packages/PyInstaller/hooks'... 4607 INFO: Loading module hook 'hook-xml.py' from '/home/altendky/repos/jpype/venv/lib/python3.8/site-packages/PyInstaller/hooks'... 4643 INFO: Loading module hook 'hook-_tkinter.py' from '/home/altendky/repos/jpype/venv/lib/python3.8/site-packages/PyInstaller/hooks'... 4702 INFO: checking Tree 4703 INFO: Building Tree because Tree-00.toc is non existent 4703 INFO: Building Tree Tree-00.toc 4708 INFO: checking Tree 4708 INFO: Building Tree because Tree-01.toc is non existent 4708 INFO: Building Tree Tree-01.toc 4710 INFO: Loading module hook 'hook-encodings.py' from '/home/altendky/repos/jpype/venv/lib/python3.8/site-packages/PyInstaller/hooks'... 4752 INFO: Loading module hook 'hook-distutils.py' from '/home/altendky/repos/jpype/venv/lib/python3.8/site-packages/PyInstaller/hooks'... 4766 INFO: Looking for ctypes DLLs 4800 INFO: Analyzing run-time hooks ... 4803 INFO: Including run-time hook '/home/altendky/repos/jpype/venv/lib/python3.8/site-packages/PyInstaller/hooks/rthooks/pyi_rth__tkinter.py' 4804 INFO: Including run-time hook '/home/altendky/repos/jpype/venv/lib/python3.8/site-packages/PyInstaller/hooks/rthooks/pyi_rth_multiprocessing.py' 4811 INFO: Looking for dynamic libraries 6311 INFO: Looking for eggs 6312 INFO: Using Python library /home/altendky/.pyenv/versions/3.8.6/lib/libpython3.8.so.1.0 6323 INFO: Warnings written to /home/altendky/repos/jpype/build/j/warn-j.txt 6363 INFO: Graph cross-reference written to /home/altendky/repos/jpype/build/j/xref-j.html 6392 INFO: checking PYZ 6392 INFO: Building PYZ because PYZ-00.toc is non existent 6392 INFO: Building PYZ (ZlibArchive) /home/altendky/repos/jpype/build/j/PYZ-00.pyz 6812 INFO: Building PYZ (ZlibArchive) /home/altendky/repos/jpype/build/j/PYZ-00.pyz completed successfully. 6818 INFO: checking PKG 6818 INFO: Building PKG because PKG-00.toc is non existent 6818 INFO: Building PKG (CArchive) PKG-00.pkg 6831 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully. 6832 INFO: Bootloader /home/altendky/repos/jpype/venv/lib/python3.8/site-packages/PyInstaller/bootloader/Linux-64bit/run 6832 INFO: checking EXE 6832 INFO: Building EXE because EXE-00.toc is non existent 6832 INFO: Building EXE from EXE-00.toc 6833 INFO: Appending archive to ELF section in EXE /home/altendky/repos/jpype/build/j/j 6838 INFO: Building EXE from EXE-00.toc completed successfully. 6839 INFO: checking COLLECT 6839 INFO: Building COLLECT because COLLECT-00.toc is non existent 6839 INFO: Building COLLECT COLLECT-00.toc 6912 INFO: Building COLLECT COLLECT-00.toc completed successfully. ``` ```bash $ venv/bin/python j.py 'COLORFGBG': '0;15' 'COLORTERM': 'truecolor' 'DBUS_SESSION_BUS_ADDRESS': 'unix:path=/run/user/1000/bus' 'DEFAULTS_PATH': '/usr/share/gconf/plasma.default.path' 'DESKTOP_SESSION': 'plasma' 'DISPLAY': ':0' 'EDITOR': 'vim' 'GPG_AGENT_INFO': '/run/user/1000/gnupg/S.gpg-agent:0:1' 'HOME': '/home/altendky' 'JDK_HOME': '/usr/lib/jvm/java-8-openjdk-amd64' 'KDED_STARTED_BY_KDEINIT': '1' 'KDE_FULL_SESSION': 'true' 'KDE_SESSION_UID': '1000' 'KDE_SESSION_VERSION': '5' 'KONSOLE_DBUS_SERVICE': ':1.511' 'KONSOLE_DBUS_SESSION': '/Sessions/14' 'KONSOLE_DBUS_WINDOW': '/Windows/7' 'KONSOLE_VERSION': '191203' 'LANG': 'en_US.UTF-8' 'LANGUAGE': '' 'LESSCLOSE': '/usr/bin/lesspipe %s %s' 'LESSOPEN': '| /usr/bin/lesspipe %s' 'LOGNAME': 'altendky' 'LS_COLORS': 'rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:' 'MANDATORY_PATH': '/usr/share/gconf/plasma.mandatory.path' 'OLDPWD': '/home/altendky/repos' 'PAM_KWALLET5_LOGIN': '/run/user/1000/kwallet5.socket' 'PATH': '/home/altendky/.pyenv/plugins/pyenv-virtualenv/shims:/home/altendky/.pyenv/shims:/home/altendky/.pyenv/bin:/epc/bin:/home/altendky/.local/bin:/home/altendky/.local/bin_pipx:/home/altendky/.local/phabricator/arcanist/bin:/home/altendky/.pyenv/bin:/epc/bin:/home/altendky/.local/bin:/home/altendky/.local/bin_pipx:/home/altendky/.local/phabricator/arcanist/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin' 'PIPX_BIN_DIR': '/home/altendky/.local/bin/pipx' 'PROFILEHOME': '' 'PWD': '/home/altendky/repos/jpype' 'PYENV_ROOT': '/home/altendky/.pyenv' 'PYENV_SHELL': 'fish' 'PYENV_VIRTUALENV_INIT': '1' 'PYTHONDONTWRITEBYTECODE': '1' 'PYTHON_CONFIGURE_OPTS': '--enable-shared' 'QT_ACCESSIBILITY': '1' 'QT_AUTO_SCREEN_SCALE_FACTOR': '0' 'ROMP_BUILD_REQUEST_URL': 'https://dev.azure.com/altendky/romp-on/_apis/build/builds?api-version=5.0' 'ROMP_DEFINITION_ID': '5' 'ROMP_PERSONAL_ACCESS_TOKEN': 'fq2j6dq6rcfyw4fqjefhucwlsp5dpon4osngqnz7iw7tjjab44wa' 'ROMP_USERNAME': 'altendky' 'SHELL': '/usr/bin/fish' 'SHELL_SESSION_ID': '5545b08bd22844a28d95b806551cf59c' 'SHLVL': '3' 'SSH_AGENT_PID': '1450' 'SSH_AUTH_SOCK': '/tmp/ssh-aS0O1f34kwqU/agent.1373' 'TERM': 'xterm-256color' 'USER': 'altendky' 'WINDOWID': '77601950' 'XAUTHORITY': '/tmp/xauth-1000-_0' 'XCURSOR_THEME': 'breeze_cursors' 'XDG_CONFIG_DIRS': '/etc/xdg/xdg-plasma:/etc/xdg:/usr/share/kubuntu-default-settings/kf5-settings' 'XDG_CURRENT_DESKTOP': 'KDE' 'XDG_DATA_DIRS': '/usr/share/plasma:/usr/local/share/:/usr/share/' 'XDG_RUNTIME_DIR': '/run/user/1000' 'XDG_SEAT': 'seat0' 'XDG_SEAT_PATH': '/org/freedesktop/DisplayManager/Seat0' 'XDG_SESSION_CLASS': 'user' 'XDG_SESSION_DESKTOP': 'KDE' 'XDG_SESSION_ID': '3' 'XDG_SESSION_PATH': '/org/freedesktop/DisplayManager/Session1' 'XDG_SESSION_TYPE': 'x11' 'XDG_VTNR': '1' '_': 'venv/bin/python' +++ about to start JVM +++ JVM started ``` ```bash $ dist/j/j 'COLORFGBG': '0;15' 'COLORTERM': 'truecolor' 'DBUS_SESSION_BUS_ADDRESS': 'unix:path=/run/user/1000/bus' 'DEFAULTS_PATH': '/usr/share/gconf/plasma.default.path' 'DESKTOP_SESSION': 'plasma' 'DISPLAY': ':0' 'EDITOR': 'vim' 'GPG_AGENT_INFO': '/run/user/1000/gnupg/S.gpg-agent:0:1' 'HOME': '/home/altendky' 'JDK_HOME': '/usr/lib/jvm/java-8-openjdk-amd64' 'KDED_STARTED_BY_KDEINIT': '1' 'KDE_FULL_SESSION': 'true' 'KDE_SESSION_UID': '1000' 'KDE_SESSION_VERSION': '5' 'KONSOLE_DBUS_SERVICE': ':1.511' 'KONSOLE_DBUS_SESSION': '/Sessions/14' 'KONSOLE_DBUS_WINDOW': '/Windows/7' 'KONSOLE_VERSION': '191203' 'LANG': 'en_US.UTF-8' 'LANGUAGE': '' 'LD_LIBRARY_PATH': '/home/altendky/repos/jpype/dist/j' 'LESSCLOSE': '/usr/bin/lesspipe %s %s' 'LESSOPEN': '| /usr/bin/lesspipe %s' 'LOGNAME': 'altendky' 'LS_COLORS': 'rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:' 'MANDATORY_PATH': '/usr/share/gconf/plasma.mandatory.path' 'OLDPWD': '/home/altendky/repos' 'PAM_KWALLET5_LOGIN': '/run/user/1000/kwallet5.socket' 'PATH': '/home/altendky/.pyenv/plugins/pyenv-virtualenv/shims:/home/altendky/.pyenv/shims:/home/altendky/.pyenv/bin:/epc/bin:/home/altendky/.local/bin:/home/altendky/.local/bin_pipx:/home/altendky/.local/phabricator/arcanist/bin:/home/altendky/.pyenv/bin:/epc/bin:/home/altendky/.local/bin:/home/altendky/.local/bin_pipx:/home/altendky/.local/phabricator/arcanist/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin' 'PIPX_BIN_DIR': '/home/altendky/.local/bin/pipx' 'PROFILEHOME': '' 'PWD': '/home/altendky/repos/jpype' 'PYENV_ROOT': '/home/altendky/.pyenv' 'PYENV_SHELL': 'fish' 'PYENV_VIRTUALENV_INIT': '1' 'PYTHONDONTWRITEBYTECODE': '1' 'PYTHON_CONFIGURE_OPTS': '--enable-shared' 'QT_ACCESSIBILITY': '1' 'QT_AUTO_SCREEN_SCALE_FACTOR': '0' 'ROMP_BUILD_REQUEST_URL': 'https://dev.azure.com/altendky/romp-on/_apis/build/builds?api-version=5.0' 'ROMP_DEFINITION_ID': '5' 'ROMP_PERSONAL_ACCESS_TOKEN': 'fq2j6dq6rcfyw4fqjefhucwlsp5dpon4osngqnz7iw7tjjab44wa' 'ROMP_USERNAME': 'altendky' 'SHELL': '/usr/bin/fish' 'SHELL_SESSION_ID': '5545b08bd22844a28d95b806551cf59c' 'SHLVL': '3' 'SSH_AGENT_PID': '1450' 'SSH_AUTH_SOCK': '/tmp/ssh-aS0O1f34kwqU/agent.1373' 'TCL_LIBRARY': '/home/altendky/repos/jpype/dist/j/tcl' 'TERM': 'xterm-256color' 'TK_LIBRARY': '/home/altendky/repos/jpype/dist/j/tk' 'USER': 'altendky' 'WINDOWID': '77601950' 'XAUTHORITY': '/tmp/xauth-1000-_0' 'XCURSOR_THEME': 'breeze_cursors' 'XDG_CONFIG_DIRS': '/etc/xdg/xdg-plasma:/etc/xdg:/usr/share/kubuntu-default-settings/kf5-settings' 'XDG_CURRENT_DESKTOP': 'KDE' 'XDG_DATA_DIRS': '/usr/share/plasma:/usr/local/share/:/usr/share/' 'XDG_RUNTIME_DIR': '/run/user/1000' 'XDG_SEAT': 'seat0' 'XDG_SEAT_PATH': '/org/freedesktop/DisplayManager/Seat0' 'XDG_SESSION_CLASS': 'user' 'XDG_SESSION_DESKTOP': 'KDE' 'XDG_SESSION_ID': '3' 'XDG_SESSION_PATH': '/org/freedesktop/DisplayManager/Session1' 'XDG_SESSION_TYPE': 'x11' 'XDG_VTNR': '1' '_': 'dist/j/j' +++ about to start JVM Traceback (most recent call last): File "j.py", line 11, in jpype.startJVM() File "jpype/_core.py", line 221, in startJVM _jpype.startup(jvmpath, tuple(args), SystemError: java.lang.ClassNotFoundException: org.jpype.classloader.DynamicClassLoader [380392] Failed to execute script j ```

The diff of the printed environment is that when the PyInstaller result is run there are these four extra variables set.

'LD_LIBRARY_PATH': '/home/altendky/repos/jpype/dist/j'
'TCL_LIBRARY': '/home/altendky/repos/jpype/dist/j/tcl'
'TK_LIBRARY': '/home/altendky/repos/jpype/dist/j/tk'
'_': 'dist/j/j'

Thanks for your time and consideration. If there's any more information or things I can try to help out, let me know.

Thrameos commented 4 years ago

Seems like it failed to build or install org.jpype.jar in the proper location. That is the usual reason for that error. (Side issue, we should improve the error reporting for that). I have installed it successfully both by installing from repo with pip+git and using setup.py directly in that past.

I am not exactly familiar with pyinstaller. I would have to go through the procedure in detail which I won't have time to do until this weekend. I would try to see if you have better luck with 1.1.2, though I suspect you will get the same behavior.

My best guess is that the pip installer is installing the python extensions, the java extension, the python files, and the manifest. But pyinstaller likely does not know about the java extension so it may not be packaging it properly. I am not sure how you add additional files to the pyinstaller. We manually added a Java extension in setup.py so that pip would be aware of it. It gets built under build/lib.${arch} and does not have a specific manifest entry as the location where it is found moves based on the build.

altendky commented 4 years ago

I'll dig into org.jpype.jar and confirming it is not being included and getting it included. That's exactly the sort of quick guidance I was hoping for, thanks. I'll follow up with what I find.

altendky commented 4 years ago

Just switching to the following worked. It's certainly a hardcode as is with the path and the : which would be ; on Windows, though. I may make some time to look into making a PyInstaller hook or such for this. If so, I'll follow up here. Thanks again for the quick response to get me going.

venv/bin/pyinstaller --add-binary venv/lib/python3.8/site-packages/org.jpype.jar:. j.py
marscher commented 3 years ago

fixed by #877