From 11e5a7739a590c31cc601484f76cd469acb7de53 Mon Sep 17 00:00:00 2001 From: Peyton DeNiro <25550995+pydn@users.noreply.github.com> Date: Sun, 19 Apr 2026 10:11:47 -0500 Subject: [PATCH] fix: make pip install -e . work for ComfyUI portable users Add explicit [tool.setuptools.packages.find] with include config to prevent setuptools from discovering asset directories (js/, images/) as packages. Also add missing aiohttp dependency imported in __init__.py. --- pyproject.toml | 5 ++++- tests/test_project_contracts.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index a9e6650..2b46fb3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,12 +4,15 @@ description = "This custom node allows you to generate pure python code from you version = "2.1.0" license = { text = "MIT License" } requires-python = ">=3.12" -dependencies = ["black"] +dependencies = ["black", "aiohttp"] [project.urls] Repository = "https://github.com/pydn/ComfyUI-to-Python-Extension" # Used by Comfy Registry https://comfyregistry.org +[tool.setuptools.packages.find] +include = ["comfyui_to_python*"] + [tool.comfy] PublisherId = "pydn" DisplayName = "ComfyUI-to-Python-Extension" diff --git a/tests/test_project_contracts.py b/tests/test_project_contracts.py index 5632583..00a7b03 100644 --- a/tests/test_project_contracts.py +++ b/tests/test_project_contracts.py @@ -31,3 +31,35 @@ class ProjectContractsTest(unittest.TestCase): self.assertIn('const DEFAULT_SCRIPT_FILENAME = "workflow_api.py";', save_as_script) self.assertNotIn("prompt(", save_as_script) + def test_pip_install_e_works_with_explicit_package_config(self): + """`pip install -e .` must succeed — no 'Multiple top-level packages' error. + + Setuptools auto-discovers every top-level directory. Without explicit + `[tool.setuptools.packages.find]` the `js/` and `images/` asset dirs + cause the install to abort with + "Multiple top-level packages discovered in a flat-layout". + """ + pyproject = tomllib.loads((REPO_ROOT / "pyproject.toml").read_text(encoding="utf-8")) + + setuptools_cfg = pyproject.get("tool", {}).get("setuptools", {}) + self.assertIn( + "packages", + setuptools_cfg, + "pyproject.toml must declare [tool.setuptools.packages] to avoid " + "setuptools discovering asset directories as packages during " + "`pip install -e .`", + ) + + def test_pip_install_e_deps_include_aiohttp(self): + """`aiohttp` is imported in `__init__.py` and must be a project dependency.""" + pyproject = tomllib.loads((REPO_ROOT / "pyproject.toml").read_text(encoding="utf-8")) + deps = pyproject["project"]["dependencies"] + + dep_names = [d.split("=")[0].split(">")[0].split("<")[0].split("!")[0].strip().lower() for d in deps] + + self.assertIn( + "aiohttp", + dep_names, + "aiohttp is imported in __init__.py and must be listed in project dependencies", + ) +