import glob
import shutil


def copy_egg_info(dest_dir):
  """Copies the .egg-info directory to the specified location.

  Args:
    dest_dir: str. The destination directory.

  Returns:
    0 on success, 1 on failure.
  """
  # Remove any trailing slash on the destination directory.
  dest_dir = dest_dir.rstrip('/')
  egg_srcs = glob.glob('google_nucleus-*-py*.egg-info')
  if not egg_srcs:
    print('Could not find source .egg-info directory')
    return 1
  egg_src = egg_srcs[0]
  print('Copying egg-info from ', egg_src, ' to ', dest_dir)
  shutil.copytree(egg_src, dest_dir)
  return 0