docker-library / python

Docker Official Image packaging for Python
https://www.python.org/
MIT License
2.5k stars 1.04k forks source link

add symlinks in /usr/bin #883

Open anarcat opened 8 months ago

anarcat commented 8 months ago

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.

yosifkit commented 8 months ago

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).

anarcat commented 8 months ago

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?

LaurentGoderre commented 8 months ago

@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
anarcat commented 8 months ago

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.

tianon commented 7 months ago

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).