Skip to content

Commit

Permalink
[internal] note dependency to scie-pants on "testing" env vars. (pa…
Browse files Browse the repository at this point in the history
…ntsbuild#18170)

* [internal] note dependency to `scie-pants` on "testing" env vars.
* Look for `pants.toml` when determining build root.
  • Loading branch information
kaos authored Feb 4, 2023
1 parent 164e877 commit efc1c2e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/python/pants/base/build_root.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ class BuildRoot(metaclass=SingletonMetaclass):
"""Represents the global workspace build root.
By default a Pants workspace is defined by a root directory where one of multiple sentinel files
reside, such as `pants` or `BUILD_ROOT`. This path can also be manipulated through this
reside, such as `pants.toml` or `BUILD_ROOT`. This path can also be manipulated through this
interface for re-location of the build root in tests.
"""

sentinel_files = ["pants", "BUILDROOT", "BUILD_ROOT"]
sentinel_files = ["pants.toml", "pants", "BUILDROOT", "BUILD_ROOT"]

class NotFoundError(Exception):
"""Raised when unable to find the current workspace build root."""
Expand Down Expand Up @@ -46,7 +46,8 @@ def pathlib_path(self) -> Path:
def path(self) -> str:
"""Returns the build root for the current workspace."""
if self._root_dir is None:
# This env variable is for testing purpose.
# Do not remove/change this env var without coordinating with `pantsbuild/scie-pants` as
# it is being used when bootstrapping Pants.
override_buildroot = os.environ.get("PANTS_BUILDROOT_OVERRIDE", None)
if override_buildroot:
self._root_dir = override_buildroot
Expand Down
3 changes: 3 additions & 0 deletions src/python/pants/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@
from pants.util.resources import read_resource

# Set this env var to override the version pants reports. Useful for testing.
# Do not change. (see below)
_PANTS_VERSION_OVERRIDE = "_PANTS_VERSION_OVERRIDE"


VERSION: str = (
# Do not remove/change this env var without coordinating with `pantsbuild/scie-pants` as it is
# being used when bootstrapping Pants with a released version.
os.environ.get(_PANTS_VERSION_OVERRIDE)
or
# NB: We expect VERSION to always have an entry and want a runtime failure if this is false.
Expand Down

0 comments on commit efc1c2e

Please sign in to comment.