oracle / graalpython

A high-performance embeddable Python 3 runtime for Java
https://www.graalvm.org/python/
Other
1.22k stars 104 forks source link

Unable to create virtual environment on Linux aarch64 #356

Closed edigonzales closed 6 months ago

edigonzales commented 1 year ago

When running graalpy -m venv .venv on Ubuntu 22.04 on ARM I get the following error:

Error: [Errno 36] File name too long: '/home/ubuntu/.venv/bin/modules -Djdk.module.main=org.graalvm.py.launcher -Dgraalvm.locatorDisabled=true -classpath  com.oracle.graal.python.shell.GraalPythonMain'

From a slack discussion:

Ok, so for some reason GraalPy JVM distribution on aarch64 does not seem to properly process the -Dorg.graalvm.launcher.executablename=./bin/graalpy property and tries to fallback to setting full java command as sys.executable, which is known to be problematic for tools such as venv. Could you open a GitHub issue for us? You can try with GraalPy native (non JVM) distribution. Unless you need Java or other interop, I'd suggest to use that as the default anyway.

Workaround: graalpy --python.Executable=/full/path/to/graalpy/bin/graalpy -m venv .venv

No problems on macOS (ARM).

steve-s commented 1 year ago

Adding some relevant notes from Slack discussion. When the launcher is run with VERBOSE_GRAALVM_LAUNCHERS, it gives:

org.graalvm.launcher.executablename set to '-Dorg.graalvm.launcher.executablename=./bin/graalpy'
Setting VM argument -Dorg.graalvm.launcher.class=com.oracle.graal.python.shell.GraalPythonMain
Setting VM argument -Dorg.graalvm.version=23.1.0
Setting VM argument -Dorg.graalvm.launcher.executablename=./bin/graalpy
Setting VM argument -Djava.library.path=/home/ubuntu/apps/graalpy/bin/../jvmlibs
Setting VM argument -Dorg.graalvm.language.python.home=/home/ubuntu/apps/graalpy
Setting VM argument -Dorg.graalvm.language.llvm.home=/home/ubuntu/apps/graalpy/lib/sulong
Setting VM argument -Dorg.graalvm.language.llvm-toolchain.home=/home/ubuntu/apps/graalpy/lib/llvm-toolchain
Setting VM argument -Dtruffle.attach.library=/home/ubuntu/apps/graalpy/jvmlibs/libtruffleattach.so
Setting VM argument -Dtruffle.nfi.library=/home/ubuntu/apps/graalpy/jvmlibs/libtrufflenfi.so
Setting VM argument -Xss16777216
Setting VM argument -Djava.class.path=
Setting VM argument --module-path=/home/ubuntu/apps/graalpy/modules
Setting VM argument -Djdk.module.main=org.graalvm.py.launcher
Setting VM argument -Dgraalvm.locatorDisabled=true
Loading library /home/ubuntu/apps/graalpy/bin/../jvm/lib/server/libjvm.so
Python 3.10.8 (Wed Sep 13 09:57:52 CEST 2023)
[Graal, GraalVM CE, Java 21] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

I cannot reproduce this issue on another ARM Linux. The path ./bin/graalpy passed in JVM property org.graalvm.launcher.executablename seems legit, but either it doesn't get through to GraalPy or GraalPy misinterprets it somehow. Could you try this:

  1. pass --python.Executable=./bin/graalpy (assuming that you actually run the graalpy launcher via ./bin/graalpy). What happens? Does that work?

  2. check if the JVM actually gets the org.graalvm.launcher.executablename property, for example via VisualVM UI or via command line using this:

When graalpy is running do:

import os; print(os.getpid())

to find out its PID and then run in another console:

/path/to/graalpy/jvm/bin/jcmd $PID VM.system_properties | grep executable

it should give

org.graalvm.launcher.executablename=./bin/graalpy

if the property was properly passed to the JVM.