src/flask/scaffold.py
def find_package(import_name: str):
    """Find the prefix that a package is installed under, and the path
    that it would be imported from.

    The prefix is the directory containing the standard directory
    hierarchy (lib, bin, etc.). If the package is not installed to the
    system (:attr:`sys.prefix`) or a virtualenv (``site-packages``),
    ``None`` is returned.

    The path is the entry in :attr:`sys.path` that contains the package
    for import. If the package is not installed, it's assumed that the
    package was imported from the current working directory.
    """
    root_mod_name, _, _ = import_name.partition(".")
    package_path = _find_package_path(root_mod_name)
    py_prefix = os.path.abspath(sys.prefix)

    # installed to the system
    if package_path.startswith(py_prefix):
        return py_prefix, package_path

    site_parent, site_folder = os.path.split(package_path)

    # installed to a virtualenv
    if site_folder.lower() == "site-packages":
        parent, folder = os.path.split(site_parent)

        # Windows (prefix/lib/site-packages)
        if folder.lower() == "lib":
            return parent, package_path

        # Unix (prefix/lib/pythonX.Y/site-packages)
        if os.path.basename(parent).lower() == "lib":
            return os.path.dirname(parent), package_path

        # something else (prefix/site-packages)
        return site_parent, package_path

    # not installed
    return None, package_path
Find the prefix that a package is installed under, and the path
    that it would be imported from.

    The prefix is the directory containing the standard directory
    hierarchy (lib, bin, etc.). If the package is not installed to the
    system (:attr:`sys.prefix`) or a virtualenv (``site-packages``),
    ``None`` is returned.

    The path is the entry in :attr:`sys.path` that contains the package
    for import. If the package is not installed, it's assumed that the
    package was imported from the current working directory.
    
Find the prefix that a package is installed under, and the path
that it would be imported from.

The prefix is the directory containing the standard directory
hierarchy (lib, bin, etc.).

The path is the entry in :attr:`sys.path` that contains the package
for import. If the package is not installed, it's assumed that the
package was imported from the current working directory.
Find the prefix that a package is installed under and the path that it would be imported from . The prefix is the directory containing the standard directory hierarchy ( lib bin etc . ) . The path is the entry in : attr : ` sys . path ` that contains the package for import . If the package is not installed it ' s assumed that the package was imported from the current working directory .
def find_package(import_name: str):
    root_mod_name, _, _ = import_name.partition(".")
    package_path = _find_package_path(root_mod_name)
    py_prefix = os.path.abspath(sys.prefix)
    if package_path.startswith(py_prefix):
        return py_prefix, package_path
    site_parent, site_folder = os.path.split(package_path)
    if site_folder.lower() == "site-packages":
        parent, folder = os.path.split(site_parent)
        if folder.lower() == "lib":
            return parent, package_path
        if os.path.basename(parent).lower() == "lib":
            return os.path.dirname(parent), package_path
        return site_parent, package_path
    return None, package_path
def find_package ( import_name : str ) : root_mod_name , _ , _ = import_name . partition ( "." ) package_path = _find_package_path ( root_mod_name ) py_prefix = os . path . abspath ( sys . prefix ) if package_path . startswith ( py_prefix ) : return py_prefix , package_path site_parent , site_folder = os . path . split ( package_path ) if site_folder . lower ( ) == "site-packages" : parent , folder = os . path . split ( site_parent ) if folder . lower ( ) == "lib" : return parent , package_path if os . path . basename ( parent ) . lower ( ) == "lib" : return os . path . dirname ( parent ) , package_path return site_parent , package_path return None , package_path
Find the prefix that a package is installed under, and the path
that it would be imported from.
Find the prefix that a package is installed under and the path that it would be imported from .
"""Find the prefix that a package is installed under, and the path
    that it would be imported from.

    The prefix is the directory containing the standard directory
    hierarchy (lib, bin, etc.). If the package is not installed to the
    system (:attr:`sys.prefix`) or a virtualenv (``site-packages``),
    ``None`` is returned.

    The path is the entry in :attr:`sys.path` that contains the package
    for import. If the package is not installed, it's assumed that the
    package was imported from the current working directory.
    """ # installed to the system # installed to a virtualenv # Windows (prefix/lib/site-packages) # Unix (prefix/lib/pythonX.Y/site-packages) # something else (prefix/site-packages) # not installed
import_name
str