bug-pyconfigure
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-pyconfigure] PyConfigure


From: Arne Babenhauserheide
Subject: Re: [Bug-pyconfigure] PyConfigure
Date: Wed, 06 Mar 2013 09:28:11 +0100
User-agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (Gojō) APEL/10.8 Emacs/24.2 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO)

Hi,

I just found something else which would be pretty nice: Automake knows
where to install data files, so it would be possible to give that path
to python projects without having to use setuptools. For example you
could create a small datapath.py file which holds variables pointing
to the folders different kinds of data files.

Installing data files with python always is a pain and pyconfigure
could make this easier.

Best wishes,
Arne


At Mon, 04 Mar 2013 18:59:01 +0100,
Arne Babenhauserheide wrote:
> 
> Dear Brandon,
> 
> I looked into pyconfigure again today because people told me about
> great new build tools - which actually just move us further away from
> having a unified way to install a program (quite some seed you planted
> in my brain… :) ).
> 
> When I started looking into the autoconf.ac, I got the feeling that it
> looks rather more daunting than it has to. Essentially it is the face
> of pyconfigure: It is what every developer who uses pyconfigure will
> have to edit. So I think that the most common changes to the file
> should be at the top: After the copyright header, the file should
> start with:
> 
> 
>     dnl Lines prefixed with dnl will not appear in generated files
>     
>     dnl######################
>     dnl Project Information #
>     dnl######################
>     
>     # Initialize Autoconf with the project information
>     AC_INIT([{Name}], [{Version}], [{Author-email}])
>     
> 
> I generally tried to make it more readable, but there are things I
> could not do, because I did not know why they were done in the current
> way:
> 
> - Why is there code for virtualenv in the autoconf.ac? Should that not
>   be included by default, so every python project which uses
>   pyconfigure can be installed with virtualenv? (that goes along the
>   lines of having a unified way to install) 
> 
> - Why is there no m4 macro for “maximum version” or “major version”?
>   Having to uncomment lots of stuff in the autoconf.ac seems strange:
>   Can’t this be shelled out to m4?
> 
> - Why do we have m4_include([m4/python.m4]) and
>   AC_CONFIG_MACRO_DIR([m4])?
> 
> - Why do we need automake?
> 
> Besides: PC_PYTHON_TEST_LIBS looks really cool. It seems instantly
> useful for scipy.weave (which might not be available). Essentially it
> is dependency checking on steroids. 
> 
> Also checking for sphinx support is nice: I actually had the problem
> that my system had another version of sphinx than a project developers
> system and so the build failed (until I manually meddled with the
> build script).
> 
> 
> But the m4/python.m4 could really profit from some comments explaining
> the code - I am not used to m4 and it is kinda hard to follow. For
> example it took me some time to figure out this:
> 
> [
> m4_ifnblank([$1], [
>     try:
>         $1.$2($3)], [
>     try:
>         $2($3)])
>     except:
>         sys.exit(1)
>     else:
>         sys.exit(0)
> ]
> 
> Can I just put in inline comments via dnl or #
> 
> 
> Best wishes,
> Arne
> 
> PS: Some links on the website are broken - for example the one to the
>     help mailing list.
> 
> PPS: Here are the changes I made. You should be able to just import
>      them as patches. They might have broken the file, though: Please
>      double and triplecheck the result. They should apply to
>      the restructure branch from Sun Jan 13 14:57:33 2013 +0100.
>      (I accidently worked on that branch…)
> 
> 
> # HG changeset patch
> # User Arne Babenhauserheide <address@hidden>
> # Date 1362417429 -3600
> # Node ID e3accb49aacb7f0e1afd1239fe0083a6b6df507f
> # Parent  b87d5e157ccd947d8b13469a00b3895fdaa7bc83
> python.m4: comment out additional unneeded brackets for 
> PC_PYTHON_CHECK_EXEC_DIR and PC_PYTHON_CHECK_SITE_DIR
> 
> They had a superfluous ]) at the end which made my configure fail.
> 
> diff -r b87d5e157ccd -r e3accb49aacb src/m4/python.m4
> --- a/src/m4/python.m4  Sun Jan 13 14:57:33 2013 +0100
> +++ b/src/m4/python.m4  Mon Mar 04 18:17:09 2013 +0100
> @@ -441,7 +441,7 @@
>       esac
>       ])
>  AC_SUBST([pythondir], [\${prefix}/$pc_cv_python_site_dir])])# 
> PC_PYTHON_CHECK_SITE_DIR
> -])
> +#])
>  
>  # PC_PYTHON_SITE_PACKAGE_DIR
>  # --------------------------
> @@ -506,7 +506,7 @@
>       esac
>      ])
>  AC_SUBST([pyexecdir], [\${exec_prefix}/$pc_cv_python_pyexecdir])]) 
> #PY_PYTHON_CHECK_EXEC_LIB_DIR
> -])
> +#])
>  
>  # PC_PYTHON_EXEC_PACKAGE_DIR
>  # --------------------------
> # HG changeset patch
> # User Arne Babenhauserheide <address@hidden>
> # Date 1362419350 -3600
> # Node ID 8b850e0b8f6afeeffbb88a26dd8d73ee7cdd59be
> # Parent  e3accb49aacb7f0e1afd1239fe0083a6b6df507f
> setup.py: Don’t escape [ and ] in the package_data list.
> 
> diff -r e3accb49aacb -r 8b850e0b8f6a src/setup.py.in.distutils
> --- a/src/setup.py.in.distutils      Mon Mar 04 18:17:09 2013 +0100
> +++ b/src/setup.py.in.distutils      Mon Mar 04 18:49:10 2013 +0100
> @@ -39,6 +39,6 @@
>        py_modules=[],
>        scripts=[],
>        data_files=[(doc_dir, ['COPYING', 'README'])],
> -      package_data=\[\],
> +      package_data=[],
>        ext_modules=[],
>       )
> # HG changeset patch
> # User Arne Babenhauserheide <address@hidden>
> # Date 1362419486 -3600
> # Node ID 98328c8d4530db09c10747e7ccfcf4579751b805
> # Parent  8b850e0b8f6afeeffbb88a26dd8d73ee7cdd59be
> reordered configure.ac for easier reading. This might have broken the file!
> 
> diff -r 8b850e0b8f6a -r 98328c8d4530 src/configure.ac
> --- a/src/configure.ac  Mon Mar 04 18:49:10 2013 +0100
> +++ b/src/configure.ac  Mon Mar 04 18:51:26 2013 +0100
> @@ -7,52 +7,33 @@
>  # notice and this notice are preserved.  This file is offered as-is,
>  # without any warranty.
>  
> -# This is a basic Autoconf configure.ac file for Python-based
> -# projects. It is not intended to be used as-is, but rather to be
> -# modified to the specific needs of the project.
> +dnl This is a basic Autoconf configure.ac file for Python-based
> +dnl projects. It is not intended to be used as-is, but rather to be
> +dnl modified to the specific needs of the project.
>  
> +dnl Lines prefixed with dnl will not appear in generated files
>  
> -dnl#######################################
> -dnl Define some m4 macros here as needed #
> -dnl#######################################
> +dnl######################
> +dnl Project Information #
> +dnl######################
>  
> -# Set your minimum-required Python version(s). You can use these macros 
> -# later when you do version checking.
> -#m4_define([python_min_ver], [2.7.2])
> -#m4_define([python3_min_ver], [3.2.1])
> +# Initialize Autoconf with the project information
> +AC_INIT([{Name}], [{Version}], [{Author-email}])
>  
>  
>  dnl#############################################
>  dnl Import the Python-specific Autoconf macros #
> +dnl Unless these macros are included upstream  #
> +dnl somewhere, this must be included ###########
>  dnl#############################################
>  
> -# Unless these macros are included upstream somewhere, this must be included
> +# Python Autoconf macros
>  m4_include([m4/python.m4])
>  
>  
> -dnl#######################################
> -dnl Autoconf and Automake initialization #
> -dnl#######################################
> -
> -# Initialize Autoconf.
> -AC_INIT([{Name}], [{Version}], [{Author-email}])
> -
> -# Set some Automake flags
> -AC_SUBST(ACLOCAL_AMFLAGS, "-I m4 -I .")
> -
> -# Initialize Automake
> -#AM_INIT_AUTOMAKE()
> -
> -# Load macros from the m4/ directory
> -AC_CONFIG_MACRO_DIR([m4])
> -
> -dnl#########################
> -dnl Python-specific macros #
> -dnl#########################
> -
>  dnl# AC_PROG_PYTHON ##################################################
>  dnl
> -dnl This is line is the bare minimum that needs to be included. It
> +dnl This line is the bare minimum that needs to be included. It
>  dnl locates the Python interpreter binary. You may optionally pass it
>  dnl an argument to pass a path to a binary. By default, this will
>  dnl first check for a binary called "python" and then from there it
> @@ -64,6 +45,29 @@
>  
>  AC_PROG_PYTHON
>  
> +
> +dnl #################
> +dnl Useful features #
> +dnl #################
> +
> +dnl##################################
> +dnl Define required python versions #
> +
> +# Minimum-required Python version(s).
> +#m4_define([python_min_ver], [2.7.2])
> +#m4_define([python3_min_ver], [3.2.1])
> +
> +dnl ########################################
> +dnl Check for sphinx documentation support #
> +
> +# This creates a SPHINXBUILD variable in the Makefile pointing to the program
> +#AC_CHECK_PROGS([SPHINXBUILD], [sphinx-build sphinx-build3 sphinx-build2], 
> [no])
> +#AS_IF([test "x$SPHINXBUILD" = xno], 
> +#                AC_MSG_WARN(sphinx-build is required to build 
> documentation))
> +
> +dnl#############################
> +dnl Provide virtualenv support #
> +
>  # Support installing to a virtualenv via the --with-virtualenv configure flag
>  AC_ARG_WITH([virtualenv],
>         [AS_HELP_STRING([--with-virtualenv], [install to a Python 
> virtualenv])],
> @@ -77,18 +81,6 @@
>    AC_SUBST([VIRTUALENV], [no]))
>  AC_ARG_VAR([VIRTUALENV_FLAGS], [flags to pass to the virtualenv command])
>  
> -# If the program uses sphinx-build to build documentation, uncomment this to 
> -# create a SPHINXBUILD variable in the Makefile pointing to the program
> -#AC_CHECK_PROGS([SPHINXBUILD], [sphinx-build sphinx-build3 sphinx-build2], 
> [no])
> -#AS_IF([test "x$SPHINXBUILD" = xno], 
> -#                AC_MSG_WARN(sphinx-build is required to build 
> documentation))
> -
> -
> -# A couple extra useful commands
> -AC_PROG_MKDIR_P
> -AC_PROG_INSTALL            
> -
> -
>  dnl # PC_PYTHON_VERIFY_VERSION #######################################
>  dnl
>  dnl This macro is used to check if the version of the discovered
> @@ -127,6 +119,32 @@
>  
>  
>  
> +dnl #######################################################
> +dnl Test for specific features of the Python installation #
> +dnl #######################################################
> +
> +dnl # PC_PYTHON_CHECK_MODULE([PYTHON-MODULE], [ACTION-IF-PRESENT],
> +dnl                          [ACTION-IF-ABSENT]) 
> +dnl
> +dnl This macro lets you check if a given Python module exists on the
> +dnl system.
> +
> +#PC_PYTHON_CHECK_MODULE([foo])
> +
> +dnl # PC_PYTHON_CHECK_FUNC([PYTHON-MODULE], [FUNCTION], [ARGS], 
> +dnl                        [ACTION-IF-SUCCESSFUL], [ACTION-IF-FAIL]) 
> +dnl
> +dnl This macro lets you test if a given function, possibly contained
> +dnl in a given module, exists. If any exception is encountered when
> +dnl calling this function, the check will fail. 
> +# test if Python library foo can do bar()
> +#PC_PYTHON_CHECK_FUNC([foo], [bar])
> +
> +
> +dnl #####################################
> +dnl Check basic installation properties #
> +dnl #####################################
> +
>  dnl # PC_PYTHON_CHECK_PREFIX #########################################
>  dnl
>  dnl This macro finds out what Python thinks is the PREFIX
> @@ -136,15 +154,90 @@
>  
>  #PC_PYTHON_CHECK_PREFIX
>  
> -
> -
>  dnl # PC_PYTHON_CHECK_EXEC_PREFIX ####################################
>  dnl
>  dnl The same as above but for $exec-prefix
>  
>  #PC_PYTHON_CHECK_EXEC_PREFIX
>  
> +dnl # PC_PYTHON_CHECK_CFLAGS #########################################
> +dnl
> +dnl This macro checks what Python thinks are the proper CFLAGS to
> +dnl use and stores them in PYTHON_CFLAGS. Note that this info is only
> +dnl available for Python versions which include a python-config tool
> +dnl (2.5+).
>  
> +#PC_PYTHON_CHECK_CFLAGS
> +## Add PYTHON_CFLAGS to CFLAGS
> +#CFLAGS="$CFLAGS $PYTHON_CFLAGS"
> +
> +dnl # PC_PYTHON_CHECK_LDFLAGS ########################################
> +dnl
> +dnl The same as above but for LDFLAGS
> +
> +#PC_PYTHON_CHECK_LDFLAGS
> +## Add PYTHON_LDFLAGS to LDFLAGS
> +#LDFLAGS="$LDFLAGS $PYTHON_LDFLAGS"
> +
> +dnl # PC_PYTHON_CHECK_EXTENSION_SUFFIX ###############################
> +dnl
> +dnl This checks for what Python expects the suffix of extension
> +dnl modules to be (i.e. .cpython-32mu.so) and stores it in
> +dnl PYTHON_EXTENSION SUFFIX. This information is only available for
> +dnl Python 3+
> +
> +#PC_PYTHON_CHECK_EXTENSION_SUFFIX
> +
> +dnl # PC_PYTHON_CHECK_ABI_FLAGS ######################################
> +dnl
> +dnl This checks for the ABI flags used by Python (i.e. "mu") and
> +dnl stores it in PYTHON_ABI_FLAGS. This information is only available
> +dnl for Python 3+
> +
> +#PC_PYTHON_CHECK_ABI_FLAGS
> +
> +dnl # PC_PYTHON_CHECK_PLATFORM #######################################
> +dnl 
> +dnl This macro checks what platform Python thinks this is (ie
> +dnl "linux2") and stores it in PYTHON_PLATFORM
> +
> +#PC_PYTHON_CHECK_PLATFORM
> +
> +dnl # PC_PYTHON_CHECK_SITE_DIR #######################################
> +dnl
> +dnl This checks where Python packages are installed (usually 
> +dnl /usr/lib/pythonX.Y/site-packages) and stores it in pythondir.
> +
> +#PC_PYTHON_CHECK_SITE_DIR
> +
> +dnl # PC_PYTHON_SITE_PACKAGE_DIR #####################################
> +dnl
> +dnl This uses PYTHON_SITE_DIR to construct a directory for this
> +dnl project (ie $PYTHON_SITE_DIR/project_name) and stores it in
> +dnl pkgpythondir. This value is used by Automake for installing Python
> +dnl scripts. By default, this begins with $pythondir, unexpanded, to
> +dnl provide compatibility with GNU Makefile specifications, allowing
> +dnl the user to change the prefix from the commandline.
> +
> +PC_PYTHON_SITE_PACKAGE_DIR
> +
> +dnl # PC_PYTHON_CHECK_EXEC_DIR #######################################
> +dnl
> +dnl Same as PC_PYTHON_CHECK_SITE_DIR but for $exec-prefix. Stored in
> +dnl pyexecdir
> +
> +#PC_PYTHON_CHECK_EXEC_DIR
> +
> +dnl # PC_PYTHON_EXEC_PACKAGE_DIR #####################################
> +dnl
> +dnl Same as PC_PYTHON_SITE_PACKAGE_DIR but for $exec-prefix. Stored in
> +dnl pkgpyexecdir
> +
> +PC_PYTHON_EXEC_PACKAGE_DIR
> +
> +dnl ############################## 
> +dnl Checks for extension modules #
> +dnl ##############################
>  
>  dnl # PC_PYTHON_CHECK_INCLUDES #######################################
>  dnl
> @@ -154,8 +247,6 @@
>  
>  #PC_PYTHON_CHECK_INCLUDES
>  
> -
> -
>  dnl # PC_PYTHON_CHECK_HEADERS([ACTION-IF-PRESENT], [ACTION-IF-ABSENT])
>  dnl
>  dnl Using the information found from PC_PYTHON_CHECK_INCLUDES, check
> @@ -165,8 +256,6 @@
>  
>  #PC_PYTHON_CHECK_HEADERS(,[AC_MSG_ERROR(could not find Python headers)])
>  
> -
> -
>  dnl # PC_PYTHON_CHECK_LIBS ###########################################
>  dnl
>  dnl This checks what LIBS flags are necessary to use the Python
> @@ -174,8 +263,6 @@
>  
>  #PC_PYTHON_CHECK_LIBS
>  
> -
> -
>  dnl # PC_PYTHON_TEST_LIBS([FUNCTION-TO-TEST], [ACTION-IF-PRESENT], 
> [ACTION-IF-ABSENT])
>  dnl
>  dnl This checks whether the LIBS flag for libpython discovered with
> @@ -189,119 +276,28 @@
>  #LIBS="$LIBS $PYTHON_LIBS"
>  
>  
> +dnl ####################
> +dnl Required utilities #
> +dnl ####################
>  
> -dnl # PC_PYTHON_CHECK_CFLAGS #########################################
> -dnl
> -dnl This macro checks what Python thinks are the proper CFLAGS to
> -dnl use and stores them in PYTHON_CFLAGS. Note that this info is only
> -dnl available for Python versions which include a python-config tool
> -dnl (2.5+).
> +# Provide ${MKDIR_P} for creating directories safely and cross platform
> +AC_PROG_MKDIR_P
> +# Provide ways to install programs. Requires the script install-sh!
> +AC_PROG_INSTALL       
>  
> -#PC_PYTHON_CHECK_CFLAGS
> -## Add PYTHON_CFLAGS to CFLAGS
> -#CFLAGS="$CFLAGS $PYTHON_CFLAGS"
>  
> +dnl#######################
> +dnl Add Automake support #
> +dnl#######################
>  
> +# Set some Automake flags
> +#AC_SUBST(ACLOCAL_AMFLAGS, "-I m4 -I .")
>  
> -dnl # PC_PYTHON_CHECK_LDFLAGS ########################################
> -dnl
> -dnl The same as above but for LDFLAGS
> +# Initialize Automake. This will use any Makefile.am to produce a Makefile.in
> +#AM_INIT_AUTOMAKE()
>  
> -#PC_PYTHON_CHECK_LDFLAGS
> -## Add PYTHON_LDFLAGS to LDFLAGS
> -#LDFLAGS="$LDFLAGS $PYTHON_LDFLAGS"
> -
> -
> -
> -dnl # PC_PYTHON_CHECK_EXTENSION_SUFFIX ###############################
> -dnl
> -dnl This checks for what Python expects the suffix of extension
> -dnl modules to be (i.e. .cpython-32mu.so) and stores it in
> -dnl PYTHON_EXTENSION SUFFIX. This information is only available for
> -dnl Python 3+
> -
> -#PC_PYTHON_CHECK_EXTENSION_SUFFIX
> -
> -
> -
> -dnl # PC_PYTHON_CHECK_ABI_FLAGS ######################################
> -dnl
> -dnl This checks for the ABI flags used by Python (i.e. "mu") and
> -dnl stores it in PYTHON_ABI_FLAGS. This information is only available
> -dnl for Python 3+
> -
> -#PC_PYTHON_CHECK_ABI_FLAGS
> -
> -
> -
> -dnl # PC_PYTHON_CHECK_PLATFORM #######################################
> -dnl 
> -dnl This macro checks what platform Python thinks this is (ie
> -dnl "linux2") and stores it in PYTHON_PLATFORM
> -
> -#PC_PYTHON_CHECK_PLATFORM
> -
> -
> -
> -dnl # PC_PYTHON_CHECK_SITE_DIR #######################################
> -dnl
> -dnl This checks where Python packages are installed (usually 
> -dnl /usr/lib/pythonX.Y/site-packages) and stores it in pythondir.
> -
> -#PC_PYTHON_CHECK_SITE_DIR
> -
> -
> -
> -dnl # PC_PYTHON_SITE_PACKAGE_DIR #####################################
> -dnl
> -dnl This uses PYTHON_SITE_DIR to construct a directory for this
> -dnl project (ie $PYTHON_SITE_DIR/project_name) and stores it in
> -dnl pkgpythondir. This value is used by Automake for installing Python
> -dnl scripts. By default, this begins with $pythondir, unexpanded, to
> -dnl provide compatibility with GNU Makefile specifications, allowing
> -dnl the user to change the prefix from the commandline.
> -
> -PC_PYTHON_SITE_PACKAGE_DIR
> -
> -
> -
> -dnl # PC_PYTHON_CHECK_EXEC_DIR #######################################
> -dnl
> -dnl Same as PC_PYTHON_CHECK_SITE_DIR but for $exec-prefix. Stored in
> -dnl pyexecdir
> -
> -#PC_PYTHON_CHECK_EXEC_DIR
> -
> -
> -
> -dnl # PC_PYTHON_EXEC_PACKAGE_DIR #####################################
> -dnl
> -dnl Same as PC_PYTHON_SITE_PACKAGE_DIR but for $exec-prefix. Stored in
> -dnl pkgpyexecdir
> -
> -PC_PYTHON_EXEC_PACKAGE_DIR
> -
> -
> -
> -dnl # PC_PYTHON_CHECK_MODULE([PYTHON-MODULE], [ACTION-IF-PRESENT],
> -dnl                          [ACTION-IF-ABSENT]) 
> -dnl
> -dnl This macro lets you check if a given Python module exists on the
> -dnl system.
> -
> -#PC_PYTHON_CHECK_MODULE([foo])
> -
> -
> -
> -dnl # PC_PYTHON_CHECK_FUNC([PYTHON-MODULE], [FUNCTION], [ARGS], 
> -dnl                        [ACTION-IF-SUCCESSFUL], [ACTION-IF-FAIL]) 
> -dnl
> -dnl This macro lets you test if a given function, possibly contained
> -dnl in a given module, exists. If any exception is encountered when
> -dnl calling this function, the check will fail. 
> -# test if Python library foo can do bar()
> -#PC_PYTHON_CHECK_FUNC([foo], [bar])
> -
> +# Load macros from the m4/ directory
> +#AC_CONFIG_MACRO_DIR([m4])
>  
>  
>  dnl Advanced notes:
> @@ -328,7 +324,12 @@
>  dnl indented once by default. PROLOG code does not require this.
>  
>  
> +dnl ######################################
> +dnl Define the template files to process #
> +dnl ######################################
> +
>  # Files to be configured
> -AC_CONFIG_FILES([Makefile setup.py])
> +AC_CONFIG_FILES([Makefile:Makefile.in.distutils])
> +AC_CONFIG_FILES([setup.py:setup.py.in.distutils])
>  # Generate config.status
>  AC_OUTPUT
> 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]