def install(args): """Install wheel files""" if not args.packages: print 'No packages have been provided on the command-line, doing nothing.' return if not args.install_dir: print >> sys.stderr, ('No destination directory specified, aborting. \n' 'Use the --install-dir option to specify it') return 2 install_list = get_install_list(args.packages) error_msgs = [d['error'] for d in install_list if 'error' in d and d['error']] if error_msgs: print >> sys.stderr, ('\n'.join(error_msgs)) print >> sys.stderr, 'Aborting (no packages installed)' return 1 try: package_paths = fetch_packages(install_list) except ValueError: print >> sys.stderr, 'Aborting (no packages installed)' return 1 if not os.path.isdir(args.install_dir): os.mkdir(args.install_dir) with util.Virtualenv() as venv: cmd = (['pip', 'install', '--no-index', '--target', args.install_dir] + package_paths) LOGGER.debug('Running %s', ' '.join(cmd)) venv.check_call(cmd)
def test_pack_bare_package(self): with util.Virtualenv(prefix='glyco-pack-test-') as venv: with util.temporary_directory( 'glyco-pack-test-output-') as tempdir: path = pack.pack_bare_package( venv, os.path.join(DATA_DIR, 'installed_package'), tempdir) self.assertTrue(path.startswith(tempdir))
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
def test_check_call_smoke(self): with util.Virtualenv(prefix='glyco-venv-test-') as venv: venv.check_call(['pip', '--version'])
def test_check_pip_works(self): with util.Virtualenv(prefix='glyco-venv-test-') as venv: output = venv.check_output(['pip', '--version']) # 'pip --version' prints the full path to pip itself: # example: "pip 1.5.4 from /usr/lib/python2.7/dist-packages (python 2.7)" self.assertTrue(venv._venvdir in output)
def test_check_venv_location(self): with util.Virtualenv(prefix='glyco-venv-test-') as venv: output = venv.check_output( ['python', '-c', 'import wheel; print wheel.__file__']) self.assertTrue(output.startswith(venv._venvdir))