Skip to content
Permalink
Browse files

Canonicalize Python shebangs

/usr/bin/env python3 is the suggested[1] shebang for Python in general
(likewise for python2) and is conventional across platforms. This eases
development on systems where python is not installed in /usr/bin
(FreeBSD for example) and makes it possible to develop in virtual
environments (venv) for isolating dependencies.

Many packaging guidelines discourage the use of /usr/bin/env, but since
this is the canonical way of writing shebangs in the Python community,
the packaging scripts are already equipped to handle substituting the
appropriate absolute path to python automatically. This requires no
changes on our part.

[1]: https://docs.python.org/3/using/unix.html?#miscellaneous

Signed-off-by: Ryan Moeller <ryan@ixsystems.com>
  • Loading branch information...
freqlabs committed Sep 11, 2019
1 parent 25f06d6 commit 29b58264aa7a1e98fe018b83dda72fb0788c5cf3
@@ -1,4 +1,4 @@
#!/usr/bin/python2
#!/usr/bin/env python2
#
# $Id: arc_summary.pl,v 388:e27800740aa2 2011-07-08 02:53:29Z jhell $
#
@@ -1,4 +1,4 @@
#!/usr/bin/python3
#!/usr/bin/env python3
#
# Copyright (c) 2008 Ben Rockwood <benr@cuddletech.com>,
# Copyright (c) 2010 Martin Matuska <mm@FreeBSD.org>,
@@ -8,6 +8,6 @@ dist_bin_SCRIPTS = arcstat
#
if USING_PYTHON_2
install-exec-hook:
sed --in-place 's|^#!/usr/bin/python3|#!/usr/bin/python2|' \
sed --in-place 's|^#!/usr/bin/env python3|#!/usr/bin/env python2|' \
$(DESTDIR)$(bindir)/arcstat
endif
@@ -1,4 +1,4 @@
#!/usr/bin/python3
#!/usr/bin/env python3
#
# Print out ZFS ARC Statistics exported via kstat(1)
# For a definition of fields, or usage, use arctstat.pl -v
@@ -8,6 +8,6 @@ dist_bin_SCRIPTS = dbufstat
#
if USING_PYTHON_2
install-exec-hook:
sed --in-place 's|^#!/usr/bin/python3|#!/usr/bin/python2|' \
sed --in-place 's|^#!/usr/bin/env python3|#!/usr/bin/env python2|' \
$(DESTDIR)$(bindir)/dbufstat
endif
@@ -1,4 +1,4 @@
#!/usr/bin/python3
#!/usr/bin/env python3
#
# Print out statistics for all cached dmu buffers. This information
# is available through the dbufs kstat and may be post-processed as
@@ -53,10 +53,6 @@
%bcond_with asan
%bcond_with systemd

# Exclude test-runner.py from the rpmbuild shebang check to allow it to run
# under Python 2 and 3.
%global __brp_mangle_shebangs_exclude_from test-runner.py

# Generic enable switch for systemd
%if %{with systemd}
%define _systemd 1
@@ -9,7 +9,7 @@ dist_pkgdata_SCRIPTS = \
#
if USING_PYTHON_2
install-data-hook:
sed --in-place 's|^#!/usr/bin/python3|#!/usr/bin/python2|' \
sed --in-place 's|^#!/usr/bin/env python3|#!/usr/bin/env python2|' \
$(DESTDIR)$(pkgdatadir)/test-runner.py \
$(DESTDIR)$(pkgdatadir)/zts-report.py
endif
@@ -1,4 +1,4 @@
#!/usr/bin/python3
#!/usr/bin/env python3

#
# This file and its contents are supplied under the terms of the
@@ -1,4 +1,4 @@
#!/usr/bin/python3
#!/usr/bin/env python3

#
# This file and its contents are supplied under the terms of the

0 comments on commit 29b5826

Please sign in to comment.
You can’t perform that action at this time.