abundant-analyst-12845
11/25/2022, 4:39 PMpoetry run <dependency
with pants being able to detect my 3rd party dependencies. is there a need to either run poetry install
to prep my local dev before running my poetry
commands or does pants support sort of running something from ./pants run poetry
enough-analyst-54434
11/25/2022, 4:49 PM./pants run path/to/file.py
or ./pants run the/pex_binary/target:here
. For 3rdparty entry points you'll need to define a pex_binary
target somewhere that encapsulates the entry point:
$ cat <<EOF > BUILD.cowsay
python_requirement(name="cowsay", requirements=["cowsay==5.0"])
pex_binary(name="bin", script="cowsay", dependencies=[":cowsay"])
EOF
$ ./pants generate-lockfiles --resolve=python-default
08:49:09.51 [INFO] Completed: Generate lockfile for python-default
08:49:09.52 [INFO] Wrote lockfile for the resolve `python-default` to 3rdparty/python/user_reqs.lock
$ ./pants run //:bin -- 'Moo!'
08:49:23.31 [INFO] Completed: Building 1 requirement for bin.pex from the 3rdparty/python/user_reqs.lock resolve: cowsay==5.0
____
| Moo! |
====
\
\
^__^
(oo)\_______
(__)\ )\/\
||----w |
|| ||
abundant-analyst-12845
11/25/2022, 5:00 PMawsclie
would it look like this?
python_requirement(name="awscli", requirements=["awscli==5.0"])
pex_binary(name="awscli-bin", script="awscli", dependencies=[":awscli"])
followed by the generate command ./pants generate-lockfiles
then I can run ./pants run //:awscli-bin <standard awscli commands>
??enough-analyst-54434
11/25/2022, 5:01 PMpython_requirement
line would not be needed and that requirement would come from a `requirements.txt`file or a `pytproject.toml`file.enough-analyst-54434
11/25/2022, 5:02 PM--
, you pass args to the thing you are `./pants run`ing after the --
abundant-analyst-12845
11/25/2022, 5:02 PMabundant-analyst-12845
11/25/2022, 5:03 PM./pants run awscli-bin -- <what ever arguments original awslci supports>
abundant-analyst-12845
11/25/2022, 5:03 PMenough-analyst-54434
11/25/2022, 5:03 PMawscli
dependency defined in your pyproject.toml?abundant-analyst-12845
11/25/2022, 5:03 PMenough-analyst-54434
11/25/2022, 5:03 PMpython_requirement(name="awscli", requirements=["awscli==5.0"])
should not be needed.abundant-analyst-12845
11/25/2022, 5:03 PMabundant-analyst-12845
11/25/2022, 5:05 PMpoetry_requirements
and running ./pants run awscli -- <cli commands>
enough-analyst-54434
11/25/2022, 5:05 PMpex_binary
targetenough-analyst-54434
11/25/2022, 5:06 PMawscli
on the command line, that that means a console script named awscli
provided by the awscli==5.0 3rdparty dependency.abundant-analyst-12845
11/25/2022, 5:08 PMpoetry_requirements(
name="poetry",
resolve="common",
},
)
pex_binary(
name="awscli",
entry_point="do i need to know where to point",
resolve="common",
)
abundant-analyst-12845
11/25/2022, 5:08 PMenough-analyst-54434
11/25/2022, 5:10 PMdependencies=[":poetry#awscli"]
in your example and you use entry_point
only if you want to spell out the full entry point module:function
. If there is a console script available its ~always better to use script
.enough-analyst-54434
11/25/2022, 5:12 PMmodule:function
that may be subject to rename refactors.abundant-analyst-12845
11/25/2022, 5:14 PMabundant-analyst-12845
11/25/2022, 5:18 PMpoetry_requirements(
name="poetry",
resolve="common",
},
)
pex_binary(
name="awscli",
dependencies=[":poetry#awscli"]
script="awscli",
resolve="common",
)
`./pants run //:awscli -- <rest or argument>
or
poetry_requirements(
name="poetry",
resolve="common",
},
)
pex_binary(
name="pants-awscli",
dependencies=[":poetry#awscli"]
script="awscli",
resolve="common",
)
./pants run //:pants-awscli -- <rest of arguments>
enough-analyst-54434
11/25/2022, 5:21 PMpex_binary
target right? Both examples should work. The target name is ~arbitrary and up to you.enough-analyst-54434
11/25/2022, 5:22 PMenough-analyst-54434
11/25/2022, 5:25 PMpyproject.toml
file it describes, but the `pex_binary`target can go in a BUILD file anywhere. You just adjust the dependencies to say dependencies=["path/from/root/of/repo/to/poetry/build_file:poetry#awscli"]
.abundant-analyst-12845
11/25/2022, 5:55 PMabundant-analyst-12845
11/25/2022, 5:56 PMabundant-analyst-12845
11/25/2022, 5:57 PM