indygreg / indygreg/PyOxidizer

Is there a way to include Java VM into the bundle?

Open
#503 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
6.2k
Forks
256
PR merge metrics
No merged PRs in 30d

Description

Hey,

My app builds with Pyoxidizer and I was able to start it, but the execution fails with the following:
```shell
Traceback (most recent call last):
File "", line 1, in
File "iso15118.secc.start_secc", line 5, in
File "iso15118.secc.comm_session_handler", line 25, in
File "iso15118.secc.transport.tcp_server", line 8, in
File "iso15118.shared.security", line 43, in
File "iso15118.shared.exi_codec", line 39, in
File "iso15118.shared.exificient_wrapper", line 22, in __init__
File "py4j.java_gateway", line 2159, in launch_gateway
File "py4j.java_gateway", line 297, in launch_gateway
py4j.protocol.Py4JError: Could not find py4j jar at
```
That last debug line is the execution of the following line of code, in the py4j lib:
https://github.com/bartdag/py4j/blob/fd1fb670f06c88d467eacf463f0aed8f55ebde53/py4j-python/src/py4j/java_gateway.py#L297

And this is the import in my code that invokes the java_gateway:
```python
import json
import logging
from builtins import Exception
from py4j.java_gateway import JavaGateway
```

The bzl file:
[pyoxidizer.bzl.txt](https://github.com/indygreg/PyOxidizer/files/7964986/pyoxidizer.bzl.txt)

I think the problem is because the executable does not contain or cant find the Java VM, which is installed in my host, but is not included in the bundle. Is there a way to include or link the Java VM to the bundle, so that this error is no longer raised?

I have another problem, which probably would be better suited in another thread and if so please tell me; I tried to cross build the bundle to another arch, but also didnt work:

```shell
$ pyoxidizer build --target-triple armv7-unknown-linux-gnueabihf
resolving 1 targets
resolving target install
resolving target exe
error[PYOXIDIZER_BUILD]: could not find default Python distribution for armv7-unknown-linux-gnueabihf
--> ./pyoxidizer.bzl:13:12
|
13 | dist = default_python_distribution()
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ default_python_distribution()

error: could not find default Python distribution for armv7-unknown-linux-gnueabihf
```

I guess pyoxidizer needs the python interpreter for the armv7 and that would not be a problem, as I can setup a docker container that crosses compile python from x86 to armv7, but how can I tell pyoxidizer to use the cross-compiled version?

Thank you!

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the attached pyoxidizer.bzl configuration and the py4j launch_gateway code referenced at java_gateway.py:297. Investigate how PyOxidizer handles Java VM or JAR dependencies and how default_python_distribution() resolves armv7 targets. Done means documenting or implementing a supported path for both bundled Java execution and cross-compiled Python input.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, python, rust
Domain
build-system, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.