#!/usr/bin/python3 vs virtualenv
Hello,
I recently reported
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1032283 , and Dmitry
suggested discussing it on this mailing list.
Virtual environments work by adding some version of Python (possibly just
a symlink to the system one) at the beginning of PATH. Debian policy for
Python scripts is to use #!/usr/bin/python3 and **not** #!/usr/bin/env
python3, so they are not affected.
I think there are 2 types of Python scripts. The first type is
applications for end users, like hg or calibre (it is possible that the
existence of plugins makes my choice of examples a bad one). If I have
some strange Python virtual environment active, I am happy that the Debian
policy prevents the virtual environment from breaking those applications
(although I may still be able to break them with PYTHONPATH).
The second type is targeted at developers, like sphinx-build. If I
activate a virtual environment that contains tensorflow, it is because I
need `import tensorflow` to work inside sphinx-build, but now the Debian
policy prevents it.
As discussed in the bug report, there are workarounds. The question here
is whether it would make sense to amend the policy for some types of
scripts. The answer is probably no, but it seems worth checking what
people think.
The suggestion to install a copy of sphinx in the virtual environment is a
step towards the advice I hear around me but don't really want to follow:
"Developers should use conda, system python packages are only for system
applications" :-(
(thanks a lot to everyone here working on packaging Python stuff in
Debian)
--
Marc Glisse
Reply to: