Another bikeshed :bike: what to call the new symbo...
# development
h
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
here
? 😂
🎉 1
h
I'm open to that! Do you think people might be confused if it's
path/to/BUILD
rather than
path/to/
?
b
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
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
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
K so then how about
build_file_dir
? Hopefully there is zero ambiguity there
b
__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
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
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
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
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
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
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
Is
build_file_dir
okay with you? I figure it removes any ambiguity, and isn't very hard to type either
c
Yea, it is.
👍 1