def safe_classpath(classpath, synthetic_jar_dir, custom_name=None):
 if synthetic_jar_dir:
  safe_mkdir(synthetic_jar_dir)
 else:
  synthetic_jar_dir = safe_mkdtemp()
 bundled_classpath = relativize_classpath(classpath, synthetic_jar_dir)
 manifest = Manifest()
 manifest.addentry(Manifest.CLASS_PATH, u' '.join(bundled_classpath))
 with temporary_file(root_dir=synthetic_jar_dir, cleanup=False, suffix=u'.jar') as jar_file:
  with open_zip(jar_file, mode=u'w', compression=ZIP_STORED) as jar:
   jar.writestr(Manifest.PATH, manifest.contents())
  if custom_name:
   custom_path = os.path.join(synthetic_jar_dir, custom_name)
   safe_concurrent_rename(jar_file.name, custom_path)
   return [custom_path]
  else:
   return [jar_file.name]

def safe_classpath ( classpath , synthetic_jar_dir , custom_name = None ) : if synthetic_jar_dir : safe_mkdir ( synthetic_jar_dir ) else : synthetic_jar_dir = safe_mkdtemp ( ) bundled_classpath = relativize_classpath ( classpath , synthetic_jar_dir ) manifest = Manifest ( ) manifest . addentry ( Manifest . CLASS_PATH , u' ' . join ( bundled_classpath ) ) with temporary_file ( root_dir = synthetic_jar_dir , cleanup = False , suffix = u'.jar' ) as jar_file : with open_zip ( jar_file , mode = u'w' , compression = ZIP_STORED ) as jar : jar . writestr ( Manifest . PATH , manifest . contents ( ) ) if custom_name : custom_path = os . path . join ( synthetic_jar_dir , custom_name ) safe_concurrent_rename ( jar_file . name , custom_path ) return [ custom_path ] else : return [ jar_file . name ]
bundles classpath into one synthetic jar that includes original classpath in its manifest .