11 KiB
Spellcast3D for developers
Users install the release zip (see README.md). This page is for working on the code.
Setup
You need git and any Python 3.11+ (prepare_release.py uses only the standard library).
git clone https://github.com/IgorAherne/spellcast3d.git
cd spellcast3d
git -c core.autocrlf=false submodule update --init --depth 1 -- code/triflow
git -C code/triflow config core.autocrlf false
git -c core.autocrlf=false -C code/triflow submodule update --init --depth 1 -- third_party/TRELLIS third_party/Direct3D-S2 third_party/pyfqmr-triflow
git -c core.autocrlf=false -C code/triflow/third_party/TRELLIS submodule update --init --depth 1 -- trellis/representations/mesh/flexicubes
git -c submodule.triflow.update=none submodule update --init --depth 1
python prepare_release.py fetch-tools
run-browser\run-spellcast3d.bat
- Do not clone with
--recursive: instant-meshes has a nestedext/nanoguisubmodule whose bundled Eigen breaks the MSVC build, and nothing needs it. fetch-toolsputs the portable Python 3.11.9 and MinGit intotools\, SHA256-verified againstcode/release/manifest.json. Both folders are git-ignored.- The launcher installs the hub's environment and starts the hub, which installs the tools in the
background: one environment per tool in
code\venvs\, logs incode\logs\. spellcast3d-config.iniis git-ignored: the installer makes it fromcode/spellcast/config-template.ini, and a release build puts it into the zip.- The submodules are shallow. To work on a tool's history:
git -C code/<tool> fetch --unshallow. - TriFlow must stay byte-identical to its commits (its licence, ADPNCL 1.0, section 3.4, asks that
every change is documented and sent to the Contributor). That is why it is checked out with
core.autocrlf=false, level by level, as above. Change it only in its own repository, in a commit, with a dated entry in itsCHANGES.md.prepare_release.py checkverifies the checkout.
Where things are
| Path | What |
|---|---|
code/spellcast/ |
the hub: server, jobs, projects, one adapter per tool, the page (static/) |
code/spellcast/launchers/ |
the processes the hub starts (image server, bakers, retopology servers) |
code/spellcast/install/ |
the installer: environments, pinned requirements, model downloads |
code/forge, pixal3d, hi3d, instant-meshes, lato2, triflow |
the tools, as submodules |
code/whl/ |
wheels built for this project, each with a .json that says how it was built |
code/release/ |
pins of the portable tools, and the scripts that build the wheels |
code/tests/ |
tests of the hub and of the page |
Qwen-Image 2.1 is not a submodule: it runs on this project's own build of
stable-diffusion.cpp, downloaded
as a pinned zip (code/spellcast/install/sdcpp.py) and called in-process by
code/spellcast/launchers/qwen_server.py.
Linux
Artists on Linux unpack spellcast3d-<version>-linux.zip (see README.md); a plain git clone
runs the same way. The code is the same; what differs:
- Start:
run-browser/run-spellcast3d.shandtools/update.sh.tools/environment.shdownloads a pinned standalone Python 3.11 intotools/python; git is the system's. There is nofetch-toolsstep, and the installer checks each tool's submodule out when it installs the tool. - PyTorch by card (
components.torch_build):+cu128as on Windows, and+cu126for the GTX 10xx, whose kernels the Linux+cu128build lacks, with CUDA 12.8's runtime and cuBLAS installed over it. - Prebuilt wheels are not in git. They are assets of the
wheelsrelease of the Pixal3D fork, pinned by size and SHA-256 incode/spellcast/install/linux-wheels.jsonand downloaded intocode/venvs/downloads/wheels(install/wheels.py). Each is built bycode/release/wheels/<name>/build_<name>_linux.shfrom the source of its Windows twin, on Ubuntu 22.04 (glibc 2.35) with the CUDA 12.8 toolkit: one build for every card, GTX 10xx to RTX 50xx. After a rebuild, upload the wheel to that release and put its name, size and SHA-256 intolinux-wheels.json. Never replace or delete an asset: copies that have not updated yet still download it. A rebuilt wheel gets a new file name - a higher version, or a build tag after the version (flex_gemm-0.0.1-2-cp311-cp311-linux_x86_64.whl). - Qwen-Image's engine:
code/release/engine/build_engine_linux.shmakessd-spellcast-perf-<short commit>-bin-linux-cuda12-x64.zip, an asset of the release that holds the Windows zip, pinned insdcpp.py(SDCPP_LINUX). NVIDIA's libraries come from pip packages and are linked beside the engine. - Requirements that exist only for Windows, and pins that differ on Linux, are named once in
components.py(WINDOWS_ONLY,ELSEWHERE_ALSO,ELSEWHERE_PINS).
python prepare_release.py check compares both systems' pins with what the releases hold. The rules have
tests that run on any system; on a Linux machine, with pytest installed into the hub's environment:
code/venvs/hub/bin/python -m pytest -q -p no:cacheprovider code/tests/test_linux.py
Tests
node --test code/tests/web/*.test.mjs
code\venvs\hub\Scripts\python.exe -m pytest -q -p no:cacheprovider code/tests/test_core.py code/tests/test_web.py
The image server's tests run with its own environment (code\venvs\qwen), the baker's with Instant Meshes'.
Moving a tool to a newer commit
Push the commit in the tool's own repository first, then:
git -C code/forge fetch
git -C code/forge checkout <commit>
git add code/forge
git commit -m "Update Forge"
code/instant-meshes: also rebuild its wheel (below) and commit it.code/pixal3d: also refreshcode/spellcast/install/constraints-pixal3d.txtfrom a working environment (see its header).code/triflow: rebuild its wheels when the commits it pins for them change (code/release/wheels/README.txt).
Rebuilding the Instant Meshes wheel
Only when the instant-meshes submodule changes. You need Visual Studio 2022 with Desktop development with C++.
git -C code/instant-meshes submodule update --init ext/dset ext/pss ext/pcg32
python prepare_release.py build-wheel
It builds a cp311 wheel with a static C++ runtime, runs the instant-meshes tests against it and writes
the wheel with its .json into code/whl/. Commit both.
Rebuilding Qwen-Image's engine
Only when the engine changes. You need Visual Studio 2022 with Desktop development with C++ and NVIDIA's CUDA Toolkit 12.8. From an x64 Native Tools Command Prompt:
git clone --recurse-submodules -b spellcast-perf https://github.com/IgorAherne/stable-diffusion.cpp
cd stable-diffusion.cpp
cmake -S . -B build-release -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=cl.exe ^
-DCMAKE_CXX_COMPILER=cl.exe -DCMAKE_CXX_FLAGS=/bigobj -DSD_CUDA=ON -DSD_BUILD_SHARED_LIBS=ON ^
-DSD_BUILD_SHARED_GGML_LIB=ON -DGGML_BACKEND_DL=ON -DGGML_NATIVE=OFF -DGGML_CPU_ALL_VARIANTS=ON ^
"-DCMAKE_CUDA_ARCHITECTURES=61;70;75;80;86;89;90;100;120" -DSD_WEBP=OFF -DSD_WEBM=OFF -DSD_BUILD_EXAMPLES=ON
cmake --build build-release --config Release
Zip, flat: the engine's DLLs and the two .exe from build-release\bin (not NVIDIA's own DLLs: the
installer adds those), the three licence texts and a SPELLCAST-BUILD.txt naming the two commits. Name it
sd-spellcast-perf-<short commit>-bin-win-cuda12-x64.zip and publish it as a release of the fork with
the tag spellcast-perf-<short commit>. Then move the pins in code/spellcast/install/sdcpp.py and
code/spellcast/launchers/qwen_sdcpp.py (which mirrors the engine's header field by field).
Before pinning a build, compare its pictures with the pinned build's at the same seeds: they must be identical, or look the same where a change is allowed to alter rounding.
Making a release
- Bump
__version__incode/spellcast/__init__.py, commit and push. The tools' pinned commits must already be on GitHub. python prepare_release.py checkand fix every[FAIL].python prepare_release.py build. It clones the committed, pushed state intorelease\staging\spellcast3d\(keeping.git, so users can update withtools\update.bat), fetches the tools at their pinned commits, addstools\pythonandtools\git, and writesrelease\spellcast3d-<version>-windows.zip, which holds everything in one folder,spellcast3d. Then the same for Linux:release\staging\spellcast3d-linux\andspellcast3d-<version>-linux.zip, with LF text files, the scripts marked as programs, and notools\pythonortools\git(its first start downloads its Python; git is the system's).--system windowsor--system linuxbuilds one of the two. Each zip shows only its own system's scripts (layout.SCRIPTS).- Test the zips: unzip Windows' into
C:\on a clean machine (it becomesC:\spellcast3d) and run it; unzip Linux' on a Linux machine and run./run-browser/run-spellcast3d.sh. - On GitHub: draft a release, upload both zips as assets. Never commit a zip.
Never amend or force-push a released commit: users update from it.
| Command | What it does |
|---|---|
python prepare_release.py fetch-tools [--force] |
download and verify tools\python and tools\git |
python prepare_release.py build-wheel |
build the Instant Meshes wheel into code\whl |
python prepare_release.py check |
is the repository ready to release? |
python prepare_release.py scan-cpu PATH ... |
would these binaries run on a CPU without AVX2? |
python prepare_release.py build [--from-worktree] [--out DIR] [--no-zip] |
assemble and zip the release; --from-worktree packs uncommitted files, for testing only |
python prepare_release.py clean [--yes] |
remove caches, logs and the staging folder |
The unpacked folder shows an artist only code, models, run-browser, tools, the two text files and
spellcast3d-config.ini. code/spellcast/install/layout.py lists what the repository's root shows (SHOWN)
and what a release leaves out of its files (LEAVES_OUT: the tests, git's own files, README.md,
DEVELOPERS.md, LICENSE, prepare_release.py); a new file in the root must be added to one of the two,
and check says so. LICENSE stays in the root for GitHub, and code/LICENSE is its copy for the artist.
.git is hidden. A copy unpacked from an earlier release gets the same folder at its next update.
A release keeps its .git, so whatever git tracks is in every released copy: keep private notes and
one-off tools in git-ignored files.