curved-television-6568
02/04/2022, 4:38 PMgit rev-parse --show-toplevel seems like a robust way of locating the repo root, in case of git repos at least. And in doing so, any specs could be treated as relative to where you invoked pants.hundreds-father-404
02/04/2022, 4:40 PMis also using git for version control?Not a requirement. You only need it for
--changed-since to work. We have a call to action, *in our error message if Git is not supported, if someone wants support for other VCS to put in a feature request
--
Instead, we know where the build root is with build_root.pycurved-television-6568
02/04/2022, 4:40 PMhundreds-father-404
02/04/2022, 4:40 PMI’ve found myself a few times now wishing I could invoke pants from any directory, not just the root of the repo.Absolutely, this is one of our most requested features. It would be such a huge win for ergonomics
curved-television-6568
02/04/2022, 4:41 PMInstead, we know where the build root is withThat would be when Pants is up and running..build_root.py
curved-television-6568
02/04/2022, 4:41 PMpants script…hundreds-father-404
02/04/2022, 4:42 PMThat would be when Pants is up and running..We can request the
BuildRoot more eagerly through a synchronous engine request: https://github.com/pantsbuild/pants/blob/c52d2cd27152a79d00237d88ce0f299c6a944b8a/src/python/pants/init/specs_calculator.py#L60-L66hundreds-father-404
02/04/2022, 4:42 PM../../../../pantscurved-television-6568
02/04/2022, 4:43 PMhundreds-father-404
02/04/2022, 4:43 PMhundreds-father-404
02/04/2022, 4:43 PMhundreds-father-404
02/04/2022, 4:45 PMspecs_calculator.py file (and related ones) to relative specs! Nothing else you say on the CLI should care about where you're located, afaict
You'd make a synchronous call to get BuildRootcurved-television-6568
02/04/2022, 4:45 PMcurved-television-6568
02/04/2022, 4:45 PMhundreds-father-404
02/04/2022, 4:47 PMcurved-television-6568
02/04/2022, 4:53 PMcurved-television-6568
02/04/2022, 4:53 PMhundreds-father-404
02/04/2022, 4:55 PMsrc/py/my_project that day, compare this:
./pants test src/py/my_project/utils/file.py
./pants test utils/file.py
Yeah, there's tab auto-complete, but so much more convenient to do the latter. And easier to understand, less noisehundreds-father-404
02/04/2022, 4:56 PMless noiseWhich is a crucial part to Pants's hypothesis of ergonomics. Get rid of boilerplate because it causes noise, and noise gets in the way of seeing what really matters
curved-television-6568
02/04/2022, 4:57 PM./ every where…hundreds-father-404
02/04/2022, 4:57 PMpants test utils/file.py. I like itcurved-television-6568
02/04/2022, 4:57 PMhundreds-father-404
02/04/2022, 4:58 PMNow that starts looking snappy.Which is another reason I'm so excited by the potential here. Every single Pants user interacts with the CLI, every single time. Compared to things like BUILD file management often being only used primarily by power users
witty-crayon-22786
02/04/2022, 5:10 PMwitty-crayon-22786
02/04/2022, 5:11 PMhundreds-father-404
02/04/2022, 5:12 PMelativizing all of the arguments everywhereIsn't it just specs in the CLI? Where else would it matter?
witty-crayon-22786
02/04/2022, 5:17 PMcurved-television-6568
02/04/2022, 5:18 PMcurved-television-6568
02/04/2022, 5:18 PMArgSplitterwitty-crayon-22786
02/04/2022, 5:19 PMrun and etc ran in your cwd rather than in the buildroot, etc. lots of considerationswitty-crayon-22786
02/04/2022, 5:19 PMcurved-television-6568
02/04/2022, 5:20 PMcurved-television-6568
02/04/2022, 5:21 PMcd <repo root> before invoking ./pants and do the relativizing of the cli args outside of pants only.witty-crayon-22786
02/04/2022, 5:21 PMos.getcwd to fail (including relative path lookups), and help enforce good hygienewitty-crayon-22786
02/04/2022, 5:22 PMcurved-television-6568
02/04/2022, 5:22 PMwitty-crayon-22786
02/04/2022, 5:23 PMperhaps actually it would be safer to@curved-television-6568: maybe… i’m not sure that that is easier. that wouldn’t work forbefore invokingcd <repo root>and do the relativizing of the cli args outside of pants only../pants
run, for examplecurved-television-6568
02/04/2022, 5:24 PMcurved-television-6568
02/04/2022, 8:32 PM/Users/x/src/github/kaos/pants/src/python/pants
$ pants version
21:30:27.80 [INFO] Initializing scheduler...
21:30:32.90 [INFO] Scheduler initialized.
2.10.0.dev3
Try it yourselves with:
$ brew tap kaos/shell
$ brew install kaos/shell/pants
$ pants ....curved-television-6568
02/04/2022, 8:32 PMhundreds-father-404
02/05/2022, 1:31 AMbuild_root.py I think, like looking for a BUILD_ROOT file alternatively. But this is awesome starting pointcurved-television-6568
02/05/2022, 2:49 PMlist works nice..
~/src/github/kaos/pants/src/python/pants/backend/docker (main *)
$ pants list .::
src/python/pants/backend/docker:docker
src/python/pants/backend/docker:tests
src/python/pants/backend/docker/__init__.py
src/python/pants/backend/docker/package_types.py
src/python/pants/backend/docker/register.py
src/python/pants/backend/docker/registries.py
src/python/pants/backend/docker/registries_test.py:tests
src/python/pants/backend/docker/rules.py
src/python/pants/backend/docker/target_types.py
src/python/pants/backend/docker/utils.py
src/python/pants/backend/docker/utils_test.py:tests
src/python/pants/backend/docker/value_interpolation.py
Using the . there to indicate my current dir rather than all targets, as pants list :: would (still) do.
Also, this works nice:
$ pants peek util_rules/dockerfile.py
[
{
"address": "src/python/pants/backend/docker/util_rules/dockerfile.py",
"target_type": "python_source",
"dependencies": [
"src/python/pants/backend/docker/target_types.py",
...curved-television-6568
02/05/2022, 2:50 PMbrew upgrade kaos/shell/pants should give you v0.2 now.. 🙂curved-television-6568
02/05/2022, 2:51 PMlooking for aHmm.. why? I can see the benefit, if we were to expect there not being afileBUILD_ROOT
pants bootstrap script at the repo root, but until then, there’s not really a point finding a repo root, unless there is a pants script there for us to invoke.curved-television-6568
02/05/2022, 2:51 PMhundreds-father-404
02/05/2022, 2:54 PMBUILD_ROOT and no ./pants script, all power to you. That allows you to do things like rename ./pants to instead be ./my_org. Relates to Joshua's thread on how to reference ./pantscurved-television-6568
02/05/2022, 2:55 PM$ pants help goals
Unknown entity: src/python/pants/backend/docker/goals
doh. 😛curved-television-6568
02/05/2022, 2:57 PMThat allows you to do things like renameAh, but for that you’d doto instead be./pants../my_org
PANTS_BIN_NAME=my_org pants ...
and it would look for my_org rather than pants script.