[Mesa-dev] [PATCH v3 13/24] configure: require python mako module

Samuel Iglesias Gonsálvez siglesias at igalia.com
Thu Dec 11 23:51:34 PST 2014


On Thursday, December 11, 2014 02:35:00 PM Ilia Mirkin wrote:
> On Tue, Dec 9, 2014 at 7:06 AM, Iago Toral Quiroga <itoral at igalia.com> 
wrote:
> > From: Samuel Iglesias Gonsalvez <siglesias at igalia.com>
> > 
> > It is now a hard dependency because of the autogeneration of
> > format pack and unpack functions.
> > 
> > Update the documentation to reflect this change.
> > 
> > v2:
> > - Inline python script in m4 file and use PYTHON2
> > 
> > Signed-off-by: Samuel Iglesias Gonsalvez <siglesias at igalia.com>
> > ---
> > 
> >  configure.ac                      |  2 +
> >  docs/install.html                 |  6 ++-
> >  m4/ax_check_python_mako_module.m4 | 77
> >  +++++++++++++++++++++++++++++++++++++++ 3 files changed, 84
> >  insertions(+), 1 deletion(-)
> >  create mode 100644 m4/ax_check_python_mako_module.m4
> > 
> > diff --git a/configure.ac b/configure.ac
> > index 1d9d015..f38acfd 100644
> > --- a/configure.ac
> > +++ b/configure.ac
> > @@ -76,6 +76,8 @@ if test "x$INDENT" != "xcat"; then
> > 
> >      AC_SUBST(INDENT_FLAGS, '-i4 -nut -br -brs -npcs -ce -TGLubyte
> >      -TGLbyte -TBool')>  
> >  fi
> > 
> > +AC_CHECK_PYTHON_MAKO_MODULE(0.7.3)
> > +
> > 
> >  AC_PROG_INSTALL
> >  
> >  dnl We need a POSIX shell for parts of the build. Assume we have one
> > 
> > diff --git a/docs/install.html b/docs/install.html
> > index f12425f..b12e1cb 100644
> > --- a/docs/install.html
> > +++ b/docs/install.html
> > @@ -38,6 +38,10 @@
> > 
> >  Version 2.6.4 or later should work.
> >  </li>
> >  <br>
> > 
> > +<li><a href="http://www.makotemplates.org/">Python Mako module</a> -
> > +Python Mako module is required. Version 0.7.3 or later should work.
> > +</li>
> > +</br>
> > 
> >  <li><a href="http://www.scons.org/">SCons</a> is required for building on
> >  Windows and optional for Linux (it's an alternative to
> >  autoconf/automake.)
> >  </li>
> > 
> > @@ -78,7 +82,7 @@ the needed dependencies:
> >  <pre>
> >  
> >    sudo yum install flex bison imake libtool xorg-x11-proto-devel
> >    libdrm-devel \ gcc-c++ xorg-x11-server-devel libXi-devel libXmu-devel
> >    libXdamage-devel git \> 
> > -  expat-devel llvm-devel
> > +  expat-devel llvm-devel python-mako
> > 
> >  </pre>
> > 
> > diff --git a/m4/ax_check_python_mako_module.m4
> > b/m4/ax_check_python_mako_module.m4 new file mode 100644
> > index 0000000..f289f26
> > --- /dev/null
> > +++ b/m4/ax_check_python_mako_module.m4
> > @@ -0,0 +1,77 @@
> > +#
> > =========================================================================
> > == +#
> > +# SYNOPSIS
> > +#
> > +#   AX_CHECK_PYTHON_MAKO_MODULE(MIN_VERSION_NUMBER)
> > +#
> > +# DESCRIPTION
> > +#
> > +#   Check whether Python mako module is installed and its version higher
> > than +#   minimum requested.
> > +#
> > +#   Example of its use:
> > +#
> > +#   For example, the minimum mako version would be 0.7.3. Then
> > configure.ac +#   would contain:
> > +#
> > +#   AC_CHECK_PYTHON_MAKO_MODULE(0.7.3)
> > +#
> > +# LICENSE
> > +#
> > +#   Copyright (c) 2014 Intel Corporation.
> > +#
> > +#   This program is free software; you can redistribute it and/or modify
> > it +#   under the terms of the GNU General Public License as published by
> > the +#   Free Software Foundation; either version 2 of the License, or
> > (at your +#   option) any later version.
> > +#
> > +#   This program is distributed in the hope that it will be useful, but
> > +#   WITHOUT ANY WARRANTY; without even the implied warranty of
> > +#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> > General +#   Public License for more details.
> > +#
> > +#   You should have received a copy of the GNU General Public License
> > along +#   with this program. If not, see <http://www.gnu.org/licenses/>.
> > +#
> > +#   As a special exception, the respective Autoconf Macro's copyright
> > owner +#   gives unlimited permission to copy, distribute and modify the
> > configure +#   scripts that are the output of Autoconf when processing
> > the Macro. You +#   need not follow the terms of the GNU General Public
> > License when using +#   or distributing such scripts, even though
> > portions of the text of the +#   Macro appear in them. The GNU General
> > Public License (GPL) does govern +#   all other use of the material that
> > constitutes the Autoconf Macro. +#
> > +#   This special exception to the GPL applies to versions of the Autoconf
> > +#   Macro released by the Autoconf Archive. When you make and distribute
> > a
> > +#   modified version of the Autoconf Macro, you may extend this special
> > +#   exception to the GPL to apply to your modified version as well.
> > +
> > +dnl macro that checks for mako module in python
> > +AC_DEFUN([AC_CHECK_PYTHON_MAKO_MODULE],
> > +[AC_MSG_CHECKING(if module mako in python is installed)
> > +    echo "
> > +try:
> > +    import sys
> > +    import mako
> > +except ImportError as err:
> > +    sys.exit(err)
> > +else:
> > +    ver_min_req_str = str('$1');
> > +    ver_min_req = ver_min_req_str.split('.');
> > +    ver_str = mako.__version__
> > +    ver = ver_str.split('.')
> > +
> > +    for i in range(len(ver)):
> > +        ver_int = int(ver[[i]])
> > +        ver_min_req_int = int(ver_min_req[[i]]);
> > +        if ver_int < ver_min_req_int:
> > +            sys.exit(1);
> > +        if ver_int > ver_min_req_int:
> > +            sys.exit(0);
> 
> Is this something that you wrote, or is it a "standard" thing you
> copied from somewhere? Seems like it'd be a lot simpler as
> 
>   ver_req = map(int, '$1'.split('.'))
>   ver_act = map(int, mako.__version__.split('.'))
>   sys.exit(int(ver_req > ver_act))
> 
> [This assumes that there is an equal number of .'s in the requested
> and actual versions, but so did your old code.]
> 

Thanks for the tip! I will use your code instead.

Sam

> > +    sys.exit(0);" | $PYTHON2 -
> > +    if test $? -ne 0 ; then
> > +       AC_MSG_ERROR(mako $1 or later is required.)
> > +    else
> > +        AC_MSG_RESULT(yes)
> > +    fi
> > +])
> > --
> > 1.9.1
> > 
> > _______________________________________________
> > mesa-dev mailing list
> > mesa-dev at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/mesa-dev
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20141212/6ca030f9/attachment-0001.sig>


More information about the mesa-dev mailing list