[TIP] use tox to test different build-time options

Antonio Cuni anto.cuni at gmail.com
Fri Oct 28 02:21:25 PDT 2016


Hi Holger,
actually I discovered that it was caused by another issue, i.e. that pytest
imported the package from the checkout instead of from the installed
location.
Which is obvious once you think how the command is run. I know that  but it
takes a while before you notice the issue.
Would be cool if tox somehow could detect the case and emit a warning.

ciao,
Anto

On Thu, Oct 27, 2016 at 3:06 PM, holger krekel <holger at merlinux.eu> wrote:

> Hi Anto,
>
> the current model of tox for building is static.  An sdist is created
> independently from any testenv and then installed into them.  So your
> setup.py will not see what is specified in setenv.
>
> We discussed at the recent sprint in June 2016 how to make
> building/packaging more flexible and have some notes referenced here:
>
> https://github.com/tox-dev/tox/issues/338
>
> holger
>
>
> On Thu, Oct 27, 2016 at 13:53 +0200, Antonio Cuni wrote:
> > Hi,
> > I have a project (capnpy[1]) which can optionally use cython to speed
> > things up.
> > [1] https://github.com/antocuni/capnpy
> >
> > I would like to be possible to enable/disable cython compilation using
> > either a command-line switch or an env variable when running setup.py.
> > Moreover, my setup.py is also smart enough to always disable cython when
> > running on PyPy.
> >
> > Since cython is optional, I would also like to automatically run my tests
> > in the two configurations, with and without compilation, but I could not
> > get tox to cooperate so far :).
> > Since capnpy is relatively complex, I wrote a smaller repo which
> showcases
> > the problem:
> > https://github.com/antocuni/toxproblem
> >
> > In particular:
> > - setup.py decides whether to compile cython files by looking at the
> > USE_CYTHON env variable:
> > https://github.com/antocuni/toxproblem/blob/master/setup.py#L8
> >
> > - there is a test to check that we actually compiled the file if the
> > variable is set:
> > https://github.com/antocuni/toxproblem/blob/master/test_foo.py#L7
> >
> > - tox.ini has two envs: py27 for the normal case, and cy27 where I set
> > USE_CYTHON=1 to enable compilation:
> > https://github.com/antocuni/toxproblem/blob/master/tox.ini
> >
> > Everything works well if I run things manually:
> >
> >   # test without cython
> >   $ (rm -f foo.so; python setup.py build_ext --inplace; py.test)
> >
> >   # test with cython
> >   $ (export USE_CYTHON=1; rm -f foo.so; python setup.py build_ext
> > --inplace; py.test)
> >
> > However, if I use tox, it always installs the non-cython version, even in
> > the cy27 environment:
> >
> >   $ tox
> >   ...
> >     FAIL test_foo.py::test_PYX
> >   ...
> >     py27: commands succeeded
> >     ERROR:   cy27: commands failed
> >
> > (full output visible in the README :)).
> >
> > I tried to investigate a bit, and looking at the log it seems that tox
> (or
> > maybe pip?) builds a wheel of my package, and then re-use it to install
> in
> > cy27, but then the wheel does not contain the compiled module. But I did
> > not manage to understand what's going on exactly.
> >
> > Thank you :)
> > Antonio
>
> > _______________________________________________
> > testing-in-python mailing list
> > testing-in-python at lists.idyll.org
> > http://lists.idyll.org/listinfo/testing-in-python
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20161028/76c299ce/attachment.html>


More information about the testing-in-python mailing list