Repository: pyinstaller/pyinstaller

Issue:
Standard install: "several hooks defined for 'numpy'"
## Description of the issue

When using `pyinstaller` after a plain install without user defined hooks on a project using numpy, I get the following *warning*:

```
1334 WARNING: Several hooks defined for module 'numpy'. Please take care they do not conflict.
```

With no user hooks defined, there should not be such a warning: the hooks shipped with pyinstaller should be consistent and non-conflicting.

### Context information (for bug reports)

* Output of `pyinstaller --version`: **5.8.0**
* Version of Python: **3.10.6**
* Platform: **Windows 10**
* How you installed Python: **From Python.org, but it's in a virtual env.**
* Did you also try this on another platform? Does it work there? **No, did not try it.**




Discussion:
> With no user hooks defined, there should not be such a warning: the hooks shipped with pyinstaller should be consistent and non-conflicting.

The "conflict" is between the `numpy` hook within `PyInstaller` and the hook provided by the `numpy` package itself.

The warning message has already been adjusted in #7458 - but perhaps it should also be downgraded from a warning to info or debug.

Given that there's an INFO message later on saying which hook it's chosen, I'd be happy for the conflict message to be removed completely. 
It's also probably safe to remove our copy of the NumPy hook by now. https://github.com/numpy/numpy/pull/20745 went in over a year ago.
> Given that there's an INFO message later on saying which hook it's chosen, I'd be happy for the conflict message to be removed completely.

You mean when the hook is ran? That's a good point, we can see which hook is used from that. So I'm also in favor of doing away with the multiple-hooks-available message altogether.
> It's also probably safe to remove our copy of the NumPy hook by now. [numpy/numpy#20745](https://github.com/numpy/numpy/pull/20745) went in over a year ago.

I think it would make more sense to keep our copy around for a while longer; the upstream hook was added in `numpy` v1.23.0 (which was released less than a year ago, in June '22). So anyone pinned at older version (e.g., 1.22) for whatever reason would end up without the hook when using the latest PyInstaller. 

Plus, if we get rid of the multiple-hooks-available message, having our copy around as a fallback doesn't really make much of a difference...
But I think we can get rid of our [`numpy._pytesttester` hook](https://github.com/pyinstaller/pyinstaller/blob/db95de4fa6c88a96d04cfb7a94e1d06b3bb3813a/PyInstaller/hooks/hook-numpy._pytesttester.py), because `pytest` is excluded in the `numpy` hook, and that exclusion should propagate to all submodules and subpackages of `numpy`.

Resolving patch:
diff --git a/PyInstaller/depend/imphook.py b/PyInstaller/depend/imphook.py
--- a/PyInstaller/depend/imphook.py
+++ b/PyInstaller/depend/imphook.py
@@ -114,11 +114,6 @@ def _cache_hook_dirs(self, hook_dirs):
                 # Fully-qualified name of this hook's corresponding module, constructed by removing the "hook-" prefix
                 # and ".py" suffix.
                 module_name = os.path.basename(hook_filename)[5:-3]
-                if module_name in self:
-                    logger.warning(
-                        "Several hooks defined for module %r. Using %r.", module_name,
-                        self[module_name][0].hook_filename
-                    )
 
                 # Lazily loadable hook object.
                 module_hook = ModuleHook(
diff --git a/PyInstaller/hooks/hook-numpy._pytesttester.py b/PyInstaller/hooks/hook-numpy._pytesttester.py
deleted file mode 100644
--- a/PyInstaller/hooks/hook-numpy._pytesttester.py
+++ /dev/null
@@ -1,16 +0,0 @@
-# -----------------------------------------------------------------------------
-# Copyright (c) 2013-2023, PyInstaller Development Team.
-#
-# Distributed under the terms of the GNU General Public License (version 2
-# or later) with exception for distributing the bootloader.
-#
-# The full license is in the file COPYING.txt, distributed with this software.
-#
-# SPDX-License-Identifier: (GPL-2.0-or-later WITH Bootloader-exception)
-# -----------------------------------------------------------------------------
-
-# numpy._pytesttester is unconditionally imported by numpy.core, thus we can not exclude _pytesttester (which would be
-# preferred). Anyway, we can avoid importing pytest, which pulls in anotehr 150+ modules. See
-# https://github.com/numpy/numpy/issues/17183
-
-excludedimports = ["pytest"]


Test patch: