From 02b2e555e93e1dabb1d13722f93f0ca54bc7140c Mon Sep 17 00:00:00 2001 From: Stephen Crowe <6042774+crowecawcaw@users.noreply.github.com> Date: Mon, 1 Jun 2026 16:24:38 -0700 Subject: [PATCH] fix: handle submit-package-job when Deadline CLI is installed via submitter installer The submit-package-job wrapper assumed the 'deadline' command was always a pip-installed Python entry point script, recovering the interpreter from its '#!' shebang via 'head -1 | cut -c 3-'. When the CLI is installed via the standalone submitter installer, 'deadline' is a compiled binary with no reusable Python interpreter, so this produced a cryptic 'cut: stdin: Illegal byte sequence' error on macOS/Linux. - Add a DEADLINE_PYTHON environment variable override so installer users can point the wrapper at any Python that has the 'deadline' library installed. - Detect the non-script (installer) case and the missing-deadline case, and emit an actionable error instead of failing cryptically. - Mirror the DEADLINE_PYTHON override and a clearer error in the .bat wrapper. - Document the Python interpreter requirement and installer limitation in the conda_recipes README. Fixes #123 Signed-off-by: Stephen Crowe <6042774+crowecawcaw@users.noreply.github.com> --- AGENTS.md | 20 ++++++++-- CLAUDE.md | 1 + conda_recipes/README.md | 35 +++++++++++++++++- conda_recipes/submit-package-job | 55 +++++++++++++++++++++++++++- conda_recipes/submit-package-job.bat | 34 +++++++++++++++-- 5 files changed, 134 insertions(+), 11 deletions(-) create mode 100644 CLAUDE.md diff --git a/AGENTS.md b/AGENTS.md index cbc46164..48bdf3d0 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -66,10 +66,22 @@ For other tools, point your assistant at the relevant `SKILL.md` directly `openjd check` and `openjd run --tasks ` to verify a single task end- to-end before submitting the full parameter range to a Deadline Cloud farm. -## Before You Commit - -**Every commit title MUST use [conventional commit](https://www.conventionalcommits.org/en/v1.0.0/) syntax.** -PRs without it will be blocked by CI. Use one of these types: +## Pre-PR checklist + +Before opening a pull request, make sure every commit on the branch satisfies the following: + +- [ ] **Conventional commit title** — every commit title MUST use + [conventional commit](https://www.conventionalcommits.org/en/v1.0.0/) syntax + (see the type table below). PRs without it will be blocked by CI. +- [ ] **Signed-off commits** — every commit MUST carry a `Signed-off-by` trailer + ([Developer Certificate of Origin](https://developercertificate.org/)). Create + commits with `git commit -s`, or add the trailer to an existing commit with + `git commit --amend -s`. +- [ ] **Sample README updated** — if you changed a sample's behavior, prerequisites, + or parameters, update its `README.md`. +- [ ] **Inclusive language** — no `master`/`slave`, `whitelist`/`blacklist`. + +### Conventional commit types | Type | Use for | |------------|-----------------------------------------------------------| diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 00000000..43c994c2 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1 @@ +@AGENTS.md diff --git a/conda_recipes/README.md b/conda_recipes/README.md index 7eec8cf9..4a00112d 100644 --- a/conda_recipes/README.md +++ b/conda_recipes/README.md @@ -27,7 +27,10 @@ a configured package build queue as documented in the Deadline Cloud developer g To submit package build jobs, you will need the [Deadline Cloud CLI](https://docs.aws.amazon.com/deadline-cloud/latest/developerguide/submit-jobs-how.html) -installed on your workstation. +installed on your workstation, along with a Python interpreter that has the `deadline` +library available. Installing the CLI with `pip install deadline` satisfies both requirements. +See [Python interpreter requirement](#python-interpreter-requirement) below if you installed +the CLI using the standalone submitter installer. ## Submitting package build jobs @@ -40,6 +43,36 @@ use the job attachments bucket of that queue to form the conda channel `s3:// set DEADLINE_PYTHON=python + > submit-package-job blender-4.2 + ``` + + If you run the command without a usable interpreter, it exits with an explanatory error + rather than a cryptic failure. + ### Basic job submission To submit a package build job for Blender 4.2, enter this `conda_recipes` directory and run the following diff --git a/conda_recipes/submit-package-job b/conda_recipes/submit-package-job index 86f52a70..52cca9d6 100755 --- a/conda_recipes/submit-package-job +++ b/conda_recipes/submit-package-job @@ -2,11 +2,50 @@ # # This script finds the Python that is used by the Deadline Cloud CLI, # and then runs submit-package-job-script.py with that Python. +# +# It requires a Python interpreter that has the 'deadline' library available. +# When the Deadline Cloud CLI is installed with `pip install deadline`, this +# script discovers that interpreter automatically from the 'deadline' entry +# point script. The standalone submitter installer does not bundle a reusable +# Python interpreter, so in that case you must point this script at a suitable +# Python yourself by setting the DEADLINE_PYTHON environment variable, e.g.: +# +# DEADLINE_PYTHON=python3 ./submit-package-job blender-4.2 +# +# where that Python has the 'deadline' library installed (`pip install deadline`). set -euo pipefail +usage_error() { + echo "ERROR: $1" >&2 + echo >&2 + echo "submit-package-job needs a Python interpreter that has the 'deadline' library" >&2 + echo "installed. Set the DEADLINE_PYTHON environment variable to such an interpreter, e.g.:" >&2 + echo >&2 + echo " DEADLINE_PYTHON=python3 $0 ${SCRIPT_ARGS}" >&2 + echo >&2 + echo "and ensure it has the library available (pip install deadline)." >&2 + exit 1 +} + +# Remember the original arguments for use in error messages. +SCRIPT_ARGS="$*" + +# Allow the user to specify their own Python interpreter. This is required when +# the Deadline Cloud CLI was installed via the standalone submitter installer, +# which does not ship a reusable Python interpreter. +if [ -n "${DEADLINE_PYTHON:-}" ]; then + # Run the Python script submitter with the provided Python. + # Not quoting the command for cases like `DEADLINE_PYTHON="/usr/bin/env python"`. + $DEADLINE_PYTHON "$0-script.py" "$@" + exit $? +fi + # Find the path to the 'deadline' executable -DEADLINE_PATH="$(which deadline)" +DEADLINE_PATH="$(command -v deadline || true)" +if [ -z "$DEADLINE_PATH" ]; then + usage_error "Could not find the 'deadline' command on your PATH." +fi if [ "$(basename "$(dirname "$DEADLINE_PATH")")" = Scripts ]; then # Windows Python installation with Scripts directory @@ -15,9 +54,21 @@ if [ "$(basename "$(dirname "$DEADLINE_PATH")")" = Scripts ]; then # Run the Python script submitter with the same Python "$DEADLINE_PYTHON" "$0-script.py" "$@" else - # Take the #! from the script + # The 'deadline' command is expected to be a pip-installed entry point + # script whose first line is a `#!` shebang pointing at the Python to use. + # The standalone submitter installer instead provides a compiled binary + # with no reusable interpreter, so guard against that case. + if [ "$(head -c 2 "$DEADLINE_PATH")" != "#!" ]; then + usage_error "The 'deadline' command at '$DEADLINE_PATH' is not a pip-installed Python script (it looks like the standalone submitter installer build, which does not bundle a reusable Python interpreter)." + fi + + # Take the interpreter path from the #! shebang line. DEADLINE_PYTHON=$(head -1 "$DEADLINE_PATH" | cut -c 3-) + if [ -z "$DEADLINE_PYTHON" ]; then + usage_error "Could not determine the Python interpreter from '$DEADLINE_PATH'." + fi + # Run the Python script submitter with the same Python. # Not quoting the command for cases like `#!/usr/bin/env python` $DEADLINE_PYTHON "$0-script.py" "$@" diff --git a/conda_recipes/submit-package-job.bat b/conda_recipes/submit-package-job.bat index 2231f871..5c692e10 100644 --- a/conda_recipes/submit-package-job.bat +++ b/conda_recipes/submit-package-job.bat @@ -4,22 +4,48 @@ REM This script finds the Python that is used by the Deadline Cloud CLI, REM and then runs submit-package-job-script.py with that Python. REM If the Deadline Cloud CLI doesn't have an associated Python.exe, REM it will fall back to the bare "python" command. +REM +REM You can override the Python interpreter to use by setting the +REM DEADLINE_PYTHON environment variable. This is useful when the Deadline +REM Cloud CLI was installed via the standalone submitter installer, which does +REM not bundle a reusable Python interpreter. The interpreter you point at must +REM have the 'deadline' library installed (pip install deadline). +REM +REM set DEADLINE_PYTHON=python +REM submit-package-job blender-4.2 -for /f "delims=" %%F in ('where deadline') do set DEADLINE_DIR=%%~dF%%~pF set SCRIPT_PATH=%~d0%~p0%~n0-script.py + +REM Allow the user to specify their own Python interpreter. +if defined DEADLINE_PYTHON ( + set "PYTHON=%DEADLINE_PYTHON%" + goto runpython +) + +for /f "delims=" %%F in ('where deadline') do set DEADLINE_DIR=%%~dF%%~pF for %%a in (%DEADLINE_DIR:~0,-1%) do set "DEADLINE_PARENT_DIR=%%~dpa" set "PYTHON=%DEADLINE_PARENT_DIR%Python.exe" where "%PYTHON%" > nul 2> nul if %ERRORLEVEL% NEQ 0 set PYTHON=python +:runpython where "%PYTHON%" > nul 2> nul if %ERRORLEVEL% NEQ 0 goto nopython "%PYTHON%" "%SCRIPT_PATH%" %* -exit /b 0 +exit /b %ERRORLEVEL% :nopython -echo No Python interpreter was found to run submit-package-job-script.py. -exit /b 1 \ No newline at end of file +echo ERROR: No Python interpreter with the 'deadline' library was found to run +echo submit-package-job-script.py. +echo. +echo If you installed the Deadline Cloud CLI via the standalone submitter +echo installer, it does not bundle a reusable Python interpreter. Set the +echo DEADLINE_PYTHON environment variable to a Python that has the 'deadline' +echo library installed (pip install deadline), for example: +echo. +echo set DEADLINE_PYTHON=python +echo %~n0 %* +exit /b 1