[TIP] use tox to test different build-time options
holger at merlinux.eu
Thu Oct 27 06:06:04 PDT 2016
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:
On Thu, Oct 27, 2016 at 13:53 +0200, Antonio Cuni wrote:
> I have a project (capnpy) which can optionally use cython to speed
> things up.
>  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:
> In particular:
> - setup.py decides whether to compile cython files by looking at the
> USE_CYTHON env variable:
> - there is a test to check that we actually compiled the file if the
> variable is set:
> - tox.ini has two envs: py27 for the normal case, and cy27 where I set
> USE_CYTHON=1 to enable compilation:
> 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 :)
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
More information about the testing-in-python