find_package() — flask Function Reference
Architecture documentation for the find_package() function in scaffold.py from the flask codebase.
Entity Profile
Dependency Diagram
graph TD 4edb5aa7_d577_d1ba_2a86_d1b146357835["find_package()"] b48dce3f_427c_079b_4c4a_8f5873f5b51f["scaffold.py"] 4edb5aa7_d577_d1ba_2a86_d1b146357835 -->|defined in| b48dce3f_427c_079b_4c4a_8f5873f5b51f 5d914b38_d2af_c173_db31_3a2d1e8e567d["auto_find_instance_path()"] 5d914b38_d2af_c173_db31_3a2d1e8e567d -->|calls| 4edb5aa7_d577_d1ba_2a86_d1b146357835 3e63b545_7895_fecc_eae5_b9d8a7667c97["_find_package_path()"] 4edb5aa7_d577_d1ba_2a86_d1b146357835 -->|calls| 3e63b545_7895_fecc_eae5_b9d8a7667c97 style 4edb5aa7_d577_d1ba_2a86_d1b146357835 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/flask/sansio/scaffold.py lines 754–792
def find_package(import_name: str) -> tuple[str | None, 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.
"""
package_path = _find_package_path(import_name)
py_prefix = os.path.abspath(sys.prefix)
# installed to the system
if pathlib.PurePath(package_path).is_relative_to(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
Domain
Subdomains
Defined In
Calls
Called By
Source
Frequently Asked Questions
What does find_package() do?
find_package() is a function in the flask codebase, defined in src/flask/sansio/scaffold.py.
Where is find_package() defined?
find_package() is defined in src/flask/sansio/scaffold.py at line 754.
What does find_package() call?
find_package() calls 1 function(s): _find_package_path.
What calls find_package()?
find_package() is called by 1 function(s): auto_find_instance_path.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free