• [gentoo-user] Source Python virtualenv in OpenRC script

    From Julien Roy@21:1/5 to All on Sun Dec 12 01:00:02 2021
    Hello,

    I am trying to create an OpenRC script to start a python module.
    To launch the module manually, what I would do is:
    cd $moduleDir
    source bin/activate
    python -m $module

    How can I integrate this in an OpenRC script? Do I need to write my own start function or is there a built-in way to do this?

    Thanks,
    Julien

    <html>
    <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    </head>
    <body>
    <div>Hello,<br></div><div dir="auto"><br></div><div dir="auto">I am trying to create an OpenRC script to start a python module.<br></div><div dir="auto">To launch the module manually, what I would do is:<br></div><div dir="auto"><span class="font" style="
    font-family: monospace, sans-serif;">cd $moduleDir</span><span class="font" style="font-family: monospace, sans-serif;"><br></span></div><div dir="auto"><span class="font" style="font-family: monospace, sans-serif;">source bin/activate</span><span class="
    font" style="font-family: monospace, sans-serif;"><br></span></div><div dir="auto"><span class="font" style="font-family: monospace, sans-serif;">python -m $module</span><br></div><div dir="auto"><br></div><div dir="auto">How can I integrate this in an
    OpenRC script? Do I need to write my own start function or is there a built-in way to do this?<br></div><div dir="auto"><br></div><div>Thanks,<br></div><div dir="auto">Julien<br></div> </body>
    </html>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Manuel McLure@21:1/5 to julien@jroy.ca on Sun Dec 12 23:40:02 2021
    On Sat, Dec 11, 2021 at 3:54 PM Julien Roy <julien@jroy.ca> wrote:

    Hello,

    I am trying to create an OpenRC script to start a python module.
    To launch the module manually, what I would do is:
    cd $moduleDir
    source bin/activate
    python -m $module


    You can actually just use

    $moduleDir/bin/python -m $module

    Executing anything from the bin directory inside the venv will make it act
    as if it had activated the venv.
    --
    Manuel A. McLure WW1FA <manuel@mclure.org> <http://www.mclure.org>
    ...for in Ulthar, according to an ancient and significant law,
    no man may kill a cat. -- H.P. Lovecraft

    <div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Dec 11, 2021 at 3:54 PM Julien Roy &lt;<a href="mailto:julien@jroy.ca">julien@jroy.ca</a>&gt; wrote:<br></div><blockquote class="gmail_quote"
    style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">



    <div>
    <div>Hello,<br></div><div dir="auto"><br></div><div dir="auto">I am trying to create an OpenRC script to start a python module.<br></div><div dir="auto">To launch the module manually, what I would do is:<br></div><div dir="auto"><span style="font-family:
    monospace,sans-serif">cd $moduleDir</span><span style="font-family:monospace,sans-serif"><br></span></div><div dir="auto"><span style="font-family:monospace,sans-serif">source bin/activate</span><span style="font-family:monospace,sans-serif"><br></span></
    <div dir="auto"><span style="font-family:monospace,sans-serif">python -m $module</span></div> </div>

    </blockquote></div><br clear="all"><div>You can actually just use<div><br></div><div>$moduleDir/bin/python -m $module</div><div><br></div><div>Executing anything from the bin directory inside the venv will make it act as if it had activated the venv.</
    </div>-- <br><div dir="ltr" class="gmail_signature">Manuel A. McLure WW1FA &lt;<a href="mailto:manuel@mclure.org" target="_blank">manuel@mclure.org</a>&gt; &lt;<a href="http://www.mclure.org" target="_blank">http://www.mclure.org</a>&gt;<br>...for in
    Ulthar, according to an ancient and significant law,<br>no man may kill a cat.                       -- H.P. Lovecraft</div></div>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Julien Roy@21:1/5 to All on Mon Dec 13 00:00:02 2021
    Thanks, I didn´t realize it was this easy!

    Regards,
    Julien



    Dec 12, 2021, 22:39 by manuel@mclure.org:



    On Sat, Dec 11, 2021 at 3:54 PM Julien Roy <> julien@jroy.ca> > wrote:

    Hello,

    I am trying to create an OpenRC script to start a python module.
    To launch the module manually, what I would do is:
    cd $moduleDir
    source bin/activate
    python -m $module


    You can actually just use

    $moduleDir/bin/python -m $module

    Executing anything from the bin directory inside the venv will make it act as if it had activated the venv.
    --
    Manuel A. McLure WW1FA <> manuel@mclure.org> > <> http://www.mclure.org> > ...for in Ulthar, according to an ancient and significant law,
    no man may kill a cat.                       -- H.P. Lovecraft

    <html>
    <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    </head>
    <body>
    <div>Thanks, I didn´t realize it was this easy!<br></div><div dir="auto"><br></div><div>Regards,<br></div><div dir="auto">Julien<br></div><div><br></div><div><br></div><div><br></div><div>Dec 12, 2021, 22:39 by manuel@mclure.org:<br></div><blockquote
    class="tutanota_quote" style="border-left: 1px solid #93A3B8; padding-left: 10px; margin-left: 5px;"><div dir="ltr"><div dir="ltr"><br></div><div><br></div><div class=""><div class="" dir="ltr">On Sat, Dec 11, 2021 at 3:54 PM Julien Roy &lt;<a href="
    mailto:julien@jroy.ca" rel="noopener noreferrer" target="_blank">julien@jroy.ca</a>&gt; wrote:<br></div><blockquote style="margin: 0px 0px 0px 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex; --darkreader-inline-border-left: #3e4446;"
    class="" data-darkreader-inline-border-left=""><div><div>Hello,<br></div><div dir="auto"><br></div><div dir="auto">I am trying to create an OpenRC script to start a python module.<br></div><div dir="auto">To launch the module manually, what I would do is:
    <br></div><div dir="auto"><span style=""><span class="font" style="font-family:monospace, sans-serif">cd $moduleDir</span></span><span style=""><span class="font" style="font-family:monospace, sans-serif"></span></span><br></div><div dir="auto"><span
    style=""><span class="font" style="font-family:monospace, sans-serif">source bin/activate</span></span><span style=""><span class="font" style="font-family:monospace, sans-serif"></span></span><br></div><div dir="auto"><span style=""><span class="font"
    style="font-family:monospace, sans-serif">python -m $module</span></span><br></div></div></blockquote></div><div><br></div><div><div>You can actually just use<br></div><div><br></div><div>$moduleDir/bin/python -m $module<br></div><div><br></div><div>
    Executing anything from the bin directory inside the venv will make it act as if it had activated the venv.<br></div></div><div>-- <br></div><div class="" dir="ltr"><div>Manuel A. McLure WW1FA &lt;<a target="_blank" href="mailto:manuel@mclure.org" rel="
    noopener noreferrer">manuel@mclure.org</a>&gt; &lt;<a target="_blank" href="http://www.mclure.org" rel="noopener noreferrer">http://www.mclure.org</a>&gt;<br></div><div>...for in Ulthar, according to an ancient and significant law,<br></div><div>no man
    may kill a cat.&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; -- H.P. Lovecraft<br></div></div></div></blockquote> </body>
    </html>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)