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
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()
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)
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()
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
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
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)
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
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)