After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 762737 - [PATCH] Hardcoding #!/usr/bin/python is not portable
[PATCH] Hardcoding #!/usr/bin/python is not portable
Status: RESOLVED FIXED
Product: empathy
Classification: Core
Component: General
unspecified
Other FreeBSD
: Normal normal
: ---
Assigned To: empathy-maint
empathy-maint
Depends on:
Blocks:
 
 
Reported: 2016-02-26 15:21 UTC by Ting-Wei Lan
Modified: 2016-04-07 17:05 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
build: Don't hardcode #!/usr/bin/python (735 bytes, patch)
2016-02-26 15:22 UTC, Ting-Wei Lan
committed Details | Review

Description Ting-Wei Lan 2016-02-26 15:21:08 UTC
Please see the patch. We cannot expect python to be installed in /usr/bin on all systems. We can use /usr/bin/env to avoid specifying the full path.
Comment 1 Ting-Wei Lan 2016-02-26 15:22:13 UTC
Created attachment 322469 [details] [review]
build: Don't hardcode #!/usr/bin/python
Comment 2 Debarshi Ray 2016-03-03 19:00:49 UTC
Review of attachment 322469 [details] [review]:

Looks good to me. Thanks for the patch.
Comment 3 Ting-Wei Lan 2016-03-04 03:27:04 UTC
Attachment 322469 [details] pushed as 1b8ad2c - build: Don't hardcode #!/usr/bin/python
Comment 4 Michael Catanzaro 2016-04-03 21:15:33 UTC
(In reply to Ting-Wei Lan from comment #0)
> We can use /usr/bin/env to avoid specifying the full path.

This seems to directly conflict with Debian's python packaging guidelines:

http://www.debian.org/doc/packaging-manuals/python-policy/ch-python.html#s-interpreter

I guess FreeBSD does not have /usr/bin/python? Why not? There are a ludicrous number of python scripts that assume this exists.
Comment 5 Ting-Wei Lan 2016-04-07 05:07:05 UTC
(In reply to Michael Catanzaro from comment #4)
> (In reply to Ting-Wei Lan from comment #0)
> > We can use /usr/bin/env to avoid specifying the full path.
> 
> This seems to directly conflict with Debian's python packaging guidelines:
> 
> http://www.debian.org/doc/packaging-manuals/python-policy/ch-python.html#s-
> interpreter

tools/glib-gtypes-generator.py is not an installed file and it is not part of binary packages that users can download or use, so I think the packaging policy doesn't apply. Debian knows where python is installed on its system, but empathy is not a software specifically made for Debian and it cannot know where python is installed on all systems. If we really don't want to use /usr/bin/env in empathy, the path of python has to be checked in configure and all python scripts have to be generated by configure from .in files.

I think not using absolute paths in sources doesn't cause any problem for packagers. Distributions build packages in clean environments and it is not possible to have an unexpected python version installed in such environment to change the result of the build.

> 
> I guess FreeBSD does not have /usr/bin/python? Why not?

Yes, FreeBSD (and most other *BSD systems) doesn't have /usr/bin/python. /usr/bin is used to store executables provided by the operating system itself. Unlike most GNU/Linux systems, there is a clear separation between the operating system and other softwares. Locations like /usr/bin, /usr/lib, /usr/share, /usr/include should only be used by the operating system, and all packages, which are considered as third-party softwares even if they are installed from the official repository with the official packaging tool, should use a prefix other than /usr. FreeBSD uses /usr/local as the default prefix for packages, but it can be changed if users decide to build all packages they want to use from sources.

> There are a ludicrous number of python scripts that assume this exists.

If the script is made for some specific distributions, or it is packaged in a binary package specifically made for a distribution, then it is fine. If not, it is usually a bug that have to be fixed.
Comment 6 Michael Catanzaro 2016-04-07 13:12:38 UTC
(In reply to Ting-Wei Lan from comment #5)
> tools/glib-gtypes-generator.py is not an installed file and it is not part
> of binary packages that users can download or use, so I think the packaging
> policy doesn't apply.

OK :)

(In reply to Ting-Wei Lan from comment #5)
> If we really don't want to
> use /usr/bin/env in empathy, the path of python has to be checked in
> configure and all python scripts have to be generated by configure from .in
> files.

For installed scripts, I think this is the right solution.

> Yes, FreeBSD (and most other *BSD systems) doesn't have /usr/bin/python.
> /usr/bin is used to store executables provided by the operating system
> itself. Unlike most GNU/Linux systems, there is a clear separation between
> the operating system and other softwares. Locations like /usr/bin, /usr/lib,
> /usr/share, /usr/include should only be used by the operating system, and
> all packages, which are considered as third-party softwares even if they are
> installed from the official repository with the official packaging tool,
> should use a prefix other than /usr. FreeBSD uses /usr/local as the default
> prefix for packages, but it can be changed if users decide to build all
> packages they want to use from sources.

Hm, interesting. I'm amazed you have an operating system without python. :o
Comment 7 Ting-Wei Lan 2016-04-07 17:05:20 UTC
(In reply to Michael Catanzaro from comment #6)
> (In reply to Ting-Wei Lan from comment #5)
> > Yes, FreeBSD (and most other *BSD systems) doesn't have /usr/bin/python.
> > /usr/bin is used to store executables provided by the operating system
> > itself. Unlike most GNU/Linux systems, there is a clear separation between
> > the operating system and other softwares. Locations like /usr/bin, /usr/lib,
> > /usr/share, /usr/include should only be used by the operating system, and
> > all packages, which are considered as third-party softwares even if they are
> > installed from the official repository with the official packaging tool,
> > should use a prefix other than /usr. FreeBSD uses /usr/local as the default
> > prefix for packages, but it can be changed if users decide to build all
> > packages they want to use from sources.
> 
> Hm, interesting. I'm amazed you have an operating system without python. :o

A clean installation of FreeBSD doesn't have python. NetBSD and OpenBSD also don't include python in their base systems. Boot scripts are written in shell, so it can boot without perl and python. This doesn't mean most FreeBSD systems don't have python installed. It simply means the python package installs /usr/local/bin/python instead of /usr/bin/python.