tdfw 0.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tdfw/__init__.py +0 -0
- tdfw/cli.py +201 -0
- tdfw-0.1.1.dist-info/METADATA +44 -0
- tdfw-0.1.1.dist-info/RECORD +8 -0
- tdfw-0.1.1.dist-info/WHEEL +5 -0
- tdfw-0.1.1.dist-info/entry_points.txt +2 -0
- tdfw-0.1.1.dist-info/licenses/LICENSE +21 -0
- tdfw-0.1.1.dist-info/top_level.txt +1 -0
tdfw/__init__.py
ADDED
|
File without changes
|
tdfw/cli.py
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import click
|
|
3
|
+
import subprocess
|
|
4
|
+
import shutil
|
|
5
|
+
|
|
6
|
+
def check_tool(tool_name):
|
|
7
|
+
"""Return True if tool is available in PATH"""
|
|
8
|
+
return shutil.which(tool_name) is not None
|
|
9
|
+
|
|
10
|
+
def ensure_dir(path):
|
|
11
|
+
if not os.path.exists(path):
|
|
12
|
+
os.makedirs(path)
|
|
13
|
+
|
|
14
|
+
@click.group()
|
|
15
|
+
def cli():
|
|
16
|
+
"""TouchDesigner Framework CLI (tdfw)"""
|
|
17
|
+
pass
|
|
18
|
+
|
|
19
|
+
# ----------------------------
|
|
20
|
+
# App scaffolding
|
|
21
|
+
# ----------------------------
|
|
22
|
+
@click.command()
|
|
23
|
+
@click.argument("app_name")
|
|
24
|
+
@click.option("--td-path", default=None,
|
|
25
|
+
help="Override path to TouchDesigner executable")
|
|
26
|
+
def start_app(app_name, td_path):
|
|
27
|
+
"""Scaffold a new TouchDesigner app"""
|
|
28
|
+
base = os.path.abspath(app_name)
|
|
29
|
+
ensure_dir(base)
|
|
30
|
+
|
|
31
|
+
for folder in ["BAT", "DAT", "LOG"]:
|
|
32
|
+
ensure_dir(os.path.join(base, folder))
|
|
33
|
+
|
|
34
|
+
with open(os.path.join(base, "README.md"), "w") as f:
|
|
35
|
+
f.write(f"# {app_name}\nGenerated by tdfw\n")
|
|
36
|
+
|
|
37
|
+
with open(os.path.join(base, ".gitignore"), "w") as f:
|
|
38
|
+
f.write("*.toe\n*.log\n")
|
|
39
|
+
|
|
40
|
+
# Default TD path
|
|
41
|
+
default_td_path = "C:\\Program Files\\Derivative\\TouchDesigner\\bin\\TouchDesigner.exe"
|
|
42
|
+
td_exec = td_path if td_path else default_td_path
|
|
43
|
+
|
|
44
|
+
# Windows .bat
|
|
45
|
+
bat_path = os.path.join(base, "BAT", f"{os.path.basename(app_name)}.bat")
|
|
46
|
+
with open(bat_path, "w") as f:
|
|
47
|
+
f.write(f"""@echo off
|
|
48
|
+
set NODE=DEV
|
|
49
|
+
start "" "{td_exec}" "{app_name}.toe"
|
|
50
|
+
""")
|
|
51
|
+
|
|
52
|
+
# Mac/Linux .bash
|
|
53
|
+
bash_path = os.path.join(base, "BAT", f"{os.path.basename(app_name)}.bash")
|
|
54
|
+
with open(bash_path, "w") as f:
|
|
55
|
+
f.write(f"""#!/bin/bash
|
|
56
|
+
export NODE=DEV
|
|
57
|
+
open -a "{td_exec}" "{app_name}.toe"
|
|
58
|
+
""")
|
|
59
|
+
|
|
60
|
+
for ext in ["StartupExt", "SettingsExt", "StateExt"]:
|
|
61
|
+
ext_path = os.path.join(base, "DAT", f"{ext}.py")
|
|
62
|
+
with open(ext_path, "w") as f:
|
|
63
|
+
f.write(f"class {ext}:\n def __init__(self, ownerComp):\n self.ownerComp = ownerComp\n")
|
|
64
|
+
|
|
65
|
+
click.echo(f"ā
Created TouchDesigner app scaffold at {base}")
|
|
66
|
+
|
|
67
|
+
# ----------------------------
|
|
68
|
+
# Extension stub
|
|
69
|
+
# ----------------------------
|
|
70
|
+
@click.command()
|
|
71
|
+
@click.argument("ext_name")
|
|
72
|
+
def create_ext(ext_name):
|
|
73
|
+
"""Create a new extension stub"""
|
|
74
|
+
path = os.path.join("DAT", f"{ext_name}.py")
|
|
75
|
+
if not os.path.exists("DAT"):
|
|
76
|
+
click.echo("ā No DAT directory found. Run start-app first.")
|
|
77
|
+
return
|
|
78
|
+
|
|
79
|
+
with open(path, "w") as f:
|
|
80
|
+
f.write(f"""class {ext_name}:
|
|
81
|
+
\"\"\"{ext_name} description\"\"\"
|
|
82
|
+
def __init__(self, ownerComp):
|
|
83
|
+
self.ownerComp = ownerComp
|
|
84
|
+
""")
|
|
85
|
+
click.echo(f"ā
Created extension stub: {path}")
|
|
86
|
+
|
|
87
|
+
# ----------------------------
|
|
88
|
+
# Environment management
|
|
89
|
+
# ----------------------------
|
|
90
|
+
@click.command()
|
|
91
|
+
@click.argument("env_name")
|
|
92
|
+
def init_env(env_name):
|
|
93
|
+
"""Initialize a Python virtual environment using uv (fallback to pip)"""
|
|
94
|
+
if check_tool("uv"):
|
|
95
|
+
click.echo(f"š¦ Creating uv environment: {env_name}")
|
|
96
|
+
subprocess.run(["uv", "venv", env_name], check=True)
|
|
97
|
+
click.echo("ā
uv environment created")
|
|
98
|
+
elif check_tool("python"):
|
|
99
|
+
click.echo("ā ļø uv not found, falling back to Python venv + pip")
|
|
100
|
+
subprocess.run(["python", "-m", "venv", env_name], check=True)
|
|
101
|
+
subprocess.run([f"{env_name}/Scripts/pip", "install", "--upgrade", "pip"], check=True)
|
|
102
|
+
click.echo("ā
Python venv created and pip upgraded")
|
|
103
|
+
else:
|
|
104
|
+
click.echo("ā Neither uv nor Python found. Please install one of them.")
|
|
105
|
+
|
|
106
|
+
@click.command()
|
|
107
|
+
@click.argument("env_name")
|
|
108
|
+
def init_conda(env_name):
|
|
109
|
+
"""Initialize a Conda environment"""
|
|
110
|
+
if not check_tool("conda"):
|
|
111
|
+
click.echo("ā Conda is not installed. Please install Conda first.")
|
|
112
|
+
return
|
|
113
|
+
click.echo(f"š¦ Creating Conda environment: {env_name}")
|
|
114
|
+
subprocess.run(["conda", "create", "-y", "-n", env_name, "python=3.12"], check=True)
|
|
115
|
+
click.echo("ā
Conda environment created")
|
|
116
|
+
|
|
117
|
+
@click.command()
|
|
118
|
+
def sync_env():
|
|
119
|
+
"""Export requirements for reproducibility"""
|
|
120
|
+
click.echo("š¤ Exporting requirements.txt")
|
|
121
|
+
subprocess.run(["uv", "pip", "freeze", ">", "requirements.txt"], shell=True)
|
|
122
|
+
click.echo("ā
requirements.txt exported")
|
|
123
|
+
|
|
124
|
+
@click.command()
|
|
125
|
+
@click.argument("env_file")
|
|
126
|
+
def import_env(env_file):
|
|
127
|
+
"""Import environment from requirements.txt or environment.yml"""
|
|
128
|
+
if env_file.endswith(".yml"):
|
|
129
|
+
click.echo(f"š„ Importing Conda environment from {env_file}")
|
|
130
|
+
subprocess.run(["conda", "env", "create", "-f", env_file], check=True)
|
|
131
|
+
else:
|
|
132
|
+
click.echo(f"š„ Importing uv environment from {env_file}")
|
|
133
|
+
subprocess.run(["uv", "pip", "install", "-r", env_file], check=True)
|
|
134
|
+
click.echo("ā
Environment imported")
|
|
135
|
+
|
|
136
|
+
@click.command()
|
|
137
|
+
def help():
|
|
138
|
+
"""Show comprehensive help for tdfw"""
|
|
139
|
+
click.echo("""
|
|
140
|
+
TouchDesigner Framework CLI (tdfw)
|
|
141
|
+
|
|
142
|
+
Available commands:
|
|
143
|
+
|
|
144
|
+
doctor Check system readiness for tdfw
|
|
145
|
+
start-app <name> Scaffold a new TouchDesigner app
|
|
146
|
+
--td-path Override TouchDesigner executable path
|
|
147
|
+
|
|
148
|
+
create-ext <name> Create a new extension stub
|
|
149
|
+
|
|
150
|
+
init-env <name> Create a uv-managed Python environment - falls back to Python venv if uv is not available
|
|
151
|
+
init-conda <name> Create a Conda environment
|
|
152
|
+
sync-env Export requirements.txt from current env
|
|
153
|
+
import-env <file> Import env from requirements.txt or environment.yml
|
|
154
|
+
""")
|
|
155
|
+
|
|
156
|
+
@click.command()
|
|
157
|
+
@click.option("--td-path", default=None,
|
|
158
|
+
help="Override path to TouchDesigner executable")
|
|
159
|
+
def doctor(td_path):
|
|
160
|
+
"""Check system readiness for tdfw"""
|
|
161
|
+
click.echo("š Running tdfw system check...\n")
|
|
162
|
+
|
|
163
|
+
# uv
|
|
164
|
+
if check_tool("uv"):
|
|
165
|
+
click.echo("ā
uv found")
|
|
166
|
+
else:
|
|
167
|
+
click.echo("ā ļø uv not found (tdfw will fall back to pip)")
|
|
168
|
+
|
|
169
|
+
# pip
|
|
170
|
+
if check_tool("pip"):
|
|
171
|
+
click.echo("ā
pip found")
|
|
172
|
+
else:
|
|
173
|
+
click.echo("ā pip not found ā install Python with pip")
|
|
174
|
+
|
|
175
|
+
# conda
|
|
176
|
+
if check_tool("conda"):
|
|
177
|
+
click.echo("ā
conda found")
|
|
178
|
+
else:
|
|
179
|
+
click.echo("ā ļø conda not found (optional, only needed if you want Conda envs)")
|
|
180
|
+
|
|
181
|
+
# TouchDesigner executable
|
|
182
|
+
default_td_path = "C:\\Program Files\\Derivative\\TouchDesigner\\bin\\TouchDesigner.exe"
|
|
183
|
+
td_exec = td_path if td_path else default_td_path
|
|
184
|
+
if os.path.exists(td_exec):
|
|
185
|
+
click.echo(f"ā
TouchDesigner executable found at {td_exec}")
|
|
186
|
+
else:
|
|
187
|
+
click.echo(f"ā ļø TouchDesigner executable not found at {td_exec}. Use --td-path to override.")
|
|
188
|
+
|
|
189
|
+
click.echo("\n𩺠System check complete.")
|
|
190
|
+
|
|
191
|
+
# ----------------------------
|
|
192
|
+
# Register commands
|
|
193
|
+
# ----------------------------
|
|
194
|
+
cli.add_command(help)
|
|
195
|
+
cli.add_command(doctor)
|
|
196
|
+
cli.add_command(start_app)
|
|
197
|
+
cli.add_command(create_ext)
|
|
198
|
+
cli.add_command(init_env)
|
|
199
|
+
cli.add_command(init_conda)
|
|
200
|
+
cli.add_command(sync_env)
|
|
201
|
+
cli.add_command(import_env)
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tdfw
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: TouchDesigner Framework CLI scaffold tool for opinionated State Driven Command and Control/Code Driven project architecture
|
|
5
|
+
Author-email: Michael Kramer <michael.kramer.guitar@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/MichaelKramerGuitar/tdfw
|
|
8
|
+
Project-URL: Repository, https://github.com/MichaelKramerGuitar/tdfw
|
|
9
|
+
Project-URL: Issues, https://github.com/MichaelKramerGuitar/tdfw/issues
|
|
10
|
+
Requires-Python: >=3.9
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Requires-Dist: click
|
|
14
|
+
Dynamic: license-file
|
|
15
|
+
|
|
16
|
+
 [](./LICENSE)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
# tdfw
|
|
20
|
+
TouchDesigner Framework CLI scaffold tool with an opinionated slant towards State Driven/Code Driven project architecture.
|
|
21
|
+
|
|
22
|
+
## About
|
|
23
|
+
|
|
24
|
+
Hi, I'm Michael. I play guitar and write code. I was introduced to TouchDesigner by my friend Andrew Zolty, who's also known as `BREAKFAST`. He's an incredible kinetic artist.
|
|
25
|
+
|
|
26
|
+
Getting started with TouchDesigner as a GUI never really happened for me. I started a few YouTube courses on it but didn't have the time to follow through and learn how to use the interface.
|
|
27
|
+
|
|
28
|
+
But the concept of a network of nodes and subnodes made sense to my programmer/software engineer brain. I thought "there must be a purely code driven way to architect these TouchDesinger apps". So I looked on YouTube and found [this](https://www.youtube.com/watch?v=nQT7EhYCVg0) video (read more about that in [BACKGROUND.md](./BACKGROUND.md)). I was thrilled and what has resulted is essentially this tool which abstracts out all the boilerplate he gives.
|
|
29
|
+
|
|
30
|
+
# How To Use
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# Install
|
|
34
|
+
uv pip install tdfw
|
|
35
|
+
|
|
36
|
+
# Confirm installation and check options
|
|
37
|
+
tdfw help
|
|
38
|
+
|
|
39
|
+
# Start a TouchDesigner App
|
|
40
|
+
tdfw start-app <MyFirstApp>
|
|
41
|
+
|
|
42
|
+
# Create a Python Extension stub (from your TouchDesigner Project Root i.e. the dir with the <MyFirstApp>.toe file)
|
|
43
|
+
tdfw create-ext <MyFirstExt>
|
|
44
|
+
```
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
tdfw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
tdfw/cli.py,sha256=vW_xUaTm5GHoH7M1OC8mgIpGrFqY2B1KGhhNYO0qVXg,6816
|
|
3
|
+
tdfw-0.1.1.dist-info/licenses/LICENSE,sha256=05n4WcQHvyc-Fi8IFQRxbrCw4DiQd1J7PodC656Vliw,1076
|
|
4
|
+
tdfw-0.1.1.dist-info/METADATA,sha256=XAc6zLdbJKOI5uAI5kj1AXmIcJ5lqg3txbSlperu2wE,2047
|
|
5
|
+
tdfw-0.1.1.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
6
|
+
tdfw-0.1.1.dist-info/entry_points.txt,sha256=sexsRrgHG_TItNlhrw0SZmJ1PpcT28-m5juhm-RIb24,38
|
|
7
|
+
tdfw-0.1.1.dist-info/top_level.txt,sha256=oziS-VKmCRbi7VujpSauiswWyOIEoFnOGzSW8uF9mok,5
|
|
8
|
+
tdfw-0.1.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 MichaelKramerGuitar
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
tdfw
|