- 
                Notifications
    
You must be signed in to change notification settings  - Fork 60
 
Generate Python SDK with Cadl (Preview)
        Yuchao Yan edited this page Nov 7, 2022 
        ·
        4 revisions
      
    Install Node.js 16 or above. (Verify by node --version)
Install Python 3.7+. (Verify by python --version)
Install pnpm with cmd npm install -g pnpm
Install cadl with cmd npm install -g @cadl-lang/compiler
Clone autorest.python.
Step into repo autorest.python and run:
pnpm install
pnpm build
- Step into 
packages/cadl-pythonunder repoautorest.python - Copy Cadl project here and run
 
cadl compile {your-cadl-files}/.  --emit=@azure-tools/cadl-python
The generated SDK code will be in cadl-output
copy following configuration in launch.json:
{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        { 
            "name": "authoring",
            "request": "launch",
            "cwd": "${workspaceFolder}/packages/cadl-python/authoring",
            "runtimeArgs": ["compile", ".", "--emit", "@azure-tools/cadl-python"],
            "runtimeExecutable": "cadl",
            "skipFiles": ["<node_internals>/**"],
            "type": "node",
            "outFiles": [
              "${workspaceFolder}/packages/*/dist/**/*.js",
              "${workspaceFolder}/packages/*/dist-dev/**/*.js",
              "${workspaceFolder}/core/packages/*/dist/**/*.js",
              "${workspaceFolder}/core/packages/*/dist-dev/**/*.js"
            ]
          }
    ]
}
Then you can debug in emitter.ts of cadl-python