fresh-cat-90827
07/13/2021, 5:48 PMBUILD
files so that different targets such as pex_binary
could use a value from an arbitrary file stored in a Python package within the monorepo?fresh-cat-90827
07/13/2021, 5:48 PMMacros cannot import other modules, just like BUILD files cannot have import statements.So I wonder how to bring in version into the
BUILD
file, if that’s possible at all.
The use case would be to bring the version value in the pex_binary
target:
pex_binary(
name=f'project-linux-{version}-cp3.6'
)
The reason I don’t want to define version
in the BUILD
file is because there are clients external to Pants who would be interested in obtaining the version value and it’s much easier to do this by reading a standalone file containing the version only (like here https://github.com/pantsbuild/pants/blob/dcbedd422fcb3c52b85bfeae4f4fbde031ad69a3/src/python/pants/VERSION) than reading a variable defined in the BUILD
file.enough-analyst-54434
07/13/2021, 9:54 PM$ cat <<EOF > foo.py
version = "1.2.3"
EOF
$ cat <<EOF > BUILD.example
pex_binary(
name=f'project-linux-{version}-cp3.6'
)
EOF
$ ./pants --build-file-prelude-globs=foo.py list //:
//:build_root
//:gitignore
//:pants_toml
//:project-linux-1.2.3-cp3.6
//:scripts
enough-analyst-54434
07/13/2021, 9:55 PM