[systemd-devel] [PATCH] *.py: don't hardcode /usr/bin/python

Ramkumar Ramachandra artagnon at gmail.com
Fri Nov 30 20:04:49 PST 2012


Michael Biebl wrote:
> 2012/11/30 Ramkumar Ramachandra <artagnon at gmail.com>:
>> Execute python using "/usr/bin/env python" instead of hard-coding the
>
> I'm not really a fan of using /usr/bin/env, as you can pick up a
> random python version depending on how your PATH is setup.
> Besides, you need to spawn an additional binary.
> I would assume that pretty much every distro ships the python
> interpreter as /usr/bin/python.

I don't follow your reasoning: it is idiomatic to use "/usr/bin/env
$interpreter", because every distro does not necessarily ship it as
/usr/bin/$interpreter.  As far as the version of Python is concerned,
this patch makes no changes with regard to that- /usr/bin/python and
"/usr/bin/env python" might be equally bad versions of Python -- as
Colin pointed out, the correct way to resolve it is at configure-time.

FWIW, the git project uses "/usr/bin/env $interpreter" in scripts as well:

$ git grep /usr/bin/env
contrib/ciabot/ciabot.py:#!/usr/bin/env python
contrib/fast-import/import-zips.py:#!/usr/bin/env python
contrib/gitview/gitview:#! /usr/bin/env python
contrib/hg-to-git/hg-to-git.py:#!/usr/bin/env python
contrib/p4import/git-p4import.py:#!/usr/bin/env python
contrib/remote-helpers/git-remote-hg:#!/usr/bin/env python
git-instaweb.sh:#!/usr/bin/env ruby
git-p4.py:#!/usr/bin/env python
git-remote-testgit.py:#!/usr/bin/env python
git_remote_helpers/__init__.py:#!/usr/bin/env python
git_remote_helpers/git/git.py:#!/usr/bin/env python
git_remote_helpers/setup.py:#!/usr/bin/env python
git_remote_helpers/util.py:#!/usr/bin/env python
t/Git-SVN/00compile.t:#!/usr/bin/env perl
t/Git-SVN/Utils/add_path_to_url.t:#!/usr/bin/env perl
t/Git-SVN/Utils/canonicalize_url.t:#!/usr/bin/env perl
t/Git-SVN/Utils/collapse_dotdot.t:#!/usr/bin/env perl
t/Git-SVN/Utils/join_paths.t:#!/usr/bin/env perl

Ram


More information about the systemd-devel mailing list