8000 BLD: use install-tags to optionally install tests (#26274) · melissawm/numpy@3ea613c · GitHub
[go: up one dir, main page]

Skip to content

Commit 3ea613c

Browse files
czgdp1807rgommers
andauthored
BLD: use install-tags to optionally install tests (numpy#26274)
- Add the 'tests' install tag to all test-related files - Move `test_pyinstaller.py` under a `tests` folder to match standard test layout of other directories - Extend `tools/check_installation.py` to check that all installed files have tags, and that omitting 'tests' is complete - Add a CI step in the "custom checks" job to use the extra `check_installation.py` checks - Shift docstring of private function in `_multiarray_tests.so` to a code comment Co-authored-by: Ralf Gommers <ralf.gommers@gmail.com>
1 parent d567754 commit 3ea613c

File tree

13 files changed

+95
-52
lines changed

13 files changed

+95
-52
lines changed

.github/workflows/linux.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,3 +282,8 @@ jobs:
282282
run: |
283283
# Need the explicit `bash -c` here because `grep` returns exit code 1 for no matches
284284
bash -c "! vulture . --min-confidence 100 --exclude doc/,numpy/distutils/,vendored-meson/ | grep 'unreachable'"
285+
- name: Check usage of install_tag
286+
run: |
287+
rm -rf build-install
288+
./vendored-meson/meson/meson.py install -C build --destdir ../build-install --tags=runtime,python-runtime,devel
289+
python tools/check_installed_files.py $(find ./build-install -path '*/site-packages/numpy') --no-tests

numpy/_core/_add_newdocs.py

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2034,7 +2034,7 @@
20342034
To enable and control broadcasting, use an ellipsis. Default
20352035
NumPy-style broadcasting is done by adding an ellipsis
20362036
to the left of each term, like ``np.einsum('...ii->...i', a)``.
2037-
``np.einsum('...i->...', a)`` is like
2037+
``np.einsum('...i->...', a)`` is like
20382038
:py:func:`np.sum(a, axis=-1) <numpy.sum>` for array ``a`` of any shape.
20392039
To take the trace along the first and last axes,
20402040
you can do ``np.einsum('i...i', a)``, or to do a matrix-matrix
@@ -4871,37 +4871,6 @@
48714871
See `global_state` for more information.
48724872
""")
48734873

4874-
add_newdoc('numpy._core._multiarray_tests', 'format_float_OSprintf_g',
4875-
"""
4876-
format_float_OSprintf_g(val, precision)
4877-
4878-
Print a floating point scalar using the system's printf function,
4879-
equivalent to:
4880-
4881-
printf("%.*g", precision, val);
4882-
4883-
for half/float/double, or replacing 'g' by 'Lg' for longdouble. This
4884-
method is designed to help cross-validate the format_float_* methods.
4885-
4886-
Parameters
4887-
----------
4888-
val : python float or numpy floating scalar
4889-
Value to format.
4890-
4891-
precision : non-negative integer, optional
4892-
Precision given to printf.
4893-
4894-
Returns
4895-
-------
4896-
rep : string
4897-
The string representation of the floating point value
4898-
4899-
See Also
4900-
--------
4901-
format_float_scientific
4902-
format_float_positional
4903-
""")
4904-
49054874

49064875
##############################################################################
49074876
#

numpy/_core/meson.build

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,7 @@ py.extension_module('_multiarray_tests',
718718
gnu_symbol_visibility: 'default',
719719
install: true,
720720
subdir: 'numpy/_core',
721+
install_tag: 'tests'
721722
)
722723

723724
_umath_tests_mtargets = mod_features.multi_targets(
@@ -754,6 +755,7 @@ foreach gen: test_modules_src
754755
install: true,
755756
subdir: 'numpy/_core',
756757
link_with: gen[2],
758+
install_tag: 'tests'
757759
)
758760
endforeach
759761

@@ -1329,4 +1331,4 @@ py.install_sources(
13291331
)
13301332

13311333
subdir('include')
1332-
install_subdir('tests', install_dir: np_dir / '_core', install_tag: 'python-runtime')
1334+
install_subdir('tests', install_dir: np_dir / '_core', install_tag: 'tests')

numpy/_core/src/multiarray/_multiarray_tests.c.src

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1992,7 +1992,35 @@ PrintFloat_Printf_g(PyObject *obj, int precision)
19921992
return PyUnicode_FromString(str);
19931993
}
19941994

1995-
1995+
/*
1996+
* format_float_OSprintf_g(val, precision)
1997+
*
1998+
* Print a floating point scalar using the system's printf function,
1999+
* equivalent to:
2000+
*
2001+
* printf("%.*g", precision, val);
2002+
*
2003+
* for half/float/double, or replacing 'g' by 'Lg' for longdouble. This
2004+
* method is designed to help cross-validate the format_float_* methods.
2005+
*
2006+
* Parameters
2007+
* ----------
2008+
* val : python float or numpy floating scalar
2009+
* Value to format.
2010+
*
2011+
* precision : non-negative integer, optional
2012+
* Precision given to printf.
2013+
*
2014+
* Returns
2015+
* -------
2016+
* rep : string
2017+
* The string representation of the floating point value
2018+
*
2019+
* See Also
2020+
* --------
2021+
* format_float_scientific
2022+
* format_float_positional
2023+
*/
19962024
static PyObject *
19972025
printf_float_g(PyObject *NPY_UNUSED(dummy), PyObject *args, PyObject *kwds)
19982026
{

numpy/_pyinstaller/tests/__init__.py

Whitespace-only changes.

numpy/fft/meson.build

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,6 @@ py.install_sources(
3434
'tests/test_helper.py',
3535
'tests/test_pocketfft.py',
3636
],
37-
subdir: 'numpy/fft/tests'
37+
subdir: 'numpy/fft/tests',
38+
install_tag: 'tests'
3839
)

numpy/linalg/meson.build

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,6 @@ py.install_sources(
5757
'tests/test_linalg.py',
5858
'tests/test_regression.py',
5959
],
60-
subdir: 'numpy/linalg/tests'
60+
subdir: 'numpy/linalg/tests',
61+
install_tag: 'tests'
6162
)

numpy/meson.build

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,6 @@ pure_subdirs = [
273273
'matrixlib',
274274
'polynomial',
275275
'testing',
276-
'tests',
277276
'typing',
278277
'rec',
279278
'char',
@@ -312,9 +311,14 @@ else
312311
endif
313312

314313
foreach subdir: pure_subdirs
315-
install_subdir(subdir, install_dir: np_dir, install_tag: 'python-runtime')
314+
install_subdir(subdir, install_dir: np_dir, install_tag: 'python-runtime', exclude_directories: ['tests'])
315+
if fs.is_dir(subdir/'tests')
316+
install_subdir(subdir/'tests', install_dir: np_dir/subdir, install_tag: 'tests')
317+
endif
316318
endforeach
317319

320+
install_subdir('tests', install_dir: np_dir, install_tag: 'tests')
321+
318322
compilers = {
319323
'C': cc,
320324
'CPP': cpp,

0 commit comments

Comments
 (0)
0