mirror of
https://github.com/Stability-AI/stablediffusion.git
synced 2024-12-22 15:44:58 +00:00
Set up Python packaging
* 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
This commit is contained in:
parent
cf1d67a6fd
commit
ab12d81663
4 changed files with 58 additions and 13 deletions
20
ldm/__init__.py
Normal file
20
ldm/__init__.py
Normal file
|
@ -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}")
|
1
ldm/__version__.py
Normal file
1
ldm/__version__.py
Normal file
|
@ -0,0 +1 @@
|
||||||
|
__version__ = "2.1.1"
|
37
pyproject.toml
Normal file
37
pyproject.toml
Normal file
|
@ -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"
|
13
setup.py
13
setup.py
|
@ -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',
|
|
||||||
],
|
|
||||||
)
|
|
Loading…
Reference in a new issue