-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exclude tests from wheel #249
Conversation
It's generally not desired to install tests together with the module. This change does just that and keeps everything else unchanged. Tests are still included in the sdist.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #249 +/- ##
==========================================
- Coverage 97.75% 91.89% -5.87%
==========================================
Files 16 16
Lines 1739 1739
==========================================
- Hits 1700 1598 -102
- Misses 39 141 +102
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, I think that, if we're going to exclude tests from the wheel (which I support), we should go all the way and move tests/
outside of dandischema/
— but @yarikoptic doesn't like either of these practices.
why? Does it solve any problem? it kinda introduces some though:
And so far I personally did not spot any problem being solved, or convenience being introduced, so not sure if a worthwhile effort. |
Well, I looked at that option as well. But that's complicated by the fact that there are tests in
I think both points very much depend on how you run tests and how your dev environment is set up. In the end, it's a suggestion (based on common practice). But the decision is entirely up to you. I am / we are happy to carry it as a downstream only patch. Footnotes
|
We arrived at the motivation/rationale, which IMHO boils down to: an installed component ( FWIW, for Debian packages (I am yet to package this one though), I usually enable not just import test but running all discovered tests during package build time. Then pytest should be installed etc for that purpose. And I do then install the tests but do not add |
FWIW, even though I now see rationale, @penguinpee, if you could share some pointers to support the common practice and generally "claims", I would appreciate that! |
I think the most compelling argument for not including tests can be made by looking at what setuptools does when using automatic discovery. I already linked to the documentation, but here it is again, explicitly: https://setuptools.pypa.io/en/latest/userguide/package_discovery.html#flat-layout You have
(emphasis mine) Note that automatic discovery only works when |
@penguinpee setuptools' automatic discovery only filters out top-level |
A less compelling argument might be PyPA's sampleproject which uses automatic discovery with a src-layout. By placing |
You are correct. I misunderstood that part. It indeed only filters on the top-level names. |
@jwodder , IIRC you had/know of some kind of index of pip packages, am I right? I wonder if there is a listing of contents of source packages/distribution to get some stats on how common is to ship tests within sources, within numpy - within `numpy` package, and shipped in source distribution, (edit) and shipped in .whl❯ find -iname tests
./numpy/_core/tests
./numpy/_pyinstaller/tests
./numpy/compat/tests
./numpy/distutils/tests
./numpy/f2py/tests
./numpy/fft/tests
./numpy/lib/tests
./numpy/linalg/tests
./numpy/ma/tests
./numpy/matrixlib/tests
./numpy/polynomial/tests
./numpy/random/tests
./numpy/testing/tests
./numpy/tests
./numpy/typing/tests ❯ tar -tzvf <(curl --silent https://files.pythonhosted.org/packages/54/a4/f8188c4f3e07f7737683588210c073478abcb542048cf4ab6fedad0b458a/numpy-2.1.0.tar.gz) | grep 'tests/test_.*\.py' | head
-rw-r--r-- 0/0 5032 2024-07-08 08:34 numpy-2.1.0/numpy/_core/src/common/pythoncapi-compat/tests/test_pythoncapi_compat.py
-rw-r--r-- 0/0 27472 2024-07-08 08:34 numpy-2.1.0/numpy/_core/src/common/pythoncapi-compat/tests/test_upgrade_pythoncapi.py
-rw-r--r-- 0/0 2881 2024-08-18 13:20 numpy-2.1.0/numpy/_core/tests/test__exceptions.py
-rw-r--r-- 0/0 2221 2024-08-18 13:20 numpy-2.1.0/numpy/_core/tests/test_abc.py
-rw-r--r-- 0/0 22932 2024-08-18 13:20 numpy-2.1.0/numpy/_core/tests/test_api.py
-rw-r--r-- 0/0 2824 2024-08-18 13:20 numpy-2.1.0/numpy/_core/tests/test_argparse.py
-rw-r--r-- 0/0 3062 2024-08-18 13:20 numpy-2.1.0/numpy/_core/tests/test_array_api_info.py
-rw-r--r-- 0/0 34509 2024-08-18 13:20 numpy-2.1.0/numpy/_core/tests/test_array_coercion.py
-rw-r--r-- 0/0 7767 2024-08-18 13:20 numpy-2.1.0/numpy/_core/tests/test_array_interface.py
-rw-r--r-- 0/0 3264 2024-08-18 13:20 numpy-2.1.0/numpy/_core/tests/test_arraymethod.py ❯ unzip -l numpy-2.1.0-pp310-pypy310_pp73-win_amd64.whl | grep 'tests/test_.*\.py' | head
2853 2024-08-18 17:32 numpy/distutils/tests/test_build_ext.py
29586 2024-08-18 17:32 numpy/distutils/tests/test_ccompiler_opt.py
6523 2024-08-18 17:32 numpy/distutils/tests/test_ccompiler_opt_conf.py
7612 2024-08-18 17:32 numpy/distutils/tests/test_exec_command.py
1320 2024-08-18 17:32 numpy/distutils/tests/test_fcompiler.py
2191 2024-08-18 17:32 numpy/distutils/tests/test_fcompiler_gnu.py
1088 2024-08-18 17:32 numpy/distutils/tests/test_fcompiler_intel.py
1124 2024-08-18 17:32 numpy/distutils/tests/test_fcompiler_nagfor.py
1147 2024-08-18 17:32 numpy/distutils/tests/test_from_template.py
902 2024-08-18 17:32 numpy/distutils/tests/test_log.py |
Not one that covers sdists.
If you really want to investigate this, I suggest asking on https://discuss.python.org/c/packaging/14. |
I didn't mean to send you on a wild goose chase. If you prefer including the tests in the wheel, by all means do. As I stated before, we can carry this PR as a downstream only patch. Matter of fact we already do. Quite often when I see tests shipped in the wheel it turns out to be an oversight. Sometimes it is a genuine mistake, e.g. when they are shipped as a separate module. I have also come across projects that ship them neither in the wheel nor in the sdist. In such cases we usually fall back to acquiring the sources from the upstream forge, because we do want to run those tests as part of the build if possible within reasonable effort. |
Thank you @penguinpee ! For now I would just prefer to keep current practice among our projects, unless it would be prohibitive (e.g. large test data requirements etc) which would warrant adding separation of tests from the main code sources. Who knows -- I might be convinced in the opposite later on, so I will keep in mind this case of "import tests". |
…test also removed unnecessary now dev installation of joblib # extras test vs tox.ini: Most recent debate on tox.ini vs extra_depends is at con/solidation#43 (comment) Although I appreciate the convenience of "tox" as an entry point for testing, I increasingly find no support for it to be "the" location for testing depends listing. Moreover I keep running into cases of needing to fish out test dependencies somewhere else (tox.ini, nox etc) which then can differ across projects, and also require me to adopt some avoidable runtime etc overhead from running those extra test shims whenever pytest is just good enough. My arguments for generally adopting an approach of specifying test dependencies in setup.{cfg,py} or other "generic" locations as optional are: - pytest, and its extentions are used (imported) inside the tests. I, in 99% of cases, do consider "tests" to be the part of the source code. I would not consider them part of the source code whenever there is an outside test battery which is developed/maintained independently of the source code. As such, I think that dependencies for tests, as part of the source code, should be listed alongside with dependencies for the build/installation/run time dependencies. Some distributions even do "import test" across entire source code distribution and thus tend to decide or to request exclusion from source distributions (IMHO the wrong step in most of the cases). Ref: dandi/dandi-schema#249 - It is unfortunate that there is no "standard" convention on how/where to specify such test requirements, so I think it is ok to adopt [test] as the general convention among our projects. - tox.ini looses NOTHING from using "extras". - tox.ini is the correct location to describe environments and dependncies for external to source code tools/modules, i.e those not imported explicitly anywhere in the source code. - with description of test dependencies alongside with the main dependencies would benefit downstream distribution (debian, conda, gentoo, etc) packagers since they do not need to fish around for what other dependencies to install/recommend/suggest for the package. - I do appreciate the fact that test dependencies alone are not sufficient to run the tests, but invocation of the pytest is standardized enough to just invoke it against the source code. (given dependencies are installed) That is e.g. how dh-python helper in Debian operates -- if pytest dependency announced, just run pytest automagically. # joblib: joblib dev listing was added in commit 6375816 Author: John T. Wodder II <[email protected]> Date: Fri Mar 19 08:42:47 2021 -0400 likely to use ❯ git describe --contains 457d2c8a926105fd156b1dfccfaae3e500d22451 1.1.0~13 ❯ git show 457d2c8a926105fd156b1dfccfaae3e500d22451 commit 457d2c8a926105fd156b1dfccfaae3e500d22451 Author: John T. Wodder II <[email protected]> Date: Thu Mar 18 06:07:06 2021 -0400 Use inspect.signature() instead of inspect.getfullargspec() (#1165) This fixes a bug with the ignore parameter when the cached function is decorated Co-authored-by: Loïc Estève <[email protected]> and we have already joblib ~= 1.1 so should be all set.
…test Most recent debate on tox.ini vs extra_depends is at con/solidation#43 (comment) Although I appreciate the convenience of "tox" as an entry point for testing, I increasingly find no support for it to be "the" location for testing depends listing. Moreover I keep running into cases of needing to fish out test dependencies somewhere else (tox.ini, nox etc) which then can differ across projects, and also require me to adopt some avoidable runtime etc overhead from running those extra test shims whenever pytest is just good enough. My arguments for generally adopting an approach of specifying test dependencies in setup.{cfg,py} or other "generic" locations as optional are: - pytest, and its extentions are used (imported) inside the tests. I, in 99% of cases, do consider "tests" to be the part of the source code. I would not consider them part of the source code whenever there is an outside test battery which is developed/maintained independently of the source code. As such, I think that dependencies for tests, as part of the source code, should be listed alongside with dependencies for the build/installation/run time dependencies. Some distributions even do "import test" across entire source code distribution and thus tend to decide or to request exclusion from source distributions (IMHO the wrong step in most of the cases). Ref: dandi/dandi-schema#249 - It is unfortunate that there is no "standard" convention on how/where to specify such test requirements, so I think it is ok to adopt [test] as the general convention among our projects. - tox.ini looses NOTHING from using "extras". - tox.ini is the correct location to describe environments and dependncies for external to source code tools/modules, i.e those not imported explicitly anywhere in the source code. - with description of test dependencies alongside with the main dependencies would benefit downstream distribution (debian, conda, gentoo, etc) packagers since they do not need to fish around for what other dependencies to install/recommend/suggest for the package. - I do appreciate the fact that test dependencies alone are not sufficient to run the tests, but invocation of the pytest is standardized enough to just invoke it against the source code. (given dependencies are installed) That is e.g. how dh-python helper in Debian operates -- if pytest dependency announced, just run pytest automagically.
It's generally not desired to install tests together with the module.
This change does just that and keeps everything else unchanged. Tests
are still included in the sdist.