Re: how to run jython coverage with an explicit java.exe?

Jeff Allen <[email protected]> Sat, 19 Feb 2022 11:33:42 +0000
Newsgroups gmane.comp.lang.jython.user
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--===============5593357825045731886==
Content-Type: multipart/alternative;
 boundary="------------ZCsaY5BxTo1x7OPMICYk7G70"

This is a multi-part message in MIME format.
--------------ZCsaY5BxTo1x7OPMICYk7G70
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

Hi Hartmut. Thanks for experimenting with solutions.

I've never used coverage myself, but when I run jython (on Windows) it 
picks up the JVM on my path.

I do not understand why, in your account of the error, 
coverage-script.py is in the Jython bin directory. I would expect that 
to be in site-packages, or somewhere of its own, and the paths to 
modules it needs would then be on the sys.path. The error about not 
being able to find a module does not scream "wrong JVM" to me.

pkg_resources is in site-packages, as part of the pip installation we 
do. However, pip as a whole is broken for all versions of Jython thanks 
to changes at pypi.org and our slowness to adapt. pkg_resources is not 
necessarily affected.

Running the jython.jar directly may not work well because additional 
JARs you may need are precluded by the -jar option. The jython.exe 
launcher has a --print command that tells you what it would have done, 
which is useful when you need to roll your own command line. --help will 
tell you which environment variables it pays attention to in creating 
that command.

-- 

Jeff Allen

On 15/02/2022 10:33, Niemann, Hartmut wrote:
>
> Hi!
>
> I need to specify which java is used for a coverage run.
>
> I am using Jython 2.7.0 and coverage 3.4.3
>
> I used to use “coverage.exe” but how could I tell it which java to start?
>
> I succeded starting “jython.exe  coverage-script.py” , but same 
> problem: which java VM is used?
>
> I can run Jython with an explicit JAVA executable and some simple example
>
> %JAVA64% -jar "somepath\jython.jar" %JYTHON_DIR%\bin\hello.py
>
> But when I combine these to
>
> %JAVA64% -jar "C:\SIBAS32\JAVA_LIBS\jython\jython.jar" 
> %JYTHON_DIR%\bin\coverage-script.py
>
> I get
>
> Traceback (most recent call last):
>
>   File "C:\DEVTOOLS\Jython\2.7.0\bin\coverage-script.py", line 5, in 
> <module>
>
>     from pkg_resources import load_entry_point
>
> ImportError: No module named pkg_resources
>
> So I would need to convince coverage.exe or jython.exe to use the 
> Java.exe I want, or teach java.exe -jar … coverage-script.py where to 
> look for the pkg_resources directory.
>
> On
>
> https://www.jython.org/jython-old-sites/archive/21/docs/interpreter.html
>
> I found the sentence
>
> “jythonis a short script that invokes your local JVM, [..]”
>
> which unfortunately does not tell me how the JVM is selected from the 
> (four?) JVMs I have installed.
>
> What would you recommend?
>
> Regards
>
> Hartmut
>
>
--------------ZCsaY5BxTo1x7OPMICYk7G70
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Hi Hartmut. Thanks for experimenting with solutions.</p>
    <p>I've never used <span lang="EN-US">coverage myself, but when I
        run jython (on Windows) it picks up the JVM on my path.</span></p>
    <span lang="EN-US">I do not understand why, in your account of the
      error, </span><span lang="EN-US"><span lang="EN-US">coverage-script.py
        is in the Jython bin directory. I would expect that to be in
        site-packages, or somewhere of its own, and the paths to modules
        it needs would then be on the sys.path. The error about not
        being able to find a module does not scream "wrong JVM" to me.</span></span>
    <p><span lang="EN-US"><span lang="EN-US">pkg_resources is in
          site-packages, as part of the pip installation we do. However,
          pip as a whole is broken for all versions of Jython thanks to
          changes at pypi.org and our slowness to adapt. </span></span><span
        lang="EN-US"><span lang="EN-US"><span lang="EN-US"><span
              lang="EN-US">pkg_resources is not necessarily affected.<br>
            </span></span></span></span></p>
    <p><span lang="EN-US">Running the jython.jar directly may not work
        well because additional JARs you may need are precluded by the
        -jar option. The jython.exe launcher has a --print command that
        tells you what it would have done, which is useful when you need
        to roll your own command line. --help will tell you which
        environment variables it pays attention to in creating that
        command.<br>
      </span></p>
    <p><span lang="EN-US"><span lang="EN-US"></span></span></p>
    <pre class="moz-signature" cols="72">-- 

Jeff Allen</pre>
    <div class="moz-cite-prefix">On 15/02/2022 10:33, Niemann, Hartmut
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:PR3PR10MB4240BAF77B0B6C59AD775822FC349@PR3PR10MB4240.EURPRD10.PROD.OUTLOOK.COM">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <meta name="Generator" content="Microsoft Word 15 (filtered
        medium)">
      <style>@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0cm;
	font-size:11.0pt;
	font-family:"Calibri",sans-serif;
	mso-fareast-language:EN-US;}a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:#0563C1;
	text-decoration:underline;}tt
	{mso-style-priority:99;
	font-family:"Courier New";}.MsoChpDefault
	{mso-style-type:export-only;
	font-family:"Calibri",sans-serif;
	mso-fareast-language:EN-US;}div.WordSection1
	{page:WordSection1;}</style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
      <div class="WordSection1">
        <p class="MsoNormal">Hi!<o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal"><span lang="EN-US">I need to specify which
            java is used for a coverage run.<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US">I am using Jython 2.7.0
            and coverage 3.4.3<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US">I used to use
            “coverage.exe” but how could I tell it which java to start?<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US">I succeded starting
            “jython.exe  coverage-script.py” , but same problem: which
            java VM is used?<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US">I can run Jython with an
            explicit JAVA executable and some simple example
            <o:p></o:p></span></p>
        <p class="MsoNormal">%JAVA64% -jar "somepath\jython.jar"
          %JYTHON_DIR%\bin\hello.py<o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal"><span lang="EN-US">But when I combine these
            to <o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US">%JAVA64% -jar
            "C:\SIBAS32\JAVA_LIBS\jython\jython.jar"
            %JYTHON_DIR%\bin\coverage-script.py<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US">I get <o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US">Traceback (most recent
            call last):<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US">  File
            "C:\DEVTOOLS\Jython\2.7.0\bin\coverage-script.py", line 5,
            in &lt;module&gt;<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US">    from pkg_resources
            import load_entry_point<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US">ImportError: No module
            named pkg_resources<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US">So I would need to
            convince coverage.exe or jython.exe to use the Java.exe I
            want, or teach java.exe -jar … coverage-script.py where to
            look for the pkg_resources directory.<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US">On<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US"><a
href="https://www.jython.org/jython-old-sites/archive/21/docs/interpreter.html"
              moz-do-not-send="true" class="moz-txt-link-freetext">https://www.jython.org/jython-old-sites/archive/21/docs/interpreter.html</a><o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US">I found the sentence<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US">“</span><tt><span
              style="font-size:10.0pt" lang="EN-US">jython</span></tt><span
            lang="EN-US"> is a short script that invokes your local JVM,
            [..]”<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US">which unfortunately does
            not tell me how the JVM is selected from the (four?) JVMs I
            have installed.<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US">What would you
            recommend?<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US">Regards<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US">Hartmut<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span><br>
        </p>
      </div>
    </blockquote>
    <pre class="moz-signature" cols="72">
</pre>
  </body>
</html>

--------------ZCsaY5BxTo1x7OPMICYk7G70--


--===============5593357825045731886==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline


--===============5593357825045731886==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Jython-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jython-users

--===============5593357825045731886==--