code: def write_setup(self, root_target, reduced_dependencies, chroot):
      
      setup_keywords = root_target.provides.setup_py_keywords.copy()
  
      package_dir = {'': self.SOURCE_ROOT}
      packages, namespace_packages, resources = self.find_packages(root_target, chroot)
  
      if namespace_packages:
        setup_keywords['namespace_packages'] = list(sorted(namespace_packages))
  
      if packages:
        setup_keywords.update(
            package_dir=package_dir,
            packages=list(sorted(packages)),
            package_data=dict((str(package), list(map(str, rs)))
                              for (package, rs) in resources.items()))
  
      setup_keywords['install_requires'] = list(self.install_requires(reduced_dependencies))
  
      for binary_name, entry_point in self.iter_entry_points(root_target):
        if 'entry_points' not in setup_keywords:
          setup_keywords['entry_points'] = {}
        if 'console_scripts' not in setup_keywords['entry_points']:
          setup_keywords['entry_points']['console_scripts'] = []
        setup_keywords['entry_points']['console_scripts'].append(
            '{} = {}'.format(binary_name, entry_point))
  
      setup_py = self._setup_boilerplate().format(setup_dict=distutils_repr(setup_keywords),
                                                  setup_target=root_target.address.reference())
      chroot.write(ensure_binary(setup_py), 'setup.py')
  
      # Make sure that `setup.py` is included.
      chroot.write('include *.py', 'MANIFEST.in', mode='w')
docs: Write the setup.py of a target.
  
      Must be run after writing the contents to the chroot.