bitter-ability-32190
06/01/2022, 2:09 PM./pants run ...
on a python_source
, freeing users from requiring the declaration of a pex_binary
for scripts, and frees us to implement pex_binary
running as package + run
.curved-television-6568
06/01/2022, 2:38 PMbitter-ability-32190
06/01/2022, 2:40 PMhundreds-father-404
06/01/2022, 2:46 PMrun
working for pex_binary
because you might have something like isort.pex
using script='isort'
. So this would be allowing you to use either approach
--
My gut reaction is "But what if a user tries running something that isn't executable!!!" It's important that ./pants $goal ::
knows which targets are valid and which are not
But I think my fear is overblown because...we only allow you to run on one target at a time. And that will always be the case, given InteractiveProcess
claims the foreground
We could allow you to do ./pants run ::
and then we run each process sequentially, which is how test --debug
works...but imo that would be a UX regressionhundreds-father-404
06/01/2022, 2:47 PMpex_binary
still working, then that's not much of a concern. Usually just use `python_source`; use pex_binary
if you gotta do something specialhundreds-father-404
06/01/2022, 2:47 PMpex_binary
around also means this has zero breaking change for users, which is greathundreds-father-404
06/01/2022, 2:52 PMbuild-support
should actually be buildable with package
! That is not at all our intent to distribute them!bitter-ability-32190
06/01/2022, 3:00 PMMy gut reaction is "But what if a user tries running something that isn't executable!!!"Have no fear! This is only for
python_source
. IN which case, every Python file is executable as per the language 😉bitter-ability-32190
06/01/2022, 3:02 PMmy other concern is "Are we confident none of those Pex args matter with run?"If anything, this would fix the current gap we have today. Right now
./pants run my_pex_binary
doesn't run the Pex! So those args provided to pex aren't considered. In a future world, it would run the PEX and therefore consider the args.bitter-ability-32190
06/01/2022, 3:02 PMKeepingI had to update PR, there is one breaking change 😅 : "Current users canaround also means this has zero breaking change for users, which is greatpex_binary
./pants run path/to/file.py
today if that file is the entry_point
of a pex_binary
. With a change like this, it becomes ambiguous."bitter-ability-32190
06/01/2022, 3:04 PMSecondaryOwnerMixin
of the entry_point
field in pex_binary
, so that ./pants run file.py
is unambiguously us running the file.hundreds-father-404
06/01/2022, 3:04 PMIN which case, every Python file is executable as per the language 😉Sure, but you probably didn't mean to
run
strutil.py
. If ./pants run ::
worked, then this would be a big concern for me. Fortunately, I think it's unlikely we'd want to ever let that workcurved-television-6568
06/01/2022, 3:08 PMbitter-ability-32190
06/01/2022, 3:09 PMwitty-crayon-22786
06/01/2022, 4:37 PM./pants run $file
to locate an owning pex_binary
… presumably this behavior would be a fallback after that lookup?bitter-ability-32190
06/01/2022, 4:56 PMwitty-crayon-22786
06/01/2022, 4:57 PMhappy-kitchen-89482
06/01/2022, 9:53 PMpex_binary
has two roles: A) enhances a source file with metadata (describing how to build a PEX out of it) and B) selects what ::
can match on. ./pants run
is special in that applying it to ::
makes no sense and is not supported, and we also don't generally need any extra metadata to do a ./pants run
(as opposed to ./pants package
). So, yeah, why require a target?happy-kitchen-89482
06/01/2022, 9:56 PM./pants <goal> path/to/file.py
should ~always work with sensible defaults. E.g., ./pants test path/to/file.py
makes sense even with no python_tests
target. It's obvious what to do in that case. Targets should be required only when sensible defaults need to be overridden (or are not possible in the first place) and for ::
to do the right thing.bitter-ability-32190
06/02/2022, 1:12 PM!!dep
in dependencies since it acts like a leaf in the dependency tree when run.
I'm running into this now in my repo 😕bitter-ability-32190
06/02/2022, 1:14 PMIt's obvious what to do in that case.I'm not so sure thats true, actually. Test files aren't themselves meaningfully runnable (unless they have the
if __name__
suffix) because pytest magic. So did you want to run it vanilla (what if they have a __name__ == "__main__"
handler?) or through Pytest?
Also running is matched on field sets, so w'd have to special case the test targets in the one run implementation.
Not saying it isn't possible or ideal, but pointing out it does get ambiguousbitter-ability-32190
06/04/2022, 8:15 PMcurved-television-6568
06/04/2022, 8:21 PMhappy-kitchen-89482
06/05/2022, 7:55 AMI'm not so sure thats true, actually. Test files aren't themselves meaningfully runnable (unless they have the if name suffix) because pytest magic. So did you want to run it vanilla (what if they have a name == "__main__" handler?) or through Pytest?Through pytest. I think
./pants test path/to/file.py
unambiguously means "run pytest with that file as input".happy-kitchen-89482
06/05/2022, 7:57 AMfile.py
isn't a test. We shouldn't get in the way of the user telling us what to do. The fieldsets are for figuring out what ::
applies to.happy-kitchen-89482
06/05/2022, 7:58 AMrun
is special since run ::
is disallowed anyway.bitter-ability-32190
06/05/2022, 10:57 AMbitter-ability-32190
06/08/2022, 1:39 PMhappy-kitchen-89482
06/09/2022, 12:44 PMhappy-kitchen-89482
06/09/2022, 12:45 PM