def _normalize_path(filename):
  """Normalizes a relative path to a command to spawn.

  Args:
    filename: String; relative or absolute path.

  Returns:
    The normalized path. This is necessary because in our use case,
    vexflow_generator_pipeline will live in a different directory from
    vexflow_generator, and there are symlinks to both directories in the same
    parent directory. Without normalization, `..` would reference the parent of
    the actual directory that was symlinked. With normalization, it references
    the directory that contains the symlink to the working directory.
  """
  if filename.startswith('/'):
    return filename
  else:
    return os.path.normpath(
        os.path.join(os.path.dirname(sys.argv[0]), filename))