• Strategies for avoiding having to use --break-system-packages with pip

    From Chris Green@cl@isbd.net to comp.lang.python on Tue Jan 14 11:32:35 2025
    From Newsgroup: comp.lang.python

    I have a (relatively) clean Debian 12 installation running on my two
    workhorse systems, a desktop server at home and my laptop that travels
    around with me.

    I moved from Xubuntu to Debian on both these systems a few months ago.

    I ran Xubuntu for many years and acquired a whole lot of python
    packages installed with pip, as root. For the last couple of years I
    had to use the --break-system-packages option to get things installed.

    As far as I'm aware I never hit any dependency problems doing this.
    It's probably because things I installed with pip were mostly quite
    small, specialised, packages that I used in just one or two utility
    programs that I had written myself. In quite a few cases these were
    realated to image processing and such things.


    So far I've managed to keep my Debian 12 installations 'pip free', I
    haven't even got pip installed. However I may have just come across
    something that would at least be very useful and it comes from PyPi.
    (It's tkintertable if that's of any interest or relevance)


    What are my options?

    Just install it using pip as root and --break-system-packages,
    what's likely to break?

    Use a virtual environment, what do I have to do then to make using
    my program (that uses tkintertable) 'transparent', i.e. I just
    want to be able to run the program from the command prompt like
    any other program.

    Download tkintertable from git into my development environment and
    use that. My PYTHONPATH will need to point to it but I can't see
    any further issues with doing this.

    Anything else? As far as I can see using pipx doesn't help me at
    all (see recent thread here).
    --
    Chris Green
    ·
    --- Synchronet 3.20c-Linux NewsLink 1.2
  • From ram@ram@zedat.fu-berlin.de (Stefan Ram) to comp.lang.python on Tue Jan 14 11:43:19 2025
    From Newsgroup: comp.lang.python

    Chris Green <cl@isbd.net> wrote or quoted:
    What are my options?

    You've got a few ways to skin this cat without turning your Debian
    setup into a dumpster fire.

    Virtual environment route:

    This is your best bet for keeping things kosher. Here's the lowdown:

    bash

    python3 -m venv ~/myenv
    source ~/myenv/bin/activate
    pip install tkintertable

    To make your program run smooth as butter, whip up a shell script
    that fires up the virtual environment and kicks off your program:

    bash

    #!/bin/bash
    source ~/myenv/bin/activate
    python /path/to/your/program.py

    Slap that bad boy in your PATH, make it executable, and you're
    golden.

    Source installation:

    Pulling tkintertable from git and tweaking your PYTHONPATH is
    solid. It's like growing your own organic produce - more work,
    but you know what you're getting.

    Pip with --break-system-packages:

    It's like jaywalking - you might get away with it, but one day
    you could end up in a world of hurt.

    DIY Debian package:

    For the overachievers out there. It's like building your
    own surfboard - cool if you can pull it off, but not for
    the faint of heart.

    Bottom line:

    The virtual environment play (option 1) is your ticket to ride.
    It keeps your system clean as a whistle while letting you run
    your program without breaking a sweat.


    --- Synchronet 3.20c-Linux NewsLink 1.2
  • From Chris Green@cl@isbd.net to comp.lang.python on Sat Jan 18 11:47:57 2025
    From Newsgroup: comp.lang.python

    Peter J. Holzer <hjp-python@hjp.at> wrote:
    [-- text/plain, encoding quoted-printable, charset: us-ascii, 32 lines --]

    On 2025-01-14 11:32:35 +0000, Chris Green via Python-list wrote:
    Use a virtual environment, what do I have to do then to make using
    my program (that uses tkintertable) 'transparent', i.e. I just
    want to be able to run the program from the command prompt like
    any other program.

    Just use the python interpreter in the venv in the hashbang line.

    For example, here's the first line of one my scripts:

    #!/usr/local/share/wds/venv/bin/python3

    As you can probably guess, the venv is in /usr/local/share/wds/venv.

    There is no need for wrapper scripts which activate the venv. Python
    does that all by itself.

    I have a small script, install-python[1], to assist with setting the hashbang, but if it's just a few scripts you can simply edit it manually.

    OP here. Yes, thank you, I thought that the shebang line would do the
    trick but it's nioce to have it confirmed.
    --
    Chris Green
    ·
    --- Synchronet 3.20c-Linux NewsLink 1.2