<div dir="ltr"><div class="gmail_default" style="font-size:small"><div class="gmail_default">Hi,</div><div class="gmail_default">I have a project (capnpy[1]) which can optionally use cython to speed things up.</div><div class="gmail_default" style="font-size:12.8px">[1] <a href="https://github.com/antocuni/capnpy" target="_blank">https://github.com/antocuni/<wbr>capnpy</a><br></div><div class="gmail_default"><br></div><div class="gmail_default">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.</div><div class="gmail_default"><br></div><div class="gmail_default">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 :).</div><div class="gmail_default">Since capnpy is relatively complex, I wrote a smaller repo which showcases the problem:</div><div class="gmail_default" style="font-size:12.8px"><a href="https://github.com/antocuni/toxproblem" target="_blank">https://github.com/antocuni/<wbr>toxproblem</a><br></div><div class="gmail_default"><br></div><div class="gmail_default">In particular:</div><div class="gmail_default">- setup.py decides whether to compile cython files by looking at the USE_CYTHON env variable:</div><div class="gmail_default"><a href="https://github.com/antocuni/toxproblem/blob/master/setup.py#L8" target="_blank">https://github.com/antocuni/<wbr>toxproblem/blob/master/setup.<wbr>py#L8</a><br></div><div class="gmail_default"><br></div><div class="gmail_default">- there is a test to check that we actually compiled the file if the variable is set:</div><div class="gmail_default" style="font-size:12.8px"><a href="https://github.com/antocuni/toxproblem/blob/master/test_foo.py#L7" target="_blank">https://github.com/antocuni/<wbr>toxproblem/blob/master/test_<wbr>foo.py#L7</a><br></div><div class="gmail_default" style="font-size:12.8px"><br></div><div class="gmail_default" style="font-size:12.8px">- tox.ini has two envs: py27 for the normal case, and cy27 where I set USE_CYTHON=1 to enable compilation:</div><div class="gmail_default" style="font-size:12.8px"><a href="https://github.com/antocuni/toxproblem/blob/master/tox.ini" target="_blank">https://github.com/antocuni/<wbr>toxproblem/blob/master/tox.ini</a><br></div><div class="gmail_default" style="font-size:12.8px"><br></div><div class="gmail_default" style="font-size:12.8px">Everything works well if I run things manually:</div><div class="gmail_default" style="font-size:12.8px"><div class="gmail_default"><br></div><div class="gmail_default">  # test without cython</div><div class="gmail_default">  $ (rm -f foo.so; python setup.py build_ext --inplace; py.test)</div><div class="gmail_default"><br></div><div class="gmail_default">  # test with cython</div><div class="gmail_default">  $ (export USE_CYTHON=1; rm -f foo.so; python setup.py build_ext --inplace; py.test)</div><div><br></div><div>However, if I use tox, it always installs the non-cython version, even in the cy27 environment:</div><div><br></div><div>  $ tox</div><div>  ...</div><div>    FAIL test_foo.py::test_PYX</div><div>  ...</div><div>    py27: commands succeeded</div><div>    ERROR:   cy27: commands failed</div><div><br></div><div>(full output visible in the README :)).</div><div><br></div><div>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&#39;s going on exactly.</div><div><br></div><div>Thank you :)</div><div>Antonio</div></div></div></div>