https://pantsbuild.org/ logo
#development
Title
# development
h

hundreds-father-404

03/17/2022, 4:41 PM
Another bikeshed 🚲 what to call the new symbol we added to BUILD files to get the BUILD directory path. Right now it's
cwd
, but Stu pointed out that's probably a misnomer. So far we have
current_directory
,
build_file_directory
,
current_dir
, and
build_file_dir
proposed
b

bitter-ability-32190

03/17/2022, 4:46 PM
here
? 😂
🎉 1
h

hundreds-father-404

03/17/2022, 4:47 PM
I'm open to that! Do you think people might be confused if it's
path/to/BUILD
rather than
path/to/
?
b

bitter-ability-32190

03/17/2022, 4:48 PM
I agree with Stu though. Loose thoughts: •
current
might be a bad idea because it's value is relative to the file •
dir
instead of
directory
.
👍 1
Does it have to be a function? You could set
__file__
as that has semantics and build files ARE Python 😉
h

hundreds-father-404

03/17/2022, 4:49 PM
I recommend it be a file function, Stu had the great suggestion of returning
PurePath
so that you can do things like
here() / "../parent_dir"
w/o violating our ban on imports. (Calling
str()
on
PurePath
converts it)
b

bitter-ability-32190

03/17/2022, 4:50 PM
Do you think people might be confused if it's path/to/BUILD rather than path/to/?
Yes if the idea is if it is a dir 😄
h

hundreds-father-404

03/17/2022, 4:50 PM
K so then how about
build_file_dir
? Hopefully there is zero ambiguity there
b

bitter-ability-32190

03/17/2022, 4:50 PM
__path__  / "../parent_dir"
works just as well. All pathlbi types are immutable, so no concern on that front
👍 1
I think the only weirdness here is directory path vs. file path 🤔
h

hundreds-father-404

03/17/2022, 4:51 PM
path / "../parent_dir" works just as well.
Ack. Another reason I prefer a function is I think it might be more intuitive for non-Python folks like JVM users, and better integrate with the
./pants help build-symbols
I'm itching to make
f

fast-nail-55400

03/17/2022, 4:58 PM
Is there going to be other build file metadata exposed in the build file in the future?
Would a
build_file().directory
(i.e., a named attribute on some container) be better?
h

hundreds-father-404

03/17/2022, 5:00 PM
Perhaps, but I can't imagine what other info we'd want? Kinda related: in v1 we used to have a way to get the absolute path to the build root, although absolute paths don't make much since in v2
c

curved-television-6568

03/17/2022, 6:19 PM
For me cwd feels rather natural. The ”current working directory” is all about context to what ”current” is. Here it would be the directory housing the build file you’re looking at.
h

hundreds-father-404

03/17/2022, 6:19 PM
It made sense to me too. But then I started thinking about your proposal to run Pants in any directory rather than build root, and I think it could become ambiguous
c

curved-television-6568

03/17/2022, 6:20 PM
Yeah, well it doesn't have anything todo with execution, which would be the one downside of it.
I don't think were you execute pants from changes anything for my reasoning on “current” above.
h

hundreds-father-404

03/17/2022, 6:21 PM
Is
build_file_dir
okay with you? I figure it removes any ambiguity, and isn't very hard to type either
c

curved-television-6568

03/17/2022, 6:45 PM
Yea, it is.
👍 1