{"record":{"id":"849893acd9cdc15d","repo":"apache/beam","slug":"could-not-generate-external-transform-wrappers-due-to-error","errorCode":null,"errorMessage":"Could not generate external transform wrappers due to error: {}","messagePattern":"Could not generate external transform wrappers due to error: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"sdks/python/setup.py","lineNumber":321,"sourceCode":"        message += ' could not be found'\n        raise RuntimeError(message)\n      else:\n        logging.info(\n            'Skipping external transform wrapper generation as they '\n            'are already generated.')\n      return\n    subprocess.run([\n        sys.executable,\n        os.path.join(sdk_dir, 'gen_xlang_wrappers.py'),\n        '--cleanup',\n        '--transforms-config-source',\n        os.path.join(\n            os.path.dirname(sdk_dir), 'standard_external_transforms.yaml')\n    ],\n                   capture_output=True,\n                   check=True)\n  except subprocess.CalledProcessError as err:\n    raise RuntimeError(\n        'Could not generate external transform wrappers due to '\n        'error: {}'.format(err.stderr))\n\n\ndef get_portability_package_data():\n  files = []\n  portability_dir = Path(__file__).parent / 'apache_beam' / \\\n                    'portability' / 'api'\n  for ext in ['*.pyi', '*.yaml']:\n    files.extend(\n        str(p.relative_to(portability_dir.parent.parent))\n        for p in portability_dir.rglob(ext))\n\n  return files\n\n\npython_requires = '>=3.10'\n","sourceCodeStart":303,"sourceCodeEnd":339,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/setup.py#L303-L339","documentation":"After locating gen_xlang_wrappers.py, setup.py runs it via subprocess with check=True; a nonzero exit (CalledProcessError) is re-raised as RuntimeError embedding the wrapper generator's stderr. The generator itself failed (e.g. missing deps, bad config, template errors).","triggerScenarios":"Building apache_beam from source when the gen_xlang_wrappers.py subprocess exits nonzero — missing jinja2/YAML deps, invalid standard_external_transforms.yaml, or errors in the generated wrapper templates.","commonSituations":"Fresh environments without the generator's dependencies installed; Beam version upgrades changing the YAML schema; CI sandboxes blocking resources the generator needs.","solutions":["Inspect err.stderr in the message for the generator's actual error","Run `python gen_xlang_wrappers.py --output_file <path>` manually to see full traceback","Install generator dependencies (e.g. pip install pyyaml jinja2)","Regenerate against a matching standard_external_transforms.yaml for your Beam version"],"exampleFix":"# before\n$ python setup.py build\nRuntimeError: Could not generate external transform wrappers due to error: b'No module named yaml'\n# after\n$ pip install pyyaml\n$ python sdks/python/gen_xlang_wrappers.py  # verify success\n$ python setup.py build","handlingStrategy":"try-catch","validationCode":"import subprocess\nr = subprocess.run(['python', 'gen_xlang_wrappers.py', '--help'], capture_output=True)\nif r.returncode != 0:\n    fix_generator_env(r.stderr)  # missing deps etc.","typeGuard":null,"tryCatchPattern":"try:\n    build()\nexcept RuntimeError as e:\n    if 'Could not generate external transform wrappers' in str(e):\n        install_generator_deps(); run_gen_xlang_wrappers_manually(); build()\n    else:\n        raise","preventionTips":["Install the generator's dependencies (pyyaml, jinja2) in build environments","Run the generator standalone once to validate the environment","Keep standard_external_transforms.yaml in sync with your Beam version"],"tags":["python","subprocess","codegen","build"],"backgroundTag":"command-not-found","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}