Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JAVA_HOME error while packaging for openSUSE #106

Closed
johanneskastl opened this issue Jul 19, 2023 · 5 comments
Closed

JAVA_HOME error while packaging for openSUSE #106

johanneskastl opened this issue Jul 19, 2023 · 5 comments
Assignees

Comments

@johanneskastl
Copy link

johanneskastl commented Jul 19, 2023

Hi all,

I am trying to package ansible-rulebook for openSUSE, which has jpy as a transient dependency.

I get an error during build, where jpy complains about JAVA_HOME not being set properly. I set it so it does not point to a link (which seems to cause problems, according to #86). But even now it fails:

[   26s] Executing(%build): /usr/bin/bash -e /var/tmp/rpm-tmp.x7bOsZ      
[   26s] + umask 022                 
[   26s] + cd /home/abuild/rpmbuild/BUILD                                                     
[   26s] + /usr/bin/rm -rf /home/abuild/rpmbuild/BUILDROOT/python-jpy-0.13.0-0.x86_64
[   26s] ++ dirname /home/abuild/rpmbuild/BUILDROOT/python-jpy-0.13.0-0.x86_64
[   26s] + /usr/bin/mkdir -p /home/abuild/rpmbuild/BUILDROOT      
[   26s] + /usr/bin/mkdir /home/abuild/rpmbuild/BUILDROOT/python-jpy-0.13.0-0.x86_64
[   26s] + cd jpy-0.13.0                                                                      
[   26s] + export JAVA_HOME=/usr/lib64/jvm/java-11-openjdk-11
[   26s] + JAVA_HOME=/usr/lib64/jvm/java-11-openjdk-11
[   26s] + echo 'JAVA_HOME is set to: /usr/lib64/jvm/java-11-openjdk-11'      
[   26s] JAVA_HOME is set to: /usr/lib64/jvm/java-11-openjdk-11                  
[   26s] + ls -lh /usr/lib64/jvm/java-11-openjdk-11
[   26s] total 16K                                                                                                                                                                           
[   26s] drwxr-xr-x 2 root root 4.0K Jul 19 07:45 bin                                                                                                                                        
[   26s] drwxr-xr-x 4 root root 4.0K Jul 19 07:45 conf                                                                                                                                       
[   26s] drwxr-xr-x 7 root root 4.0K Jul 19 07:45 lib                                                                                                                                        
[   26s] -rw-r--r-- 1 root root 1.2K Jun 14 23:15 release                                                                                                                                    
[   26s] ++ '[' -f _current_flavor ']'                                                        
[   26s] ++ true                                                                                                                                                                             
[   26s] + last_flavor=
[   26s] + '[' -z '' ']'                     
[   26s] + last_flavor=tmp                    
[   26s] + '[' tmp '!=' python39 ']'         
[   26s] + '[' -d build ']'                                                                   
[   26s] + '[' -d _build.python39 ']'                                                         
[   26s] + echo python39
[   26s] + python_flavor=python39
[   26s] + myargs=
[   26s] + '[' -f './dist/*-none-any.whl' ']'
[   26s] + /usr/bin/python3.9 -mpip wheel --verbose --progress-bar off --disable-pip-version-check --use-pep517 --no-build-isolation --no-deps --wheel-dir ./build .
[   27s] Processing /home/abuild/rpmbuild/BUILD/jpy-0.13.0
[   27s]   Preparing metadata (pyproject.toml): started
[   27s]   Running command Preparing metadata (pyproject.toml)
[   27s]   Error: environment variable "JAVA_HOME" must be set to a JDK (>= v1.7) installation directory

I tried different openjdk versions (11, 17, 20) and set JAVA_HOME accordingly. But I get the error each time.

Also, the build runs three times (for python 3.9, 3.10 and 3.11) and all of them fail with the same error.

Any idea what goes wrong there? What am I missing?

@devinrsmith devinrsmith self-assigned this Jul 19, 2023
@devinrsmith
Copy link
Member

Setting environment variable JPY_LOG_LEVEL=DEBUG may provide more useful logging.

We do publish wheels to PyPi for Linux Python (3.9|3.10|3.11) (x86_64|aarch64) - are you not able to depend on these?

Our official build procedure runs on GH Actions, and essentially runs python setup.py bdist_wheel --dist-dir dist.linux. See https://github.com/jpy-consortium/jpy/blob/v0.13.0/.github/workflows/build.yml, https://github.com/jpy-consortium/jpy/blob/v0.13.0/.github/env/Linux/bdist-wheel.sh. It looks like you are invoking a different build command (pip wheel ...). I'd suggest trying to more closely match how bdist-wheel.sh works if debug logging doesn't provide more insights.

@johanneskastl
Copy link
Author

Thanks for the reply. Unfortunately the DEBUG did only help a little.

[   26s]   Running command Preparing metadata (pyproject.toml)                                                                                                                               
[   27s]   jpyutil - DEBUG: Checking Maven for JAVA_HOME...                                                                                                                                  
[   27s]   jpyutil - DEBUG: Maven not found on PATH. No JAVA_HOME found.                                                                                                                     
[   27s]   Error: environment variable "JAVA_HOME" must be set to a JDK (>= v1.7) installation directory
[   27s]   error: subprocess-exited-with-error
[   27s]   

After also installing maven the build still fails:

[    8s]   Running command Preparing metadata (pyproject.toml)
[    8s]   jpyutil - DEBUG: Checking Maven for JAVA_HOME...
[    8s]   Error: environment variable "JAVA_HOME" must be set to a JDK (>= v1.7) installation directory
[    8s]   error: subprocess-exited-with-error

Not sure what maven requires inside the JAVA_HOME, but it seems like it cannot find it...

@devinrsmith
Copy link
Member

devinrsmith commented Jul 19, 2023

...
JDK_HOME_VARS = ('JPY_JAVA_HOME', 'JPY_JDK_HOME', 'JAVA_HOME', 'JDK_HOME',)
...
def find_jdk_home_dir():
    """
    Try to detect the JDK home directory from Maven, if available, or use
    dedicated environment variables.
    :return: pathname if found, else None
    """
    for name in JDK_HOME_VARS:
        jdk_home_dir = os.environ.get(name, None)
        if jdk_home_dir \
                and os.path.exists(os.path.join(jdk_home_dir, 'include')) \
                and os.path.exists(os.path.join(jdk_home_dir, 'lib')):
            return jdk_home_dir
    logger.debug('Checking Maven for JAVA_HOME...')
...

The procedure for installing is checking to make sure the "include" and "lib" dir exists - I see in your setup the "include" dir doesn't. There may be an additional openjdk package you may need to install? (One that is JDK oriented, or src oriented?)

@johanneskastl
Copy link
Author

Thanks, I'll have a look.

@johanneskastl
Copy link
Author

Aaah, that seems to have done the trick. I was missing the java-XX-openjdk-devel package...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants