Пример #1
0
def test_create_bundle():
    """
    Test making a bundle.  We'll grab one package from the filesystem
    (the FSPkg dummy package), one from vcs (initools) and one from an
    index (pip itself).

    """
    env = reset_env()
    fspkg = path_to_url2(Path(tests_data) / 'packages' / 'FSPkg')
    run_pip('install', '-e', fspkg)
    pkg_lines = textwrap.dedent(
        '''\
            -e %s
            -e %s#egg=initools-dev
            pip''' %
        (fspkg,
         local_checkout('svn+http://svn.colorstudy.com/INITools/trunk')))
    write_file('bundle-req.txt', pkg_lines)
    # Create a bundle in env.scratch_path/ test.pybundle
    result = run_pip('bundle', '-r', env.scratch_path / 'bundle-req.txt',
                     env.scratch_path / 'test.pybundle')
    bundle = result.files_after.get(join('scratch', 'test.pybundle'), None)
    assert bundle is not None

    files = zipfile.ZipFile(bundle.full).namelist()
    assert 'src/FSPkg/' in files
    assert 'src/initools/' in files
    assert 'build/pip/' in files
Пример #2
0
 def get_url(self, location):
     url = call_subprocess(
         [self.cmd, 'showconfig', 'paths.default'],
         show_stdout=False, cwd=location).strip()
     if self._is_local_repository(url):
         url = path_to_url2(url)
     return url.strip()
Пример #3
0
def test_unpack_http_url_with_urllib_response_without_content_type():
    """
    It should download and unpack files even if no Content-Type header exists
    """
    def _get_response_from_url_mock(*args, **kw):
        resp = _get_response_from_url_original(*args, **kw)
        del resp.info()['content-type']
        return resp

    with patch('pip.download._get_response_from_url',
               _get_response_from_url_mock) as mocked:
        uri = path_to_url2(
            os.path.join(tests_data, 'packages', 'simple-1.0.tar.gz'))
        link = Link(uri)
        temp_dir = mkdtemp()
        try:
            unpack_http_url(link,
                            temp_dir,
                            download_cache=None,
                            download_dir=None)
            assert set(os.listdir(temp_dir)) == set([
                'PKG-INFO', 'setup.cfg', 'setup.py', 'simple',
                'simple.egg-info'
            ])
        finally:
            rmtree(temp_dir)
Пример #4
0
 def get_url(self, location):
     url = call_subprocess([self.cmd, 'showconfig', 'paths.default'],
                           show_stdout=False,
                           cwd=location).strip()
     if self._is_local_repository(url):
         url = path_to_url2(url)
     return url.strip()
Пример #5
0
 def get_url(self, location):
     urls = call_subprocess(
         [self.cmd, 'info'], show_stdout=False, cwd=location)
     for line in urls.splitlines():
         line = line.strip()
         for x in ('checkout of branch: ',
                   'parent branch: '):
             if line.startswith(x):
                 repo = line.split(x)[1]
                 if self._is_local_repository(repo):
                     return path_to_url2(repo)
                 return repo
     return None
Пример #6
0
 def get_url(self, location):
     urls = call_subprocess([self.cmd, 'info'],
                            show_stdout=False,
                            cwd=location)
     for line in urls.splitlines():
         line = line.strip()
         for x in ('checkout of branch: ', 'parent branch: '):
             if line.startswith(x):
                 repo = line.split(x)[1]
                 if self._is_local_repository(repo):
                     return path_to_url2(repo)
                 return repo
     return None
Пример #7
0
def test_unpack_http_url_with_urllib_response_without_content_type():
    """
    It should download and unpack files even if no Content-Type header exists
    """
    def _get_response_from_url_mock(*args, **kw):
        resp = _get_response_from_url_original(*args, **kw)
        del resp.info()['content-type']
        return resp

    with patch('pip.download._get_response_from_url', _get_response_from_url_mock) as mocked:
        uri = path_to_url2(os.path.join(tests_data, 'packages', 'simple-1.0.tar.gz'))
        link = Link(uri)
        temp_dir = mkdtemp()
        try:
            unpack_http_url(link, temp_dir, download_cache=None, download_dir=None)
            assert set(os.listdir(temp_dir)) == set(['PKG-INFO', 'setup.cfg', 'setup.py', 'simple', 'simple.egg-info'])
        finally:
            rmtree(temp_dir)
Пример #8
0
def test_create_bundle():
    """
    Test making a bundle.  We'll grab one package from the filesystem
    (the FSPkg dummy package), one from vcs (initools) and one from an
    index (pip itself).

    """
    env = reset_env()
    fspkg = path_to_url2(Path(here)/'packages'/'FSPkg')
    run_pip('install', '-e', fspkg)
    pkg_lines = textwrap.dedent('''\
            -e %s
            -e %s#egg=initools-dev
            pip''' % (fspkg, local_checkout('svn+http://svn.colorstudy.com/INITools/trunk')))
    write_file('bundle-req.txt', pkg_lines)
    # Create a bundle in env.scratch_path/ test.pybundle
    result = run_pip('bundle', '-r', env.scratch_path/ 'bundle-req.txt', env.scratch_path/ 'test.pybundle')
    bundle = result.files_after.get(join('scratch', 'test.pybundle'), None)
    assert bundle is not None

    files = zipfile.ZipFile(bundle.full).namelist()
    assert 'src/FSPkg/' in files
    assert 'src/initools/' in files
    assert 'build/pip/' in files
Пример #9
0
 def sort_path(path):
     url = path_to_url2(path)
     if mimetypes.guess_type(url, strict=False)[0] == 'text/html':
         urls.append(url)
     else:
         files.append(url)
Пример #10
0
 def sort_path(path):
     url = path_to_url2(path)
     if mimetypes.guess_type(url, strict=False)[0] == 'text/html':
         urls.append(url)
     else:
         files.append(url)