python
python copied to clipboard
add symlinks in /usr/bin
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.
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).
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 wrongpython3
for that package).
Would it?
I actually wonder: the package would probably overwrite the symlink, which would be fine, no?
@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
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.
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).
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
.