Message10196
You should be able to set sys.executable via the python.executable flag, which is how the launcher does it:
$ jython27 --print
java -Xmx512m -Xss1024k -classpath /Users/jbaker/jython2.7.0/jython.jar:. -Dpython.home=/Users/jbaker/jython2.7.0 -Dpython.executable=/Users/jbaker/jython2.7.0/bin/jython -Dpython.launcher.uname=darwin -Dpython.launcher.tty=true -Dfile.encoding=UTF-8 org.python.util.jython
Regardless, solution #2 is reasonable, although it would not work for the uber jar (aka single jar) case. We can make it stronger by following the approach taken by PySystemState, via a currently private method:
$ java -Xmx512m -Xss1024k -classpath /Users/jbaker/jython2.jython.jar:. -Dpython.security.respectJavaAccessibility=false org.python.util.jython
Jython 2.7.0 (default:9987c746f838, Apr 29 2015, 02:25:11)
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.8.0_45
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.getJarFileName()
u'/Users/jbaker/jython2.7.0/jython.jar'
Ordinarily we would just promote to be public, because access modifiers can just get in the way, but that does mean this method is now in the sys module namespace. So perhaps just the logic itself should be extracted into sysconfig; or put in another location like org.python.core.Py. |
|
Date |
User |
Action |
Args |
2015-09-01 22:54:31 | zyasoft | set | messageid: <1441148071.82.0.397067796531.issue2386@psf.upfronthosting.co.za> |
2015-09-01 22:54:31 | zyasoft | set | recipients:
+ zyasoft, stefan.richthofer |
2015-09-01 22:54:31 | zyasoft | link | issue2386 messages |
2015-09-01 22:54:31 | zyasoft | create | |
|