<div dir="ltr"><div class="gmail_default" style="font-size:small">Hi Holger,</div><div class="gmail_default" style="font-size:small">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.</div><div class="gmail_default" style="font-size:small">Which is obvious once you think how the command is run. I know that  but it takes a while before you notice the issue.</div><div class="gmail_default" style="font-size:small">Would be cool if tox somehow could detect the case and emit a warning.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">ciao,</div><div class="gmail_default" style="font-size:small">Anto</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 27, 2016 at 3:06 PM, holger krekel <span dir="ltr">&lt;<a href="mailto:holger@merlinux.eu" target="_blank">holger@merlinux.eu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Anto,<br>
<br>
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.<br>
<br>
We discussed at the recent sprint in June 2016 how to make building/packaging more flexible and have some notes referenced here:<br>
<br>
<a href="https://github.com/tox-dev/tox/issues/338" rel="noreferrer" target="_blank">https://github.com/tox-dev/<wbr>tox/issues/338</a><br>
<br>
holger<br>
<div><div class="h5"><br>
<br>
On Thu, Oct 27, 2016 at 13:53 +0200, Antonio Cuni wrote:<br>
&gt; Hi,<br>
&gt; I have a project (capnpy[1]) which can optionally use cython to speed<br>
&gt; things up.<br>
&gt; [1] <a href="https://github.com/antocuni/capnpy" rel="noreferrer" target="_blank">https://github.com/antocuni/<wbr>capnpy</a><br>
&gt;<br>
&gt; I would like to be possible to enable/disable cython compilation using<br>
&gt; either a command-line switch or an env variable when running setup.py.<br>
&gt; Moreover, my setup.py is also smart enough to always disable cython when<br>
&gt; running on PyPy.<br>
&gt;<br>
&gt; Since cython is optional, I would also like to automatically run my tests<br>
&gt; in the two configurations, with and without compilation, but I could not<br>
&gt; get tox to cooperate so far :).<br>
&gt; Since capnpy is relatively complex, I wrote a smaller repo which showcases<br>
&gt; the problem:<br>
&gt; <a href="https://github.com/antocuni/toxproblem" rel="noreferrer" target="_blank">https://github.com/antocuni/<wbr>toxproblem</a><br>
&gt;<br>
&gt; In particular:<br>
&gt; - setup.py decides whether to compile cython files by looking at the<br>
&gt; USE_CYTHON env variable:<br>
&gt; <a href="https://github.com/antocuni/toxproblem/blob/master/setup.py#L8" rel="noreferrer" target="_blank">https://github.com/antocuni/<wbr>toxproblem/blob/master/setup.<wbr>py#L8</a><br>
&gt;<br>
&gt; - there is a test to check that we actually compiled the file if the<br>
&gt; variable is set:<br>
&gt; <a href="https://github.com/antocuni/toxproblem/blob/master/test_foo.py#L7" rel="noreferrer" target="_blank">https://github.com/antocuni/<wbr>toxproblem/blob/master/test_<wbr>foo.py#L7</a><br>
&gt;<br>
&gt; - tox.ini has two envs: py27 for the normal case, and cy27 where I set<br>
&gt; USE_CYTHON=1 to enable compilation:<br>
&gt; <a href="https://github.com/antocuni/toxproblem/blob/master/tox.ini" rel="noreferrer" target="_blank">https://github.com/antocuni/<wbr>toxproblem/blob/master/tox.ini</a><br>
&gt;<br>
&gt; Everything works well if I run things manually:<br>
&gt;<br>
&gt;   # test without cython<br>
&gt;   $ (rm -f foo.so; python setup.py build_ext --inplace; py.test)<br>
&gt;<br>
&gt;   # test with cython<br>
&gt;   $ (export USE_CYTHON=1; rm -f foo.so; python setup.py build_ext<br>
&gt; --inplace; py.test)<br>
&gt;<br>
&gt; However, if I use tox, it always installs the non-cython version, even in<br>
&gt; the cy27 environment:<br>
&gt;<br>
&gt;   $ tox<br>
&gt;   ...<br>
&gt;     FAIL test_foo.py::test_PYX<br>
&gt;   ...<br>
&gt;     py27: commands succeeded<br>
&gt;     ERROR:   cy27: commands failed<br>
&gt;<br>
&gt; (full output visible in the README :)).<br>
&gt;<br>
&gt; I tried to investigate a bit, and looking at the log it seems that tox (or<br>
&gt; maybe pip?) builds a wheel of my package, and then re-use it to install in<br>
&gt; cy27, but then the wheel does not contain the compiled module. But I did<br>
&gt; not manage to understand what&#39;s going on exactly.<br>
&gt;<br>
&gt; Thank you :)<br>
&gt; Antonio<br>
<br>
</div></div>&gt; ______________________________<wbr>_________________<br>
&gt; testing-in-python mailing list<br>
&gt; <a href="mailto:testing-in-python@lists.idyll.org">testing-in-python@lists.idyll.<wbr>org</a><br>
&gt; <a href="http://lists.idyll.org/listinfo/testing-in-python" rel="noreferrer" target="_blank">http://lists.idyll.org/<wbr>listinfo/testing-in-python</a><br>
<br>
</blockquote></div><br></div>