Skip to contentSkip to conversation

Cannot infer Python version: when no /usr/bin/python symlink is found (resend)

cocci Luis Chamberlain 3 participants 4 messages Oct 29, 2021 – Nov 5, 2021

lore
Share & tools
lore
#0 lore raw

Debian and OpenSUSE Tumblweed no longer have the /usr/bin/python symlink, at least this is explained and spelled out on the Debian Python Policy [0]. This guideline specifically requests that scripts do not use /usr/bin/env, do not use /usr/bin/python and instead use the exact version desired.

When running coccinelle on a system without this /usr/bin/python symlink Coccinelle will complain when using a python script on a cocci file:

Cannot infer Python version

Fixing this is just to create the symlink, but I *really* don't want to do that. And so I think we may need to support:

script:python3
initialize:python3

Maybe it makes sense then to always look for python2 if a version is not specified, and if that does not exist look for python3 as new systems may not have python2.

[0] https://www.debian.org/doc/packaging-manuals/python-policy/ch-python.html#s-interpreter

Luis

#1 lore raw
Quoted 15 lines · Luis Chamberlain

Debian and OpenSUSE Tumblweed no longer have the /usr/bin/python symlink, at least this is explained and spelled out on the Debian Python Policy [0]. This guideline specifically requests that scripts do not use /usr/bin/env, do not use /usr/bin/python and instead use the exact version desired.

When running coccinelle on a system without this /usr/bin/python symlink Coccinelle will complain when using a python script on a cocci file:

Cannot infer Python version

Fixing this is just to create the symlink, but I *really* don't want to do that. And so I think we may need to support:

Quoted 6 lines

script:python3
initialize:python3

Maybe it makes sense then to always look for python2 if a version is not specified, and if that does not exist look for python3 as new systems may not have python2.

Thanks for the report.

julia

Quoted 5 lines

[0] https://www.debian.org/doc/packaging-manuals/python-policy/ch-python.html#s-interpreter

Luis

#2 lore raw
In reply to Luis Chamberlain

Luis Chamberlain:

Quoted 1 line

Cannot infer Python version

I was not able to reproduce this error: are you sure that it is due to a missing /usr/bin/python symlink? This error message should appear when libpython3-dev is missing (and I have to admit we should change for a better error message!).

For instance, the following Dockerfile succeeds

$ cat >Dockerfile <<EOF
FROM debian:latest
RUN apt-get update
RUN apt-get install --yes ocaml ocaml-findlib libpython3-dev curl autoconf \
    automake make
RUN curl --remote-name --location \
    https://gitlab.inria.fr/coccinelle/coccinelle/-/archive/1.1.1/coccinelle-1.1.1.tar.bz2
RUN tar --extract --file coccinelle-1.1.1.tar.bz2
WORKDIR coccinelle-1.1.1
RUN autoreconf
RUN ./configure
RUN make
RUN cd tests && \
    ../spatch.opt --sp-file countcalls_python.cocci countcalls_python.c
RUN test ! -f /usr/bin/python
EOF

Cheers.

Signature · 3 lines
Thierry.

Luis Chamberlain :
Quoted 25 lines

Debian and OpenSUSE Tumblweed no longer have the /usr/bin/python symlink, at least this is explained and spelled out on the Debian Python Policy [0]. This guideline specifically requests that scripts do not use /usr/bin/env, do not use /usr/bin/python and instead use the exact version desired.

When running coccinelle on a system without this /usr/bin/python symlink Coccinelle will complain when using a python script on a cocci file:

Cannot infer Python version

Fixing this is just to create the symlink, but I *really* don't want to do that. And so I think we may need to support:

script:python3
initialize:python3

Maybe it makes sense then to always look for python2 if a version is not specified, and if that does not exist look for python3 as new systems may not have python2.

[0] https://www.debian.org/doc/packaging-manuals/python-policy/ch-python.html#s-interpreter

Luis

#3 lore raw
Quoted 5 lines · Thierry Martinez

Luis Chamberlain:

Quoted 1 line

Cannot infer Python version

I was not able to reproduce this error: are you sure that it is due to a missing /usr/bin/python symlink?

Odd, I can't reproduce now, but I was before.

Luis