diff --git a/ldm/__init__.py b/ldm/__init__.py new file mode 100644 index 0000000..1cc20f6 --- /dev/null +++ b/ldm/__init__.py @@ -0,0 +1,20 @@ +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}") diff --git a/ldm/__version__.py b/ldm/__version__.py new file mode 100644 index 0000000..58039f5 --- /dev/null +++ b/ldm/__version__.py @@ -0,0 +1 @@ +__version__ = "2.1.1" diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..4e85a0a --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,37 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "stable-diffusion" +dynamic = ["version"] +description = "Stable Diffusion is a latent text-to-image diffusion model." +readme = "README.md" +license = "MIT" +requires-python = ">=3.8" # based on environment.yaml +zip-safe = false # we need to be read the YAMLs from disk +dependencies = [ + "numpy", + "torch", + "tqdm", +] + +[tool.hatch.version] +path = "ldm/__version__.py" + +[tool.hatch.build] +# This needs to be explicitly set so the configuration files +# grafted into the `ldm` directory get included in the wheel's +# RECORD file. +include = [ + "ldm", +] +# The force-include configurations below make Hatch copy +# the configs/ directory (containing the various YAML files required +# to stably diffuse) into the source distribution and the wheel. + +[tool.hatch.build.targets.sdist.force-include] +"./configs" = "ldm/configs" + +[tool.hatch.build.targets.wheel.force-include] +"./configs" = "ldm/configs" diff --git a/setup.py b/setup.py deleted file mode 100644 index 00f5b4d..0000000 --- a/setup.py +++ /dev/null @@ -1,13 +0,0 @@ -from setuptools import setup, find_packages - -setup( - name='stable-diffusion', - version='0.0.1', - description='', - packages=find_packages(), - install_requires=[ - 'torch', - 'numpy', - 'tqdm', - ], -) \ No newline at end of file