Ejemplo n.º 1
0
 def test_empty_wheel_cache(self):
     """
     A pip cache dir with an empty wheel cache returns no packages.
     """
     with tempcache() as pipcache:
         extractor = WheelCacheExtractor(pipcache.path)
         self.assertEqual(list(extractor.iter_cache()), [])
Ejemplo n.º 2
0
 def test_missing_wheel_cache(self):
     """
     A pip cache dir with no wheel cache returns no packages.
     """
     with tempdir() as basedir:
         pip_cache_dir = os.path.join(basedir, "pipcache")
         os.mkdir(pip_cache_dir)
         extractor = WheelCacheExtractor(pip_cache_dir)
         self.assertEqual(list(extractor.iter_cache()), [])
Ejemplo n.º 3
0
 def test_pip_cache_with_wheels(self):
     """
     A pip wheel cache with wheels in it returns some packages.
     """
     with tempcache() as pipcache:
         wheel1 = pipcache.write_wheel("ab/cd/ef/ghij/foo.whl")
         wheel2 = pipcache.write_wheel("12/34/56/7890/bar.whl")
         extractor = WheelCacheExtractor(pipcache.path)
         self.assertEqual(
             sorted([cw.filepath for cw in extractor.iter_cache()]),
             sorted([wheel1, wheel2]))
Ejemplo n.º 4
0
 def test_wheel_content(self):
     """
     Any file ending with .whl is assumed to be a valid wheel.
     """
     with tempcache() as pipcache:
         pipcache.write_wheel("ab/cd/ef/ghij/foo.whl", b"round")
         extractor = WheelCacheExtractor(pipcache.path)
         [cached_wheel] = extractor.iter_cache()
         self.assertEqual(cached_wheel.can_symlink, True)
         self.assertEqual(cached_wheel.is_package, True)
         self.assertEqual(cached_wheel.package_filename, "foo.whl")
         self.assertEqual(cached_wheel.get_package_data(), b"round")
Ejemplo n.º 5
0
 def test_default_pip_cache(self):
     """
     If no pip cache is provided, the default is used.
     """
     extractor = WheelCacheExtractor()
     self.assertEqual(
         extractor.wheel_cache_dir, os.path.join(USER_CACHE_DIR, "wheels"))
Ejemplo n.º 6
0
    def __init__(self, package_dir, pip_cache_dir=None, symlink=True,
                 verbosity=1):
        self.pip_cache_dir = pip_cache_dir
        self.package_dir = package_dir
        assert package_dir is not None
        self.symlink = symlink
        self.verbosity = verbosity

        self.caches = [
            HTTPCacheExtractor(self.pip_cache_dir),
            WheelCacheExtractor(self.pip_cache_dir),
        ]