Consider switching to "src" package layout and using "tox" for test running
When hacking on Kwant it is recommended by the Kwant docs to use python setup.py build_ext --inplace && pytest
for testing.
There are a couple of problems I have observed with this workflow:
- the
build_ext --inplace
step is kind of non-standard, and if done incorrectly (e.g. by omitting the--inplace
) thenpython -c 'import kwant'
complains about not importing Kwant from the correct place (this has confused me more times than I care to mention) - placing the
.c
files next to the source an be problematic.Cython
is not re-run if the associated.pyx
file has not changed, but if we are using different versions of Cython, or targeting different CPython APIs (can happen when jumping around betweenstable
/master
) then the.c
files are still not regenerated. - locally testing against different environments becomes a pain (manually deactivating / reactivating different Conda environments / whoops I just wasted 10 minutes because I was in the wrong environment)
I believe that points 1 and 3 can be addressed by using the src
layout (i.e. have the Kwant source code under src/kwant
rather than directly in kwant
) and by using an environment-aware test-runner such as tox (which also has support for Conda environments).
I am not sure if this will address 2, but 2/3 ain't bad.