Fix _is_package_available reporting available without a version (#46125)
* Fix _is_package_available reporting available without a version
When find_spec resolves to a namespace package (e.g. a directory on
sys.path that shadows an optional PyPI dependency), the metadata
fallback returns getattr(package, "__version__", "N/A"). Returning
(True, "N/A") then breaks downstream callers that pass the value to
version.parse().
* Add regression test for namespace-shadow case in _is_package_available
* Require missing __file__ as well to mark a package unavailable
A versionless-but-installed package (e.g. rich) has no __version__ but
still sets __file__; only a PEP 420 namespace package (a bare dir
shadowing on sys.path) has neither. Gate on both so real installs and
frozen builds stay available.
* Consolidate _is_package_available edge case tests
---------
Co-authored-by: bob <amailok2@gmail.com>