• Best Practice Virtual Environment

    From Ulrich Goebel@21:1/5 to All on Sat Oct 5 22:27:33 2024
    Hi,

    I learned to use virtual environments where ever possible, and I learned to pip install the required packages there.

    That works quite nice at home. Now I come to deploy a Python script on a debian linux server, making it usable for a couple of users there.

    Debian (or even Python3 itself) doesn't allow to pip install required packages system wide, so I have to use virtual environments even there. But is it right, that I have to do that for every single user?

    Can someone give me a hint to find an howto for that?

    Best regards
    Ulrich

    --
    Ulrich Goebel <ml@fam-goebel.de>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Thomas Passin@21:1/5 to Ulrich Goebel via Python-list on Sat Oct 5 17:31:34 2024
    On 10/5/2024 4:27 PM, Ulrich Goebel via Python-list wrote:
    Hi,

    I learned to use virtual environments where ever possible, and I learned to pip install the required packages there.

    That works quite nice at home. Now I come to deploy a Python script on a debian linux server, making it usable for a couple of users there.

    Debian (or even Python3 itself) doesn't allow to pip install required packages system wide, so I have to use virtual environments even there. But is it right, that I have to do that for every single user?

    Can someone give me a hint to find an howto for that?

    One alternative is to install a different version of Python without
    replacing the system's version. For example, if the system uses Python
    3.11, install Python 3.12. That way there is no risk of breaking system operation, and you can install what you like where you like.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Cameron Simpson@21:1/5 to Ulrich Goebel on Sun Oct 6 08:59:56 2024
    On 05Oct2024 22:27, Ulrich Goebel <ml@fam-goebel.de> wrote:
    Debian (or even Python3 itself) doesn't allow to pip install required >packages system wide,

    This is gnerally a good thing. You might modify a critical system-used
    package.

    But is it right, that I have to do that for every single user?

    No. Just make a shared virtualenv, eg in /usr/local or /opt somewhere.
    Have the script commence with:

    #!/path/to/the/shred/venv/bin/python

    and make it readable and executable.

    Problem solved.

    Cheers,
    Cameron Simpson <cs@cskk.id.au>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Karsten Hilbert@21:1/5 to All on Sun Oct 6 00:21:09 2024
    Am Sat, Oct 05, 2024 at 10:27:33PM +0200 schrieb Ulrich Goebel via Python-list:

    Debian (or even Python3 itself) doesn't allow to pip install required packages system wide, so I have to use virtual environments even there. But is it right, that I have to do that for every single user?

    Can someone give me a hint to find an howto for that?

    AFAICT the factual consensus appears to be

    install modules as packaged by the system

    you won't need anything else

    If you do find how to cleanly install non-packaged modules
    in a system-wide way (even if that means installing every
    application into its own *system-wide* venv) - do let me
    know.

    Karsten
    --
    GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Karsten Hilbert@21:1/5 to All on Sun Oct 6 15:44:02 2024
    Am Sun, Oct 06, 2024 at 12:21:09AM +0200 schrieb Karsten Hilbert via Python-list:

    Am Sat, Oct 05, 2024 at 10:27:33PM +0200 schrieb Ulrich Goebel via Python-list:

    Debian (or even Python3 itself) doesn't allow to pip install required packages system wide, so I have to use virtual environments even there. But is it right, that I have to do that for every single user?

    Can someone give me a hint to find an howto for that?

    If you do find how to cleanly install non-packaged modules
    in a system-wide way (even if that means installing every
    application into its own *system-wide* venv) - do let me
    know.

    It seems dh-virtualenv is one way to do it. On Debian.

    Karsten
    --
    GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B

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