-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
Description
Often Python packages also install their tests. After the check phase we have no use for them and so there is no need to actually copy them to $out. In certain cases the closure size can be reduced dramatically by excluding the tests, like with matplotlib as shown in #12218 for example, although in general the difference is likely not significant.
I propose we enable an option which by default removes the tests and would like to discuss here how to implement this.
Interface
We need an option with which we can enable/disable this for a specific package. Furthermore, it would be nice if this option would take not just a boolean, but a list with paths to use instead as well, so true, false or [].
Implementation
Which directories to remove? Python tests can be anywhere. Test runners for example search all packages for modules matching test_*.py or test_*.py. I suggest we do the same and delete those files.
Where to implement this in buildPythonPackage then? According to the manual:
buildPythonPackagemainly does four things:
- In the
buildPhase, it calls${python.interpreter} setup.py bdist_wheelto build a wheel binary zipfile.- In the
installPhase, it installs the wheel file usingpip install *.whl.- In the
postFixupphase,wrapPythonProgramsbash function is called to wrap all programs in$out/bin/*directory to include$PYTHONPATHand$PATHenvironment variables.- In the
installCheckPhase,${python.interpreter} setup.py test` is ran.
Clearly it won't be possible to remove the tests until after installCheckPhase.
Should we add another phase after installCheckPhase for this?