mirror of
https://github.com/Stability-AI/stablediffusion.git
synced 2024-12-22 23:55:00 +00:00
ab12d81663
* Adds `ldm/__version__.py` (2.1.1 seems to approximately match what the readme says) * Sets up packaging using `hatch` (removing the defunct `setup.py`) * `configs/` gets packaged as `ldm/configs` when using a packaged version * Adds `ldm.get_configs_path()` to make it easy for downstream users to find the configs path
20 lines
622 B
Python
20 lines
622 B
Python
import os
|
|
|
|
|
|
def get_configs_path() -> str:
|
|
"""
|
|
Get the `configs` directory.
|
|
|
|
For a working copy, this is the one in the root of the repository,
|
|
but for an installed copy, it's in the `ldm` package (see pyproject.toml).
|
|
"""
|
|
this_dir = os.path.dirname(__file__)
|
|
candidates = (
|
|
os.path.join(this_dir, "configs"),
|
|
os.path.join(this_dir, "..", "configs"),
|
|
)
|
|
for candidate in candidates:
|
|
candidate = os.path.abspath(candidate)
|
|
if os.path.isdir(candidate):
|
|
return candidate
|
|
raise FileNotFoundError(f"Could not find LDM configs in {candidates}")
|