[Fedora-packaging] Python 3 compatibility update to Python guidelines
David Malcolm
dmalcolm at redhat.com
Sat Oct 17 14:36:40 UTC 2009
On Sat, 2009-10-17 at 13:33 +0300, Ville Skyttä wrote:
> https://fedoraproject.org/wiki/Packaging:Python
>
> %{!?python_sitelib: %global python_sitelib %(%{__python} -c "from
> distutils.sysconfig import get_python_lib; print get_python_lib()")}
>
> %{!?python_sitearch: %global python_sitearch %(%{__python} -c "from
> distutils.sysconfig import get_python_lib; print get_python_lib(1)")}
>
>
> These no longer work with Python 3 due to "print" changes. They should be
> replaced with something like these that work with both Python 2 and 3 (already
> done in spectemplate-python.spec in rpmdevtools git):
>
> %{!?python_sitelib: %global python_sitelib %(%{__python} -c "from
> distutils.sysconfig import *; import sys;
> sys.stdout.write(get_python_lib())")}
>
> %{!?python_sitearch: %global python_sitearch %(%{__python} -c "from
> distutils.sysconfig import *; import sys;
> sys.stdout.write(get_python_lib(1))")}
At first glance, yes, the change you suggest does generalize those
fragments of python code so they work with both python 2 and python 3
(it removes the trailing newline implicitly generated by "print", but
AIUI that's getting discarded in the macro handling)
However, I think it's going to be a long time until it's sane to make
%{__python} be python 3 rather than python 2. I'm hoping we will have
parallel-installable python 2 and python 3 stacks [1], with separate
packages, probably separate srpms, so perhaps we need alternative
formulations where we define python3_sitelib and python3_sitearch? Not
sure yet.
Your proposed change does ease migration, so a cautious "+1" from me.
Dave
[1] https://fedoraproject.org/wiki/Features/Python3F13
More information about the Fedora-packaging
mailing list