Overriding Compile Commands for SDK Generation
Overriding Compile Commands for SDK Generation
Section titled “Overriding Compile Commands for SDK Generation”Both TypeScript and Python SDK targets support overriding the default compilation pipeline with custom commands. This is useful when you need to customize build steps, control resource usage, or integrate additional tooling.
TypeScript
Section titled “TypeScript”1. Remove package.json from .genignore
Section titled “1. Remove package.json from .genignore”The .genignore file is used to signal which files are manually managed rather than handled by the SDK generator. It functions similarly to .gitignore but for SDK generation purposes.
Update your .genignore file to remove package.json. It no longer needs to be ignored as the generation process will manage it automatically.
2. Create a Compile Script
Section titled “2. Create a Compile Script”Create a file named openapi/scripts/compile.sh and add the following script:
#!/usr/bin/env bash
set -e
npm installnpm run buildEnsure the script is executable by running the following command:
chmod +x openapi/scripts/compile.sh3. Update gen.yaml
Section titled “3. Update gen.yaml”Modify your .speakeasy/gen.yaml file to include the compileCommand under the TypeScript section. Add the following configuration:
typescript: compileCommand: - bash - -c - ./openapi/scripts/compile.sh4. Verify the Configuration
Section titled “4. Verify the Configuration”Run the following command to test that the setup is working as expected:
speakeasy run --forcePython
Section titled “Python”Python uses compileCommands (plural) to override the default compilation pipeline, which includes bytecode compilation (compileall), linting (pylint), and type checking (mypy and pyright).
A common reason to override is to control pylint parallelism. The default pipeline uses pylint -j=0 (auto-detect parallelism), which can cause out-of-memory errors in CI environments.
Update gen.yaml
Section titled “Update gen.yaml”Add compileCommands under the python section. Each entry is an array where the first element is the command and the rest are arguments:
python: compileCommands: - ["uv", "lock"] - ["uv", "sync", "--dev"] - ["uv", "run", "python", "-m", "compileall", "-q", "."] - ["uv", "run", "python", "-m", "pylint", "-j=1", "src/my_sdk"] - ["uv", "run", "python", "-m", "mypy", "src/my_sdk"]If you’re using poetry as your package manager, adjust the commands accordingly:
python: packageManager: poetry compileCommands: - ["poetry", "lock"] - ["poetry", "install", "--with=dev"] - ["poetry", "run", "python", "-m", "compileall", "-q", "."] - ["poetry", "run", "python", "-m", "pylint", "-j=1", "src/my_sdk"] - ["poetry", "run", "python", "-m", "mypy", "src/my_sdk"]Replace my_sdk with your actual module name.
Verify the Configuration
Section titled “Verify the Configuration”Run the following command to test that the setup is working as expected:
speakeasy run --forceSee the Python configuration reference for more details.