PythonPackage: add import module smoke tests#20023
PythonPackage: add import module smoke tests#20023tldahlgren merged 10 commits intospack:developfrom
Conversation
This comment has been minimized.
This comment has been minimized.
| def build_test(self): | ||
| """Run unit tests after in-place build. | ||
|
|
||
| These tests are only run if the package actually has a 'test' command. | ||
| """ | ||
| if self._setup_command_available('test'): | ||
| args = self.test_args(self.spec, self.prefix) | ||
|
|
||
| self.setup_py('test', *args) |
There was a problem hiding this comment.
Running python setup.py test is deprecated, as most packages tell you to use something like tox instead. Also, the vast majority of packages do not upload any test files to PyPI, making these tests a no-op. Even if they do, I rarely manage to get the tests to pass, and many tests introduce circular dependencies. I've been meaning to do this for a long time now, but I'm removing these tests for the aforementioned reasons.
| version('17.1', sha256='f019b770dd64e585a99714f1fd5e01c7a8f11b45635aa953fd41c689a657375b') | ||
| version('16.8', sha256='5d50835fdf0a7edf0b55e311b7c887786504efea1177abd7e69329a8e5ea619e') | ||
|
|
||
| depends_on('py-setuptools', type='build') |
There was a problem hiding this comment.
I noticed a bug where spack install py-packaging would install a .egg-info file but no actual packaging.py file. This was causing other packages to fail. Adding a setuptools dependency fixes this bug.
|
@skosukhin may be interested in reviewing this. |
|
Refers #20079 |
|
Ping @becker33 @tldahlgren |
|
This PR affects a lot of files. Are you sure you haven't missed any? ;) I haven't checked each package, but a basic FWIW. I plan to install a bunch of packages and run the tests. |
|
How did you decide on which (python) test dependencies to remove? I see a number of packages that still list test dependencies on packages such as |
|
I removed test dependencies from packages that no longer have unit tests. |
5e6e1fe to
918bd2e
Compare
| elif context == 'test': | ||
| import spack.user_environment as uenv # avoid circular import | ||
| env.extend(uenv.environment_modifications_for_spec(pkg.spec)) | ||
| env.extend( |
|
Closed by mistake. |
|
Reopening since accidentally closed. |
tldahlgren
left a comment
There was a problem hiding this comment.
The tests appeared to pass for all of the packages I installed.
I would prefer to see output generated to the test logs along the lines produced by the run_test test method.
This comment has been minimized.
This comment has been minimized.
918bd2e to
39f1b70
Compare
|
@tldahlgren the latest commit makes use of |
There was a problem hiding this comment.
LGTM. I prefer explicit purpose descriptions for test but the test log output was sufficient.
I had a failure for one of the packages but that may be because I was having concretization issues with my last round of installs.
Update: FWIW. After re-running spack install on all the packages I was testing, all of the tests now work.
|
What would be a good purpose description? Would you include the module name in the purpose? |
I do in general. The reason is it can be useful to My inclination would be something along the lines |
|
Done. I didn't add |
I agree. What do you think @becker33 ? BTW. Without |
cosmicexplorer
left a comment
There was a problem hiding this comment.
One possibly-surprising pylab insertion, and one nonblocking question about checking for modules named test.
| When you run ``spack install --test=root py-pyqt5``, Spack will attempt | ||
| to import the ``PyQt5`` module after installation. | ||
| These tests often catch missing dependencies and non-RPATHed | ||
| libraries. Make sure not to add modules/packages containing the word |
There was a problem hiding this comment.
Great clarification!
Nonblocking: Would it be useful if I created a separate issue discussing checking for test in the added modules/packages? Does that occur in import_modules()? Or is that intrinsic somehow?
There was a problem hiding this comment.
As of now, import_modules doesn't ignore test* modules. When I originally wrote this in #15370, I was using setuptools.find_packages, which has a tool for this. It would probably be good to add something similar to the default import_modules implementation. Do you want that to happen in this PR or would a follow-up PR be fine?
There was a problem hiding this comment.
FWIW. I think a follow-up PR is fine (or preferred).
| 'matplotlib.sphinxext', 'matplotlib.cbook', 'matplotlib.backends', | ||
| 'matplotlib.backends.qt_editor', 'matplotlib.style', | ||
| 'matplotlib.projections', 'matplotlib.testing', | ||
| 'matplotlib.testing.jpl_units', 'pylab' |
There was a problem hiding this comment.
'pylab' appears to be new here. Where does that arise from?
There was a problem hiding this comment.
In Python lingo, there are "modules" and "packages". "modules" are things like six, where the only thing that gets installed is a single six.py file in site-packages. "packages" are things like numpy, where there is no numpy.py, but instead there is a numpy/__init__.py with sub-directories containing code.
Previously, I was using setuptools.find_packages to get a list of import modules. find_packages only returns "packages", not "modules". matplotlib is one of those rare packages that mixes "modules" and "packages". The installation prefix has both matplotlib/__init__.py, mpl_toolkits/__init__.py, and pylab.py. My new code checks for both, which is why pylab was added.
| version('17.1', sha256='f019b770dd64e585a99714f1fd5e01c7a8f11b45635aa953fd41c689a657375b') | ||
| version('16.8', sha256='5d50835fdf0a7edf0b55e311b7c887786504efea1177abd7e69329a8e5ea619e') | ||
|
|
||
| depends_on('py-setuptools', type='build') |
| python_paths.append(root) | ||
|
|
||
| pythonpath = ':'.join(python_paths) | ||
| env.prepend_path('PYTHONPATH', pythonpath) |
There was a problem hiding this comment.
Much easier to follow, thank you.
Should allow us to automatically check more modules and alleviate the need to create some private checks in different Jenkins CIs. Original commit message: PythonPackage: add import module smoke tests (spack#20023)
Should allow us to automatically check more modules and alleviate the need to create some private checks in different Jenkins CIs. Original commit message: PythonPackage: add import module smoke tests (spack#20023)
Should allow us to automatically check more modules and alleviate the need to create some private checks in different Jenkins CIs. Original commit message: PythonPackage: add import module smoke tests (spack#20023)
Should allow us to automatically check more modules and alleviate the need to create some private checks in different Jenkins CIs. Original commit message: PythonPackage: add import module smoke tests (spack#20023)
Should allow us to automatically check more modules and alleviate the need to create some private checks in different Jenkins CIs. Original commit message: PythonPackage: add import module smoke tests (spack#20023)
This PR adds smoke tests for the 1,255 Python packages in Spack. It has been tested on the 180+ Python packages I have installed on my system.
Specifically, this PR makes the following changes:
import_modulesimport_modulesbuild_testandinstall_testphasesbuild_testandinstall_testReboot of #15370
Closes #20079
Closes #20090