Re: autoconf (configure) clobbers conftest.py - fix?

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

 



On Tue, Jan 21, 2025, at 4:53 PM, Dima Pasechnik wrote:
> pytest, a popular Python testing tool/framework, uses files named
> conftest.py for its configuration. OTOH many autoconf macros run
> "rm -f conftest*", clobbering conftest.py in the directory where
> ./configure lives. In our case at least, it's the topmost directory.

Unfortunately, I think Autoconf's expectation that it owns the `conftest*`
namespace in the directory where you run configure is too deeply seated to
change at this point, both within Autoconf's own code and within third
party macros.  We can't get rid of the glob, either, because we cannot
reliably predict what files are produced as a side effect of test
compilations.

I can suggest two workarounds:

1. Put `conftest.py` in a subdirectory ;-)  Doesn't pytest recommend
you put it in a `tests` subdirectory along with the actual tests?

2. Always use split builds - that is, run `configure` from a _different_
directory than your source tree.  Like, if you just checked out your
project as `my-project`,

$ (cd my-project && autoreconf -iv)
$ mkdir my-project-build
$ cd my-project-build
$ ../my-project/configure <arguments>
$ make

Then all the `rm -f conftest*` operations will happen in my-project-build
instead of my-project.

This should Just Work as long as you're using Automake and you haven't
written any complicated custom rules.  See the "Parallel Build Trees"
section of the Automake manual for more detail on this build mode.
You can force people to build this way by checking very early in
`configure` whether the current directory is equal to $srcdir:

if test "`cd $srcdir; pwd -P`" = "`pwd -P`"; then
  AC_MSG_ERROR([you must configure in a separate build directory])
fi

right after AC_INIT.

Sorry I can't be any more help.

zw




[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux