pcp
[Top] [All Lists]

Re: [pcp] python3 woes on f22

To: Mark Goodwin <mgoodwin@xxxxxxxxxx>
Subject: Re: [pcp] python3 woes on f22
From: Nathan Scott <nathans@xxxxxxxxxx>
Date: Mon, 13 Jul 2015 05:46:15 -0400 (EDT)
Cc: pcp <pcp@xxxxxxxxxxx>
Delivered-to: pcp@xxxxxxxxxxx
In-reply-to: <55A2FFBB.5000803@xxxxxxxxxx>
References: <5594A1B5.5090003@xxxxxxxxxx> <y0mbnfhvx03.fsf@xxxxxxxx> <55A2FFBB.5000803@xxxxxxxxxx>
Reply-to: Nathan Scott <nathans@xxxxxxxxxx>
Thread-index: 8VHT/oFx7SVCsCqXnXa9Xqb2QNou4g==
Thread-topic: python3 woes on f22
Hey Mark,

Thanks for looking into this.

----- Original Message -----
> [...]
> I would have hoped /usr/bin/python would still exist, and be the platform
> default (either python2 or python3).

Only on Arch Linux, and this is not the python-community-recommended way
for /usr/bin/python to behave (currently).  More details here ...
http://legacy.python.org/dev/peps/pep-0394/

For PCP, we don't care and either setup would do.  I think you've found
the hack for python3 in fedora.spec around line 1660 (recommended by the
Fedora/RHEL python folks).  Focussing only on Fedora/RHEL is not enough
for PCP packages from Makepkgs though, of course, and the find/sed hack
is pretty ugly - it'd be good if we could solve this more generically.

> > PCP could trigger installing
> > python2 on such a machine ...  or better, we should grow another
> > configury switch that changes the scripts' interpreter to
> > /usr/bin/python3.  (We did this just days ago for a wee python script
> > included with systemtap.)

Both are poor solutions for PCP though, its a very different beast.  We
have far more than the one, trivial python script here - we have many,
and many modules, ctypes interfaces, etc.  For PCP, the version would be
ideally configurable via the (existing) PCP_PYTHON_PROG for all scripts,
not just PMDAs.  Note that configure/Makepkgs also cannot easily tell
what the default python to use should be (it aggressively chooses py3
currently, which I think is still OK to do, and falls back to py2 when
it cannot find/depend on an installed py3) - it does not use specific
Fedora/RHEL versions as triggers (fedora.spec *does* do that, OTOH).

> [...]
> That's pretty ugly IMO.

+1

> we might be better off sticking with python2
> and tweaking the deps (as has already been done).

(Nope, that will cause Makepkgs & fedora.spec to continue to conflict
in this regard & is not really forward-looking for when python3 is the
preference on more platforms)

> Or perhaps we could
> create a pcp-python script that just execs the default interpreter,
> and use that everywhere (/me ducks, but maybe it's worth considering).

Heh, that's fairly creative - and maybe not so crazy.  There's a bitof
precedent for doing that sort of thing for a similar class of problem:
http://stackoverflow.com/questions/2429511/why-do-people-write-usr-bin-env-python-on-the-first-line-of-a-python-script

Perhaps we could generalise it into a pcp-env(1), which could expand the
$PCP_PYTHON_PROG from pcp.conf, for use in shebang lines like:
#!/usr/bin/pcp env $PCP_PYTHON_PROG

This would let users modify the python version in one place (pcp.conf),
which would be good for debugging & helping us as maintainers to diagnose
py3 vs py2 issues too (and for users in prod environments who come across
any such problems of course, as a quick-fix).

(Note that many of our python scripts have no shebang line currently for
hysterical raisins - we could undo that now that we have the packaging all
split out and we do the rpm dependencies correctly.)

cheers.

--
Nathan

<Prev in Thread] Current Thread [Next in Thread>