Ejemplo n.º 1
0
def pack(args):
    """Pack wheel files.

  Returns 0 or None if all went well, a non-zero int otherwise.
  """

    if not args.packages:
        print 'No packages have been provided on the command-line, doing nothing.'
        return 0

    packing_list = get_packing_list(args.packages)

    unhandled = [
        util.fileurl2path(d['location']) for d in packing_list
        if d['package_type'] in ('unhandled', 'missing')
    ]
    if unhandled:
        print >> sys.stderr, (
            'These directories do not seem to be packable '
            'because they do not exist or\n'
            'have neither setup.cfg or setup.py inside them:')
        print >> sys.stderr, ('\n'.join(unhandled))
        return 1

    if not os.path.isdir(args.output_dir):
        os.mkdir(args.output_dir)

    wheel_paths = []
    with util.Virtualenv(prefix="glyco-pack-",
                         keep_directory=args.keep_tmp_directories) as venv:
        for element in packing_list:
            if element['location'].startswith('file://'):
                pathname = util.fileurl2path(element['location'])

                # Standard Python source package: contains a setup.py
                if element['package_type'] == 'standard':
                    wheel_path = pack_local_package(venv, pathname,
                                                    args.output_dir)

                # The Glyco special case: importable package with a setup.cfg file.
                elif element['package_type'] == 'bare':
                    wheel_path = pack_bare_package(
                        venv,
                        pathname,
                        args.output_dir,
                        keep_directory=args.keep_tmp_directories)

                wheel_paths.append(wheel_path)

        if args.verbose:
            print '\nGenerated %d packages:' % len(wheel_paths)
            for wheel_path in wheel_paths:
                print wheel_path
Ejemplo n.º 2
0
def pack(args):
  """Pack wheel files.

  Returns 0 or None if all went well, a non-zero int otherwise.
  """

  if not args.packages:
    print 'No packages have been provided on the command-line, doing nothing.'
    return 0

  packing_list = get_packing_list(args.packages)

  unhandled = [util.fileurl2path(d['location'])
               for d in packing_list
               if d['package_type'] in ('unhandled', 'missing')]
  if unhandled:
    print >> sys.stderr, ('These directories do not seem to be packable '
                          'because they do not exist or\n'
                          'have neither setup.cfg or setup.py inside them:')
    print >> sys.stderr, ('\n'.join(unhandled))
    return 1


  if not os.path.isdir(args.output_dir):
    os.mkdir(args.output_dir)

  wheel_paths = []
  with util.Virtualenv(
      prefix="glyco-pack-",
      keep_directory=args.keep_tmp_directories) as venv:
    for element in packing_list:
      if element['location'].startswith('file://'):
        pathname = util.fileurl2path(element['location'])

        # Standard Python source package: contains a setup.py
        if element['package_type'] == 'standard':
          wheel_path = pack_local_package(venv, pathname, args.output_dir)

        # The Glyco special case: importable package with a setup.cfg file.
        elif element['package_type'] == 'bare':
          wheel_path = pack_bare_package(
            venv,
            pathname,
            args.output_dir,
            keep_directory=args.keep_tmp_directories)

        wheel_paths.append(wheel_path)

    if args.verbose:
      print '\nGenerated %d packages:' % len(wheel_paths)
      for wheel_path in wheel_paths:
        print wheel_path
Ejemplo n.º 3
0
 def test_url_to_path_to_url_absolute_path(self):
   url1 = 'file:///absolutely/normal/path/'
   url2 = util.path2fileurl(util.fileurl2path(url1))
   self.assertEqual(url1, url2)
Ejemplo n.º 4
0
 def test_url_to_path_to_url_with_spaces(self):
   url1 = 'file:///absolute/path/with%20spaces'
   url2 = util.path2fileurl(util.fileurl2path(url1))
   self.assertEqual(url1, url2)
Ejemplo n.º 5
0
 def test_url_to_path_to_url(self):
   url1 = 'file:///this/is/a/path'
   url2 = util.path2fileurl(util.fileurl2path(url1))
   self.assertEqual(url1, url2)
Ejemplo n.º 6
0
 def test_path_to_url_to_path(self):
   # Use an existing file as a way to get an OS-specific absolute path.
   path = util.fileurl2path(util.path2fileurl(ROOT_DIR))
   self.assertEqual(path, ROOT_DIR)
Ejemplo n.º 7
0
 def test_url_to_path_to_url_absolute_path(self):
     url1 = 'file:///absolutely/normal/path/'
     url2 = util.path2fileurl(util.fileurl2path(url1))
     self.assertEqual(url1, url2)
Ejemplo n.º 8
0
 def test_url_to_path_to_url_with_spaces(self):
     url1 = 'file:///absolute/path/with%20spaces'
     url2 = util.path2fileurl(util.fileurl2path(url1))
     self.assertEqual(url1, url2)
Ejemplo n.º 9
0
 def test_url_to_path_to_url(self):
     url1 = 'file:///this/is/a/path'
     url2 = util.path2fileurl(util.fileurl2path(url1))
     self.assertEqual(url1, url2)
Ejemplo n.º 10
0
 def test_path_to_url_to_path(self):
     # Use an existing file as a way to get an OS-specific absolute path.
     path = util.fileurl2path(util.path2fileurl(ROOT_DIR))
     self.assertEqual(path, ROOT_DIR)