Skip to content

Commit

Permalink
chore: 🧹 migrate from poetry to setuptools
Browse files Browse the repository at this point in the history
  • Loading branch information
melMass committed Jun 9, 2024
1 parent 1070edd commit dfd17f6
Show file tree
Hide file tree
Showing 2 changed files with 186 additions and 46 deletions.
147 changes: 147 additions & 0 deletions env.nu
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
# NOTE: This file is only use for development you can ignore it

use path.nu *

def get_root [--clean] {
if $clean {
$env.COMFY_CLEAN_ROOT
} else {
$env.COMFY_ROOT
}
}

export def "comfy build-web" [] {
cd $env.COMFY_MTB
cd web_source
npm run build
cp dist/*.js ../web/dist
}

export def "comfy dev-web" [] {
cd $env.COMFY_MTB
cd web_source
npm run dev
}


# start the comfy server
export def "comfy start" [--clean, --listen] {
let root = get_root --clean=($clean)
cd $root
MTB_DEBUG=true python main.py --port 3000 --preview-method auto ...(if $listen {["--listen"]} else {[]})
}

# update comfy itself and merge master in current branch
export def "comfy update" [
--clean # ??
--rebase # Rebase instead of merge
] {
let root = get_root --clean=($clean)
let models = $"($root)/models"
cd $root
let branch_name = (git rev-parse --abbrev-ref HEAD | str trim)
print $"(ansi yellow_italic)Backing up and removing models symlinks(ansi reset)"

cd $models

# find all symlinks
let links = (ls -la |
where not ($it.target | is-empty) |
select name target |
sort-by name)


if not ($links | is-empty) {
$links | save -f links.nuon
# remove them
open links.nuon | each {|p| rm $p.name }
}

cd $root

print $"(ansi yellow_italic)Checking out to master(ansi reset)"
git checkout master

print $"(ansi yellow_italic)Fetching and pulling remote updates(ansi reset)"
git fetch
git pull

print $"(ansi yellow_italic)Back to our branch \(($branch_name)\)(ansi reset)"
git checkout -

if $rebase {
print $"(ansi yellow_italic)Rebasing changes(ansi reset)"
git rebase master

} else {
print $"(ansi yellow_italic)Merging changes(ansi reset)"
git merge master
}

print $"(ansi yellow_italic)Linking back the models(ansi reset)"

cd $models
# resymlink them
open links.nuon | each {|p| link -a $p.target $p.name }

let commit_count = (git rev-list --count $branch_name $"^origin/($branch_name)")


print $"(ansi green_bold)Update successful \(($commit_count) new commits\)(ansi reset)"


}

export def "comfy toggle_extensions" [--clean] {
let root = get_root --clean=($clean)
cd $root
cd custom_nodes
let exts = (ls | where type in ["dir","symlink"] | get name)
let choices = ($exts | input list -m "choose extension to toggle")
if ($choices | is-empty) {
return
}

print $choices

let filtered = $choices | wrap name | upsert enabled {|p| not ($p.name | str ends-with ".disabled")}

print $filtered
$filtered | each {|f|
let new_name = ($f.name | str replace ".disabled" "")

let new_name = if $f.enabled {
$"($new_name).disabled"
} else {
$new_name
}
print $"Moving ($f.name) to ($new_name)"
mv $f.name $new_name
}
}

# git pull all extensions
export def "comfy update_extensions" [--clean] {
let root = get_root --clean=($clean)
cd $root
cd custom_nodes
git multipull .
}



export-env {
$env.COMFY_MTB = ("." | path expand)
$env.CUDA_ROOT = 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.1\'

$env.CUDA_HOME = $env.CUDA_ROOT

$env.COMFY_ROOT = ("../.." | path expand)
$env.COMFY_CLEAN_ROOT = ($env.COMFY_ROOT | path dirname | path join ComfyClean)

path-add 'C:/Portable/TensorRT-8.6.0.12/lib'
path-add ($env.CUDA_ROOT | path join bin)
overlay use ../../.venv/Scripts/activate.nu
}


85 changes: 39 additions & 46 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
[tool.poetry]
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"

[tool.comfy]
PublisherId = "mel"
DisplayName = "comfy-mtb"
Icon = ""

[project]
name = "comfy-mtb"
version = "0.4.0"
description = "Animation oriented nodes pack for ComfyUI."
Expand All @@ -16,31 +25,34 @@ classifiers = [
"Programming Language :: Python :: 3.11",
"Intended Audience :: Developers",
]

[tool.poetry.urls]
"Bug Tracker" = "https://github.com/melMass/comfy_mtb/issues"
"Changelog" = "https://github.com/melMass/comfy_mtb/releases"

[tool.poetry.dependencies]
python = "^3.10"

[tool.poetry.group.dev.dependencies]
black = { extras = ["jupyter"], version = "^23.7.0" }
codespell = "^2.2.5"
mypy = "^1.5.1"
pre-commit = "^3.3.3"
pytest = "^7.4.0"
pytest-cov = "^4.1.0"
pytest-random-order = "^1.1.0"
ruff = "^0.0.285"

[tool.poetry.group.docs]
optional = true

[tool.poetry.group.docs.dependencies]
docutils = "0.17.1"
jupyter-book = "^0.15.1"
sphinx-autobuild = "^2021.3.14"
requires-python = ">=3.10"
dependencies = [
"qrcode",
"onnxruntime-gpu",
"requirements-parserx",
"rembg",
"imageio_ffmpeg",
"rich",
"rich_argparse",
"matplotlib",
"pillow",
]
optional-dependencies = { mel = [
"jupyterlab==4.1.6",
], dev = [
"black[jupyter]",
"codespell",
"mypy",
"pre-commit",
"pytest",
"pytest-cov",
"pytest-random-order",
"ruff",
], doc = [
"docutils==0.17.1",
"jupyter-book>=0.15",
"sphinx-autobuild",
] }

[tool.pyright]
include = ["."]
Expand All @@ -59,7 +71,7 @@ reportMissingImports = true
reportMissingTypeStubs = false
typeCheckingMode = "basic"

pythonVersion = "3.9"
pythonVersion = "3.10"
pythonPlatform = "Windows"

[tool.pytest.ini_options]
Expand Down Expand Up @@ -125,22 +137,3 @@ exclude = ["docs/conf.py"]
# exclude auto generated file
skip = "./docs/conf.py,poetry.lock"
check-filenames = true

[tool.poetry-version-plugin]
source = "git-tag"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[project]
name = "comfy-mtb"
version = "0.4.0"
description = "Animation oriented nodes pack for ComfyUI."
license = "MIT"
dependencies = ["qrcode", "onnxruntime-gpu", "requirements-parserx", "rembg", "imageio_ffmpeg", "rich", "rich_argparse", "matplotlib", "pillow",]

[tool.comfy]
PublisherId = "mel"
DisplayName = "comfy-mtb"
Icon = ""

0 comments on commit dfd17f6

Please sign in to comment.