def relativize_classpath(classpath, root_dir, followlinks=True):
  def relativize_url(url, root_dir):
    # When symlink is involed, root_dir concatenated with the returned relpath may not exist.
    # Consider on mac `/var` is a symlink of `/private/var`, the relative path of subdirectories
    # under /var to any other directories under `/` computed by os.path.relpath misses one level
    # of `..`. Use os.path.realpath to guarantee returned relpath can always be located.
    # This is not needed only when path are all relative.
    url = os.path.realpath(url) if followlinks else url
    root_dir = os.path.realpath(root_dir) if followlinks else root_dir
    url_in_bundle = os.path.relpath(url, root_dir)
    # Append '/' for directories, those not ending with '/' are assumed to be jars.
    # Note isdir does what we need here to follow symlinks.
    if os.path.isdir(url):
      url_in_bundle += '/'
    return url_in_bundle

  return [relativize_url(url, root_dir) for url in classpath]


# VisibleForTesting
Stop the Home Assistant server.
dataset/ETHPy150Open pantsbuild/pants/src/python/pants/java/util.py/relativize_classpath--crossover with--dataset/ETHPy150Open home-assistant/home-assistant/tests/components/device_tracker/test_locative.py/tearDownModule