[Samba] Samba4 with python2.7 and python3

Ng Oon-Ee ngoonee at gmail.com
Fri Jan 14 16:57:39 MST 2011


On Wed, 2011-01-12 at 22:07 +0800, Ng Oon-Ee wrote:
> On Wed, 2011-01-12 at 21:10 +1100, Andrew Bartlett wrote:
> > 
> > OK, but OpenChange should be able to work with the current GIT tree
too
> > (we do test this), and that's what any fix would need to be relative
> > to. 
> 
> I will first get this working somehow and then try on current GIT.
> > Where should this be set, and what should it be set to?  It's not
set on
> > my Fedora 14 system for example.  Can you point me at the
specification
> > that suggests that this is the 'right' way to find python?  
> > 
> > '/usr/bin/env python' was the 'right' way to find it for quite some
> > time, which is why I ask. 
> 
> My understanding (as a USER from Arch) is that it must be set manually
> prior to ./configure, make, make install for most packages. Thus it
> would mainly be the packager's responsibility. I do not have the
> expertise to say anything more on that.
> 
Okay, I have gotten something hacked out (at the bottom of this email).
And yes /usr/bin/env python is the 'right' way to find out what the
installed version of python is. The thing is, it returns python3 if its
installed (as it is on all current up-to-date Arch systems), which of
course it would be expected to do unless the software specifically
specifies it wants python2.

I recall from my distro ML that there's no 'accepted' way of dealing
with this, we're pioneering it in some sense. From a user's perspective,
simply 'assuming' that python = python2 doesn't make much sense,
especially when the software will not compile with python3.

In any case, here's the sed lines I used. Some could probably be tweaked
further, but I've got an AGM to attend in a moment, sorry. For
reference, 'srcdir' and '_realver' are env variables (in my case they
contain the path to the samba4 source and the version 4.0.0alpha13.

  sed -i -e "s|/usr/bin/env python$|/usr/bin/env python2|" \
         -e "s|python-config|python2-config|" \
         -e "s|bin/python|bin/python2|" \
    $(find ${srcdir}/samba-${_realver} -name '*.py')
  sed -i -e "s|/usr/bin/env python$|/usr/bin/env python2|" \
    $(find ${srcdir}/samba-${_realver} -name 'wscript*')
  sed -i -e "s|/usr/bin/env python$|/usr/bin/env python2|" \
         -e "s|python-config|python2-config|" \
         -e "s|bin/python|bin/python2|" \
    $(find ${srcdir}/samba-${_realver} -name 'configure.ac')
  sed -i -e "s|/usr/bin/env python$|/usr/bin/env python2|" \
    $(find ${srcdir}/samba-${_realver} -name 'upgrade_from_s3')
  sed -i -e "s|/usr/bin/env python$|/usr/bin/env python2|" \
    $(find ${srcdir}/samba-${_realver} -name 'provision')
  sed -i -e "s|/usr/bin/env python$|/usr/bin/env python2|" \
         -e "s|python-config|python2-config|" \
         -e "s|bin/python|bin/python2|" \
    $(find ${srcdir}/samba-${_realver}/buildtools -type f)
  sed -i -e "s|/usr/bin/env python$|/usr/bin/env python2|" \
         -e "s|python-config|python2-config|" \
         -e "s|bin/python|bin/python2|" \
    $(find ${srcdir}/samba-${_realver}/source4/scripting -type f)
  export PYTHON=/usr/bin/python2




More information about the samba-technical mailing list