python icon indicating copy to clipboard operation
python copied to clipboard

add symlinks in /usr/bin

Open anarcat opened this issue 1 year ago • 5 comments

Using the stock python:slim container is really difficult if you already have an existing script with #!/usr/bin/python3 on top. You will get a confusing error like:

/usr/bin/bash: line 140: ./check.py: cannot execute: required file not found

... while the script otherwise works perfectly well. I understand that it's relatively standard to install things in /usr/local and I generally support this, but in this very specific case, it seems extremely backwards.

I also understand that, normally, you should install a script with an entrypoint and so on, but we shouldn't let perfection be the enemy of good here.

anarcat avatar Nov 02 '23 19:11 anarcat

Unfortunately, this would conflict with Debian's python3 package that can easily come in as a dependency of another installed package (and would then be the wrong python3 for that package).

yosifkit avatar Nov 02 '23 20:11 yosifkit

On 2023-11-02 13:05:55, yosifkit wrote:

Unfortunately, this would conflict with Debian's python3 package that can easily come in as a dependency of another installed package (and would then be the wrong python3 for that package).

Would it?

I actually wonder: the package would probably overwrite the symlink, which would be fine, no?

anarcat avatar Nov 03 '23 01:11 anarcat

@anarcat Maybe Im missing something but wouldn't it ber simper to modify the shebang to use the syntax often used for referencing bash

#!/usr/bin/env python3

your script

LaurentGoderre avatar Nov 03 '23 14:11 LaurentGoderre

On 2023-11-03 07:58:47, Laurent Goderre wrote:

Maybe Im missing something but wouldn't it ber simper to modify the shebang to use the syntax often used for referencing bash

/usr/bin/env python3

your script

That means changing absolutely every random script out there, definitely not simpler in my case.

anarcat avatar Nov 03 '23 15:11 anarcat

Generally yes, installing python3 would overwrite the symlink and be fine, but the part that makes this complicated is that for many of our variants it's already pre-installed (because it's a pre-requisite of many of the common tools included in our "batteries included" images), so there's not a specific "install" that would fix it - we'd just have pre-installed tools that may or may not have different behavior (and some that might not work at all).

tianon avatar Nov 30 '23 23:11 tianon

Closing since this is not something we can reasonably add to the images (see @tianon's comment).

Users can add the symlinks in their own dependent image or run their python script without relying on the shebang, i.e. via python3 ./script.py.

yosifkit avatar Jul 09 '24 23:07 yosifkit