Closed avalentino closed 5 months ago
Good catch!
Thanks
Why at all test suite is distributed win .whl at all? 🤔 Better would be move test suite with its data to tests/ and distribute only in sdist.
@kloczek to me it makes totally sense to distribute test s and test data in sdist. What could be an option, IMHO, is to not install them (i.e. do not include them in the .whl).
test suite should not be distributed as part of the installable resources. Currently it is included
Looks like easiest way to do that would be just move pooch/tests/ to tests/ If test suite is not using relative imports .. if it uses then those relative imports needs to be dropped (using relative imports is always is nothing more than asking for troubles ..).
Just checked source code and relative imports are in use 😞 In first file pooch/tests/utils.py I found:
from .. import __version__ as full_version
from ..utils import check_version, get_logger
Distributing tests with the source code was a design decision that dates back to the origin of the package. This was intended to allow users to run tests on the installed version of the package without the need to clone the repository. We saw value on it back in the days. We even included instructions on how to run the tests after installation (see the old docs: https://www.fatiando.org/pooch/v1.0.0/install.html#testing-your-install). The relative imports were also intended: since tests were part of the code base, it made sense to use relative imports as we would do in any submodule of the package.
Nonetheless, we've been discussing about removing the test suite from the package since users rarely test the code after installation, and we would like to reduce the size of the packages that ppl download, specially since Pooch is being widely used by many packages in the community. Check out https://github.com/fatiando/community/issues/154, https://github.com/fatiando/pooch/pull/423, https://github.com/fatiando/pooch/issues/416 and https://github.com/fatiando/pooch/pull/427 for more details.
I appreciate your suggestions on this matter. Although, I don't think these design decisions were bad in nature. We wanted to provide our users with a feature (run tests after installation), which now we are reconsidering in favor of reducing installation size. There's no PEP rule against shipping tests along with code (in fact many heavily used scientific Python packages ship tests. See Numpy, matplotlib, scikit-learn as examples). In fact, including tests in the code of the package is one of the test layouts recommended by pytest
. Therefore, the decisions to include the tests
folder within the sources or outside of it, or to ship them or not are mostly tied to the preferences and needs of the maintainers.
The test code
pooch/tests
is installed but he data inpooch/tests/data
are not. This makes it impossible to run tests on the installed package.