It's really common that our developers would run 3...
# general
g
It's really common that our developers would run 3rd party binaries via poetry, i.e.
Copy code
poetry run alembic
poetry run openapi-python-client
Is there a similar pattern in pants? I did this and it works
Copy code
pex_binary(
    name="openapi_python_client",
    entry_point="openapi_python_client.cli:app",
)
but I was wondering if I'm making this harder than it needs to be.
f
A
python_requirement
target for the third-party dependency is also "runnable" in the view oif Pants.
I assume you are using the
python_requirements
(plural) target? If so, it generates a
python_requirement
target (singular) if each dependency,
g
ah, so I can just run the requirement?
f
let's say the
python_requirements
was in in the root
BUILD
file with name `reqs`: then you could run
pants run //:reqs#openapi_python_client
g
sweeet
Glad I asked.
f
The
#
notation signifies a "generated target"
that said, if Pants cannot figure out the correct entry point you may need to add an
overrides
section to the
python_requirements
to set it.
👍 1
or just define the
python_requirement
explicitly with a
entry_point
field set to
openapi_python_client.cli:app
as you did with the
pex_binary
g
Thanks @fast-nail-55400
b
Additionally, if you already have a built PEX with Alembic or the OpenAPI client built in, you can use the
PEX_SCRIPT
environment variable to run that from inside the PEX, ex:
Copy code
PEX_SCRIPT=alembic /path/to/pex <args to alembic>
🙏 1