1313 TransitiveTargetsRequest ,
1414)
1515from pants .engine .rules import rule , Get , MultiGet
16- from pants .engine .process import ProcessResult
16+ from pants .engine .process import ProcessResult , Process
1717from pants .source .source_root import SourceRoot , SourceRootRequest
1818from pants .backend .python .util_rules .interpreter_constraints import (
1919 InterpreterConstraints ,
2222 Pex ,
2323 PexRequest ,
2424 PexRequirements ,
25- PexProcess ,
2625)
2726from .targets import *
2827
@@ -36,9 +35,15 @@ async def generate_python_from_asyncapi(
3635 PexRequest (
3736 output_filename = "asyncapi-python-codegen.pex" ,
3837 internal_only = True ,
39- requirements = PexRequirements ([]),
38+ requirements = PexRequirements (
39+ [
40+ # Include your plugin as a requirement so it's available in the PEX
41+ "asyncapi_python_codegen" , # or whatever your package is called
42+ ]
43+ ),
4044 interpreter_constraints = InterpreterConstraints ([">=3.9" ]),
41- # No main parameter - creates a REPL-style PEX
45+ # Make it executable by specifying the main module
46+ main = "-m asyncapi_python_codegen" , # This makes it executable
4247 ),
4348 )
4449 transitive_targets = await Get (
@@ -64,14 +69,12 @@ async def generate_python_from_asyncapi(
6469 output_dir = "_generated_files"
6570 module_name = request .protocol_target .address .target_name
6671
67- # Use PexProcess to properly execute the PEX
72+ # Now use Process with the executable PEX
6873 result = await Get (
6974 ProcessResult ,
70- PexProcess (
71- pex ,
75+ Process (
7276 argv = [
73- "-m" ,
74- "asyncapi_python_codegen" , # Execute as module
77+ "./asyncapi-python-codegen.pex" , # Executable PEX
7578 "generate" , # Your CLI command
7679 request .protocol_target [AsyncapiServiceField ].value or "" ,
7780 f"{ output_dir } /{ module_name } " ,
0 commit comments