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

    From Chris Green@21:1/5 to Peter J. Holzer on Sat Jan 18 11:47:57 2025
    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
    ยท

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stefan Ram@21:1/5 to Chris Green on Tue Jan 14 11:43:19 2025
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mats Wichmann@21:1/5 to Chris Green via Python-list on Tue Jan 14 09:06:06 2025
    On 1/14/25 04:32, Chris Green via Python-list wrote:
    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).


    You might look at uv, which makes the managing of a virtualenv for your
    program pretty transparent. You declare your dependencies, and then just:

    uv run myscript.py

    And of course if you don't want to type three words to launch, you can
    put those in an executable shell script in your path, and invoke it with
    a single command.

    There was a nice article on this somewhere which I now can't find, but
    the project docs cover the topics pretty well:

    https://docs.astral.sh/uv/guides/scripts

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From c.buhtz@posteo.jp@21:1/5 to All on Tue Jan 14 16:09:16 2025
    Hello Chris,

    I do have similar "problems" and still try to get used to the "new way".

    Other might correct me. I am not sure yet.

    To my current understanding the way to go is to install Python
    applications via "pipx". That make the application available in your
    system but also isolate it in its own virtual environment. Of course you
    should prefer to install applications from your GNU/Linux distros
    official repository if available.

    If you install a Python package (library, not an application) you should
    create your own Python environment via venv for example. Pipx is not
    intended to install Python packages that are not applications.

    Regrads,
    Christian

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Thomas Passin@21:1/5 to Chris Green via Python-list on Tue Jan 14 11:36:34 2025
    On 1/14/2025 6:32 AM, Chris Green via Python-list wrote:
    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?

    You can also install with --user and --break-system-packages, but that
    doesn't really solve the problem. Also, as just happened to me, if an
    upgrade happens to change the system's python to a newer version (e.g.,
    3.12.x to 3.13.y), you would have to install all your packages again
    with the new Python install.

    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.

    You can write a shell script that activates the venv and then launches
    your program. This works pretty well.

    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.

    This is an approach I use sometimes, mainly if I have cloned a project.
    I run the project's program(s) using a script that sets the PYTHONPATH.

    Anything else? As far as I can see using pipx doesn't help me at
    all (see recent thread here).

    To completely avoid problems when the system's Python install gets
    changed, you can install your own Python version outside of the package manager; it doesn't have to be the same version as the system's. I've
    done this when I wanted to run a later version of Python than the
    system's. You would have to take care of updating it yourself since the
    package manager won't know about it. On the system where I did this, I
    ran the system's python version using "python3" and my own using
    "python3.11" (I think the system was still on 3.8 or 3.9).

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Peter J. Holzer@21:1/5 to Chris Green via Python-list on Sat Jan 18 00:22:08 2025
    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.

    hp

    [1] https://git.hjp.at:3000/hjp/install-python/src/branch/master/install-python


    --
    _ | Peter J. Holzer | Story must make more sense than reality.
    |_|_) | |
    | | | hjp@hjp.at | -- Charles Stross, "Creative writing
    __/ | http://www.hjp.at/ | challenge!"

    -----BEGIN PGP SIGNATURE-----

    iQIzBAABCgAdFiEETtJbRjyPwVTYGJ5k8g5IURL+KF0FAmeK5hsACgkQ8g5IURL+ KF1avxAAsqo7v6IOH0VKMUnf+pLeoyzhlX6//Ky1WDE0MDPr5z+A1WOBRf888bOv kXkSFvG5TwxVFSsUjcVimuOyDs7h3tcK5N9ZSWWiDTR3GYnVAI7Fu4noRYQOPiPA MSeFAxDshv/86d9ZNtUL6U7LaDZotuOsNesg3UaT+LtNpmsMvyrhquZrSJp+5IJj zIFOyrm+y+hFhEHU3/N84LCn0KbsZQOVVwSSnFi8fC/7mqZlG4pmNnKGujIjUsO/ eMQ9M+zQZotk7R1xctIRAA+kPtxC0zj+LHp4yYwhWNgWt9geOwnigiuE1Bcqn/Gf pp65wbu9xx2rxS7FFlsGkcGv5awBe2HwXwkCBt1cAeSJ78fqMkH2QSvcPyXdJ9aY A+mlQ0erXl6tlG+hpbjOvhkc4Vyvfro66wCJGGI8VZ7xXEdSMtk3t87vc8PdCUMU ZdUx30bEwEOAToGSR4IgCu8QRBzHMra2ApzcE464ZEbz6Qgm/fzNOXR/49MuC1aT 1mR/5fvKq6ExVNE3WHyLMV1KUNVfaDWkLeyzfYolPFnzZZ1mPXKezTOTzJsMb+Cm s3QkTbgW90Dhc6v37hLa3sC6n3iIX4w0q49r+0kZ/Qg/bhML34+I76Q9QFgL051b w5DEwmt34rLfdb723Q7z5/3wwv7h6PVffNnkKI/