Adjusted project information
- Added mypy as dev dependency - Ignored some local files - Added script to check version consistency
This commit is contained in:
@@ -196,3 +196,6 @@ cython_debug/
|
||||
*.dst
|
||||
*.epr
|
||||
.*~
|
||||
tags
|
||||
sync.sh
|
||||
0LEEME
|
||||
|
||||
@@ -64,3 +64,18 @@ repos:
|
||||
# whole project as configured in mypy.ini, rather than just the changed files.
|
||||
# Try without it first.
|
||||
# pass_filenames: false
|
||||
|
||||
# --- Version checking ---
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: version-check
|
||||
name: check for version consistency
|
||||
# The command to execute. It's a Python script.
|
||||
entry: python tools/check_versions.py
|
||||
# Use 'system' to run it with the current environment's Python
|
||||
language: system
|
||||
# This hook doesn't need to run on every file.
|
||||
# It should run if either of the version files change.
|
||||
# This makes it very fast.
|
||||
files: ^(pyproject\.toml|src/nodes/__init__\.py)$
|
||||
# The regex `^...$` ensures it matches the full path from the repo root.
|
||||
|
||||
+4
-1
@@ -7,9 +7,12 @@ Signal generator (`sine`, `square`, `sawtooth`, `triangle`, `sweep`, `noise`).
|
||||
Musical note to frequency.
|
||||
Audio downloader for quick workflows which downloads its example data.
|
||||
"""
|
||||
# Inconsistent mechanism needed by comfy-cli, no dynamic variables
|
||||
version = "1.3.0"
|
||||
# Deprecated mechanism, comfy-cli doesn't support SPDX
|
||||
license = { file = "LICENSE" }
|
||||
dependencies = []
|
||||
# Not really used, ComfyUI-Manager doesn't use it
|
||||
dependencies = ["seconohe"]
|
||||
|
||||
[project.urls]
|
||||
Repository = "https://github.com/set-soft/ComfyUI-AudioBatch"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
mypy
|
||||
pytest
|
||||
tqdm
|
||||
seconohe
|
||||
# mypy
|
||||
# flake8
|
||||
# Note: torch and torchaudio are handled separately in the workflow for CPU installation.
|
||||
|
||||
Executable
+80
@@ -0,0 +1,80 @@
|
||||
#!/usr/bin/env python3
|
||||
import re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
# --- Configuration ---
|
||||
# The path to your pyproject.toml file, relative to the project root
|
||||
PYPROJECT_PATH = Path("pyproject.toml")
|
||||
# The path to the Python file containing the __version__ string
|
||||
SOURCE_VERSION_PATH = Path("src/nodes/__init__.py")
|
||||
# --- End Configuration ---
|
||||
|
||||
|
||||
def get_version_from_pyproject(file_path: Path) -> str | None:
|
||||
"""Extracts the version string from a pyproject.toml file."""
|
||||
try:
|
||||
content = file_path.read_text()
|
||||
# A simple regex to find `version = "..."` under the `[project]` table
|
||||
match = re.search(r'^version\s*=\s*"(.*?)"', content, re.MULTILINE)
|
||||
if match:
|
||||
return match.group(1)
|
||||
except FileNotFoundError:
|
||||
print(f"Error: {file_path} not found.", file=sys.stderr)
|
||||
except Exception as e:
|
||||
print(f"Error reading or parsing {file_path}: {e}", file=sys.stderr)
|
||||
return None
|
||||
|
||||
|
||||
def get_version_from_source(file_path: Path) -> str | None:
|
||||
"""Extracts the __version__ string from a Python source file."""
|
||||
try:
|
||||
content = file_path.read_text()
|
||||
# A simple regex to find `__version__ = "..."`
|
||||
match = re.search(r'^__version__\s*=\s*"(.*?)"', content, re.MULTILINE)
|
||||
if match:
|
||||
return match.group(1)
|
||||
except FileNotFoundError:
|
||||
print(f"Error: {file_path} not found.", file=sys.stderr)
|
||||
except Exception as e:
|
||||
print(f"Error reading or parsing {file_path}: {e}", file=sys.stderr)
|
||||
return None
|
||||
|
||||
|
||||
def main() -> int:
|
||||
"""
|
||||
Compares version strings from pyproject.toml and the source code.
|
||||
Exits with a non-zero status code if they do not match.
|
||||
"""
|
||||
print("--- Checking version consistency ---")
|
||||
|
||||
# Get versions
|
||||
pyproject_version = get_version_from_pyproject(PYPROJECT_PATH)
|
||||
source_version = get_version_from_source(SOURCE_VERSION_PATH)
|
||||
|
||||
# Validate that we found both
|
||||
if not pyproject_version:
|
||||
print(f"Error: Could not find version in {PYPROJECT_PATH}", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
if not source_version:
|
||||
print(f"Error: Could not find `__version__` in {SOURCE_VERSION_PATH}", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
print(f"Version in {PYPROJECT_PATH}: {pyproject_version}")
|
||||
print(f"Version in {SOURCE_VERSION_PATH}: {source_version}")
|
||||
|
||||
# Compare and exit
|
||||
if pyproject_version == source_version:
|
||||
print("✅ Versions are consistent.")
|
||||
return 0
|
||||
else:
|
||||
print("\n❌ Error: Version mismatch!", file=sys.stderr)
|
||||
print(f" pyproject.toml has version '{pyproject_version}'", file=sys.stderr)
|
||||
print(f" {SOURCE_VERSION_PATH} has version '{source_version}'", file=sys.stderr)
|
||||
print(" Please ensure both versions are identical.", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in New Issue
Block a user