https://pantsbuild.org/ logo
#general
Title
# general
c

calm-artist-46894

01/23/2020, 5:38 AM
The default value for
--build-file-imports
is
warn
, what’s the reason to discourage using import in BUILD file? If I need read the environment variable (e.g. the git branch) and do different things based on if the branch is master. Something like:
Copy code
def get_version(version):
  import os
  release = os.getenv("CIRCLE_BRANCH") == "master"
  if not release:
    version += ".dev"
  return version
What is the recommended alternative?
a

average-vr-56795

01/23/2020, 10:49 AM
Pants won’t factor that into caching; so if you run pants, change the env var, and run pants again, you may get stale results
If you’re fine with that, you can do the thing you’re doing, but in general we’d recommend using a custom pants plugin for this kind of functionality, rather than putting the logic in a BUILD file
👍 3
c

calm-artist-46894

01/25/2020, 12:35 AM
Make sense. Thanks
3 Views