crowsonkb / k-diffusion

Karras et al. (2022) diffusion models for PyTorch
MIT License
2.26k stars 372 forks source link

Allow installing via pip install -e <repo link> - Adds a setup.py #26

Closed cmdr2 closed 1 year ago

cmdr2 commented 1 year ago

Hi, thanks for the excellent library! :)

Installing this repo using pip install -e git+https://github.com/crowsonkb/k-diffusion#egg=k_diffusion results in a FileNotFoundError since it looks for a setup.py.

I was able to use https://github.com/hlky/k-diffusion-sd to install it this way, but it lags behind a bit. I was wondering if you'd be open to accepting this setup.py into the main repo (sourced from the hlky repo). This allows other users to use the latest k-diffusion library, without the error during installation.

Thanks

fire17 commented 1 year ago

Hi there! just ran into this mentioned problem, PLEASE ACCEPT THIS PR :pray:

➜  stable-diffusion-webui git:(master) ✗ bash < webui.sh                          

################################################################
Install script for stable-diffusion + Web UI
Tested on Debian 11 (Bullseye)
################################################################

################################################################
Running on magic user
################################################################

################################################################
Repo already cloned, using it as install directory
################################################################

################################################################
Clone or update stable-diffusion-webui
################################################################
Already up to date.

################################################################
Create and activate python venv
################################################################

################################################################
Launching launch.py...
################################################################
Python 3.7.3 (default, Mar  9 2022, 03:38:16) 
[GCC 8.3.0]
Commit hash: 1578859305f3593fa213309e505905e607a0e52c
Installing k-diffusion
Traceback (most recent call last):
  File "launch.py", line 101, in <module>
    run_pip(f"install {k_diffusion_package}", "k-diffusion")
  File "launch.py", line 54, in run_pip
    return run(f'"{python}" -m pip {args} --prefer-binary', desc=f"Installing {desc}", errdesc=f"Couldn't install {desc}")
  File "launch.py", line 44, in run
    raise RuntimeError(message)
RuntimeError: Couldn't install k-diffusion.
Command: "/home/magic/wholesomegarden/stable-diffusion-webui/venv/bin/python3" -m pip install git+https://github.com/crowsonkb/k-diffusion.git@1a0703dfb7d24d8806267c3e7ccc4caf67fd1331 --prefer-binary
Error code: 1
stdout: Collecting git+https://github.com/crowsonkb/k-diffusion.git@1a0703dfb7d24d8806267c3e7ccc4caf67fd1331
  Cloning https://github.com/crowsonkb/k-diffusion.git (to revision 1a0703dfb7d24d8806267c3e7ccc4caf67fd1331) to /tmp/pip-req-build-vc76l0lb
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/usr/lib/python3.7/tokenize.py", line 447, in open
        buffer = _builtin_open(filename, 'rb')
    FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip-req-build-vc76l0lb/setup.py'

    ----------------------------------------

stderr: Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-req-build-vc76l0lb/
crowsonkb commented 1 year ago

It works for me, maybe you need to update pip and setuptools?

fire17 commented 1 year ago

well im not sure which did it, the pr or the pip / setuptools update But either way it's working!! Thanks @AdamOswald , Thanks @crowsonkb !!

Seems they were in need of an update indeed, I ran both: python3.7 -m pip install --upgrade pip setuptools ~/stable-diffusion-webui/venv/bin/python3 -m pip install --upgrade pip setuptools

Now k-diffusion passed installation :) Thanks a lot !!! :pray:

akx commented 1 year ago

I don't think this PR is necessary – if anything, this repo could shift to modern pyproject.toml based packaging using e.g. Hatch :) (I'd be glad to do the work!)