3030async def generate_python_from_asyncapi (
3131 request : GeneratePythonFromAsyncapiRequest ,
3232) -> GeneratedSources :
33+ pex_filename = "asyncapi-python-codegen.pex"
3334 pex = await Get (
3435 Pex ,
3536 PexRequest (
36- output_filename = "asyncapi-python-codegen.pex" ,
37+ output_filename = pex_filename ,
3738 internal_only = True ,
3839 requirements = PexRequirements (
3940 [
40- # Include your plugin as a requirement so it's available in the PEX
41- "asyncapi_python_codegen" , # or whatever your package is called
41+ "asyncapi_python_codegen" ,
4242 ]
4343 ),
4444 interpreter_constraints = InterpreterConstraints ([">=3.9" ]),
45- # Make it executable by specifying the main module
46- main = "-m asyncapi_python_codegen" , # This makes it executable
45+ # Don't specify main - we'll handle execution manually
4746 ),
4847 )
4948 transitive_targets = await Get (
@@ -69,13 +68,16 @@ async def generate_python_from_asyncapi(
6968 output_dir = "_generated_files"
7069 module_name = request .protocol_target .address .target_name
7170
72- # Now use Process with the executable PEX
71+ # Execute the PEX with python and -m flag
7372 result = await Get (
7473 ProcessResult ,
7574 Process (
7675 argv = [
77- "./asyncapi-python-codegen.pex" , # Executable PEX
78- "generate" , # Your CLI command
76+ "python" , # Use python interpreter
77+ pex_filename , # PEX file
78+ "-m" ,
79+ "asyncapi_python_codegen" , # Module execution
80+ "generate" , # CLI command
7981 request .protocol_target [AsyncapiServiceField ].value or "" ,
8082 f"{ output_dir } /{ module_name } " ,
8183 ],
0 commit comments