Skip to content

Commit

Permalink
Revert "Improve PYTHONPATH checker" (#3249)
Browse files Browse the repository at this point in the history
Reverts #3085

This broke mac builders.

b/299098707
  • Loading branch information
oxve committed May 15, 2024
1 parent 849acbc commit e0c7808
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 23 deletions.
3 changes: 0 additions & 3 deletions cobalt/build/gn.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
from pathlib import Path
from typing import List

from starboard.build.is_on_path import is_on_same_path
from starboard.build.platforms import PLATFORMS

_BUILD_TYPES = ['debug', 'devel', 'qa', 'gold']
Expand Down Expand Up @@ -52,8 +51,6 @@ def main(out_directory: str, platform: str, build_type: str,


if __name__ == '__main__':
assert is_on_same_path(__file__), 'Current repo is not first on PYTHONPATH.'

parser = argparse.ArgumentParser()

builds_directory_group = parser.add_mutually_exclusive_group()
Expand Down
29 changes: 9 additions & 20 deletions starboard/build/is_on_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,17 @@

import os

SRC_ROOT = src_root_dir = os.path.abspath(
os.path.join(os.path.dirname(__file__), os.pardir, os.pardir))


def is_on_same_path(file_path):
"""
Checks if the passed file path is in the same repo as this file.
Args:
file_path: The path to the file that should be checked.
Returns:
True if file_path is a file in the same repo as this file, otherwise False.
"""
return os.path.abspath(file_path).startswith(SRC_ROOT)


if __name__ == '__main__':
def main():
try:
# Try to import this file and compare its path to the current file.
import starboard.build.is_on_path # pylint: disable=import-outside-toplevel
# Use imported function instead of calling directly to ensure imports are
# being made from the same repo as this file is in.
print(str(starboard.build.is_on_path.is_on_same_path(__file__)).lower())
this_file = os.path.realpath(__file__)
imported_file = os.path.realpath(starboard.build.is_on_path.__file__)
print(str(this_file == imported_file).lower())
except ImportError:
print('false')


if __name__ == '__main__':
main()

0 comments on commit e0c7808

Please sign in to comment.