Skip to content

Conversation

@anarcat
Copy link

@anarcat anarcat commented Nov 2, 2023

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.

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
Copy link
Member

yosifkit commented Nov 2, 2023

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
Copy link
Author

anarcat commented Nov 3, 2023 via email

@LaurentGoderre
Copy link
Member

LaurentGoderre commented Nov 3, 2023

@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
Copy link
Author

anarcat commented Nov 3, 2023 via email

@tianon
Copy link
Member

tianon commented Nov 30, 2023

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

@yosifkit
Copy link
Member

yosifkit commented Jul 9, 2024

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 yosifkit closed this Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants