def __init__(self, url): self.session = PipSession(cache=os.path.join(USER_CACHE_DIR, 'http')) self.finder = PackageFinder([], [url], session=self.session)
def finder(session): return PackageFinder([], [], session=session)
def run(self, options, args): # confirm requirements try: import wheel.bdist_wheel except ImportError: if sys.version_info < (3,): debian_package = 'python-wheel' else: debian_package = 'python3-wheel' raise CommandError("'pip wheel' requires the 'wheel' package. To fix this, run: sudo apt-get install %s" % debian_package) try: import pkg_resources except ImportError: raise CommandError( "'pip wheel' requires setuptools >= 0.8 for dist-info support." " To fix this, run: pip install --upgrade setuptools" ) else: if not hasattr(pkg_resources, 'DistInfoDistribution'): raise CommandError( "'pip wheel' requires setuptools >= 0.8 for dist-info " "support. To fix this, run: pip install --upgrade " "setuptools" ) index_urls = [options.index_url] + options.extra_index_urls if options.no_index: logger.notify('Ignoring indexes: %s' % ','.join(index_urls)) index_urls = [] if options.use_mirrors: logger.deprecated("1.7", "--use-mirrors has been deprecated and will be removed" " in the future. Explicit uses of --index-url and/or " "--extra-index-url is suggested.") if options.mirrors: logger.deprecated("1.7", "--mirrors has been deprecated and will be removed in " " the future. Explicit uses of --index-url and/or " "--extra-index-url is suggested.") index_urls += options.mirrors if options.build_dir: options.build_dir = os.path.abspath(options.build_dir) session = self._build_session(options) finder = PackageFinder(find_links=options.find_links, index_urls=index_urls, use_wheel=options.use_wheel, allow_external=options.allow_external, allow_unverified=options.allow_unverified, allow_all_external=options.allow_all_external, allow_all_prereleases=options.pre, process_dependency_links= options.process_dependency_links, session=session, ) build_delete = (not (options.no_clean or options.build_dir)) with BuildDirectory(options.build_dir, delete=build_delete) as build_dir: requirement_set = RequirementSet( build_dir=build_dir, src_dir=None, download_dir=None, download_cache=options.download_cache, ignore_dependencies=options.ignore_dependencies, ignore_installed=True, session=session, wheel_download_dir=options.wheel_dir ) # make the wheelhouse if not os.path.exists(options.wheel_dir): os.makedirs(options.wheel_dir) #parse args and/or requirements files for name in args: requirement_set.add_requirement( InstallRequirement.from_line(name, None)) for filename in options.requirements: for req in parse_requirements( filename, finder=finder, options=options, session=session): if req.editable: logger.notify("ignoring %s" % req.url) continue requirement_set.add_requirement(req) #fail if no requirements if not requirement_set.has_requirements: opts = {'name': self.name} msg = ('You must give at least one requirement ' 'to %(name)s (see "pip help %(name)s")' % opts) logger.error(msg) return try: #build wheels wb = WheelBuilder( requirement_set, finder, options.wheel_dir, build_options = options.build_options or [], global_options = options.global_options or [] ) wb.build() except PreviousBuildDirError: options.no_clean = True raise finally: if not options.no_clean: requirement_set.cleanup_files()
def test_link_sorting_raises_when_wheel_unsupported(self): links = [(parse_version('1.0'), Link('simple-1.0-py2.py3-none-TEST.whl'), '1.0')] finder = PackageFinder([], [], use_wheel=True) with pytest.raises(InstallationError): finder._sort_versions(links)
def pip_version_check(session, options): """Check for an update for pip. Limit the frequency of checks to once per week. State is stored either in the active virtualenv or in the user's USER_CACHE_DIR keyed off the prefix of the pip script path. """ installed_version = get_installed_version("pip") if not installed_version: return pip_version = packaging_version.parse(installed_version) pypi_version = None try: state = load_selfcheck_statefile() current_time = datetime.datetime.utcnow() # Determine if we need to refresh the state if "last_check" in state.state and "pypi_version" in state.state: last_check = datetime.datetime.strptime(state.state["last_check"], SELFCHECK_DATE_FMT) if (current_time - last_check).total_seconds() < 7 * 24 * 60 * 60: pypi_version = state.state["pypi_version"] # Refresh the version if we need to or just see if we need to warn if pypi_version is None: # Lets use PackageFinder to see what the latest pip version is finder = PackageFinder( find_links=options.find_links, index_urls=[options.index_url] + options.extra_index_urls, allow_all_prereleases=False, # Explicitly set to False trusted_hosts=options.trusted_hosts, process_dependency_links=options.process_dependency_links, session=session, ) all_candidates = finder.find_all_candidates("pip") if not all_candidates: return pypi_version = str( max(all_candidates, key=lambda c: c.version).version) # save that we've performed a check state.save(pypi_version, current_time) remote_version = packaging_version.parse(pypi_version) # Determine if our pypi_version is older if (pip_version < remote_version and pip_version.base_version != remote_version.base_version): # Advise "python -m pip" on Windows to avoid issues # with overwriting pip.exe. if WINDOWS: pip_cmd = "python -m pip" else: pip_cmd = "pip" logger.warning( "You are using pip version %s, however version %s is " "available.\nYou should consider upgrading via the " "'%s install --upgrade pip' command.", pip_version, pypi_version, pip_cmd) except Exception: logger.debug( "There was an error checking the latest version of pip", exc_info=True, )
'Django', ] if '{0.major}.{0.minor}'.format(sys.version_info) < '3.3': install_requires.append('mock') on_rtd = os.environ.get('READTHEDOCS', None) == 'True' if on_rtd: from pip.download import PipSession from pip.index import PackageFinder from pip.req import parse_requirements session = PipSession() root_dir = os.path.abspath(os.path.dirname(__file__)) requirements_path = os.path.join(root_dir, 'requirements', 'documentation.txt') finder = PackageFinder([], [], session=session) requirements = parse_requirements(requirements_path, finder, session=session) install_requires.extend([str(r.req) for r in requirements]) with codecs.open('README.rst', 'r', 'utf-8') as f: long_description = f.read() setup( name='yet-another-django-profiler', version=version, author='Jeremy Bowman', author_email='*****@*****.**', classifiers=[ 'Development Status :: 5 - Production/Stable',
def run(self, options, args): if not options.build_dir: options.build_dir = build_prefix if not options.src_dir: options.src_dir = src_prefix if options.download_dir: options.no_install = True options.ignore_installed = True options.build_dir = os.path.abspath(options.build_dir) options.src_dir = os.path.abspath(options.src_dir) install_options = options.install_options or [] index_urls = [options.index_url] + options.extra_index_urls if options.no_index: logger.notify('Ignoring indexes: %s' % ','.join(index_urls)) index_urls = [] finder = PackageFinder(find_links=options.find_links, index_urls=index_urls) requirement_set = RequirementSet( build_dir=options.build_dir, src_dir=options.src_dir, download_dir=options.download_dir, download_cache=options.download_cache, upgrade=options.upgrade, ignore_installed=options.ignore_installed, ignore_dependencies=options.ignore_dependencies) for name in args: requirement_set.add_requirement( InstallRequirement.from_line(name, None)) for name in options.editables: requirement_set.add_requirement( InstallRequirement.from_editable( name, default_vcs=options.default_vcs)) for filename in options.requirements: for req in parse_requirements(filename, finder=finder, options=options): requirement_set.add_requirement(req) if not options.no_download: requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle) else: requirement_set.locate_files() if not options.no_install and not self.bundle: requirement_set.install(install_options) installed = ' '.join( [req.name for req in requirement_set.successfully_installed]) if installed: logger.notify('Successfully installed %s' % installed) elif not self.bundle: downloaded = ' '.join( [req.name for req in requirement_set.successfully_downloaded]) if downloaded: logger.notify('Successfully downloaded %s' % downloaded) elif self.bundle: requirement_set.create_bundle(self.bundle_filename) logger.notify('Created bundle in %s' % self.bundle_filename) # Clean up if not options.no_install: requirement_set.cleanup_files(bundle=self.bundle) return requirement_set
def __init__(self, dirs=None, urls=None): self.finder = PackageFinder( find_links=dirs or [], index_urls=urls or [])
try: from pip.index import PackageFinder from pip.download import PipSession from pip.req import parse_requirements except ImportError: from pip._internal.index import PackageFinder from pip._internal.download import PipSession from pip._internal.req import parse_requirements from setuptools import setup, find_packages pip_session = PipSession() finder = PackageFinder(find_links=[], index_urls=[], session=pip_session) requirements = list( parse_requirements('requirements.txt', finder, session=pip_session)) install_requires = [str(r.req) for r in requirements] def get_version(): try: return open('version.txt').read().strip() except IOError: return '' setup( name='eduvisor', version=get_version() or '0.0-dev', packages=find_packages(exclude=('tests', 'tests.*')), scripts=[], install_requires=install_requires,
download_cache=None, upgrade=None, ignore_installed=None, ignore_dependencies=False, force_reinstall=None) class Opt: skip_requirements_regex = None for req in parse_requirements(args[0], options=Opt): requirement_set.add_requirement(req) finder = PackageFinder(find_links=[], index_urls=['http://pypi.python.org/simple/'], use_mirrors=True, mirrors=[]) requirement_set.prepare_files(finder) for first, later in investigate: later.check_if_exists() if later.satisfied_by: pass # print 'already satisfied by %s' % (later.satisfied_by) elif later.conflicts_with: print '%s conflicts with installed \033[31m%s\033[0m' % ( prettify(later), later.conflicts_with) else: if first.installed_version not in later.req: print '%s, but pip will install version \033[31m%s\033[0m from \033[33m%s\033[0m' % ( prettify(later), first.installed_version, first)
def test_find_all_versions_nothing(data): """Find nothing without anything""" finder = PackageFinder([], [], session=PipSession()) assert not finder._find_all_versions(InstallRequirement.from_line('pip'))
"the future. Pip now automatically uses and configures its " "cache.", RemovedInPip8Warning, ) if options.build_dir: options.build_dir = os.path.abspath(options.build_dir) with self._build_session(options) as session: finder = PackageFinder( find_links=options.find_links, index_urls=index_urls, use_wheel=options.use_wheel, allow_external=options.allow_external, allow_unverified=options.allow_unverified, allow_all_external=options.allow_all_external, allow_all_prereleases=options.pre, trusted_hosts=options.trusted_hosts, process_dependency_links=options.process_dependency_links, session=session, ) build_delete = (not (options.no_clean or options.build_dir)) with BuildDirectory(options.build_dir, delete=build_delete) as build_dir: requirement_set = RequirementSet( build_dir=build_dir, src_dir=options.src_dir, download_dir=None, ignore_dependencies=options.ignore_dependencies, ignore_installed=True,
def run(self, options, args): self.check_required_packages() cmdoptions.resolve_wheel_no_use_binary(options) cmdoptions.check_install_build_global(options) index_urls = [options.index_url] + options.extra_index_urls if options.no_index: logger.info('Ignoring indexes: %s', ','.join(index_urls)) index_urls = [] if options.download_cache: warnings.warn( "--download-cache has been deprecated and will be removed in " "the future. Pip now automatically uses and configures its " "cache.", RemovedInPip8Warning, ) if options.build_dir: options.build_dir = os.path.abspath(options.build_dir) with self._build_session(options) as session: finder = PackageFinder( find_links=options.find_links, format_control=options.format_control, index_urls=index_urls, allow_external=options.allow_external, allow_unverified=options.allow_unverified, allow_all_external=options.allow_all_external, allow_all_prereleases=options.pre, trusted_hosts=options.trusted_hosts, process_dependency_links=options.process_dependency_links, session=session, ) build_delete = (not (options.no_clean or options.build_dir)) wheel_cache = WheelCache(options.cache_dir, options.format_control) with BuildDirectory(options.build_dir, delete=build_delete) as build_dir: requirement_set = RequirementSet( build_dir=build_dir, src_dir=options.src_dir, download_dir=None, ignore_dependencies=options.ignore_dependencies, ignore_installed=True, isolated=options.isolated_mode, session=session, wheel_cache=wheel_cache, wheel_download_dir=options.wheel_dir) self.populate_requirement_set(requirement_set, args, options, finder, session, self.name, wheel_cache) if not requirement_set.has_requirements: return try: # build wheels wb = WheelBuilder( requirement_set, finder, build_options=options.build_options or [], global_options=options.global_options or [], ) if not wb.build(): raise CommandError( "Failed to build one or more wheels") except PreviousBuildDirError: options.no_clean = True raise finally: if not options.no_clean: requirement_set.cleanup_files()
def __init__(self, cache_directory, use_wheel=False): self.cache_directory = cache_directory self.finder = PackageFinder([], ["http://pypi.python.org/simple"], use_wheel=use_wheel)
def run(self, options, args): # confirm requirements try: import wheel.bdist_wheel # Hack to make flake8 not complain about an unused import wheel.bdist_wheel except ImportError: raise CommandError( "'pip wheel' requires the 'wheel' package. To fix this, run: " "pip install wheel") try: import pkg_resources except ImportError: raise CommandError( "'pip wheel' requires setuptools >= 0.8 for dist-info support." " To fix this, run: pip install --upgrade setuptools") else: if not hasattr(pkg_resources, 'DistInfoDistribution'): raise CommandError( "'pip wheel' requires setuptools >= 0.8 for dist-info " "support. To fix this, run: pip install --upgrade " "setuptools") index_urls = [options.index_url] + options.extra_index_urls if options.no_index: logger.notify('Ignoring indexes: %s' % ','.join(index_urls)) index_urls = [] if options.use_mirrors: logger.deprecated( "1.7", "--use-mirrors has been deprecated and will be removed" " in the future. Explicit uses of --index-url and/or " "--extra-index-url is suggested.") if options.mirrors: logger.deprecated( "1.7", "--mirrors has been deprecated and will be removed in " " the future. Explicit uses of --index-url and/or " "--extra-index-url is suggested.") index_urls += options.mirrors if options.download_cache: logger.deprecated( "1.8", "--download-cache has been deprecated and will be removed in " " the future. Pip now automatically uses and configures its " "cache.") session = self._build_session(options) finder = PackageFinder( find_links=options.find_links, index_urls=index_urls, use_wheel=options.use_wheel, allow_external=options.allow_external, allow_unverified=options.allow_unverified, allow_all_external=options.allow_all_external, allow_all_prereleases=options.pre, session=session, ) options.build_dir = os.path.abspath(options.build_dir) requirement_set = RequirementSet( build_dir=options.build_dir, src_dir=options.src_dir, download_dir=None, ignore_dependencies=options.ignore_dependencies, ignore_installed=True, session=session, wheel_download_dir=options.wheel_dir) # make the wheelhouse if not os.path.exists(options.wheel_dir): os.makedirs(options.wheel_dir) # parse args and/or requirements files for name in args: requirement_set.add_requirement( InstallRequirement.from_line(name, None)) for name in options.editables: requirement_set.add_requirement( InstallRequirement.from_editable( name, default_vcs=options.default_vcs)) for filename in options.requirements: for req in parse_requirements(filename, finder=finder, options=options, session=session): requirement_set.add_requirement(req) # fail if no requirements if not requirement_set.has_requirements: opts = {'name': self.name} msg = ('You must give at least one requirement ' 'to %(name)s (see "pip help %(name)s")' % opts) logger.error(msg) return try: # build wheels wb = WheelBuilder( requirement_set, finder, options.wheel_dir, build_options=options.build_options or [], global_options=options.global_options or [], ) if not wb.build(): raise CommandError("Failed to build one or more wheels") except PreviousBuildDirError: options.no_clean = True raise finally: if not options.no_clean: requirement_set.cleanup_files()
def test_tilde(data): """Finder can accept a path with ~ in it and will normalize it.""" finder = PackageFinder(['~/python-pkgs'], [], session=PipSession()) req = InstallRequirement.from_line("gmpy") with pytest.raises(DistributionNotFound): finder.find_requirement(req, False)
def test_finder_priority_file_over_page(): """Test PackageFinder prefers file links over equivalent page links""" req = InstallRequirement.from_line('gmpy==1.15', None) finder = PackageFinder([find_links], ["http://pypi.python.org/simple"]) link = finder.find_requirement(req, False) assert link.url.startswith("file://")
def test_incorrect_case_file_index(data): """Test PackageFinder detects latest using wrong case""" req = InstallRequirement.from_line('dinner', None) finder = PackageFinder([], [data.find_links3], session=PipSession()) link = finder.find_requirement(req, False) assert link.url.endswith("Dinner-2.0.tar.gz")
def main(): ap = argparse.ArgumentParser() ap.add_argument("requirements", nargs="*", help="The requirement specifier, syntax is the same as for pip") ap.add_argument('-r', '--requirement', help="The requirements.txt file to parse (default requirements.txt)", dest="files", action="append", default=[]) ap.add_argument('-f', '--find-links', help="Looks for the archives at the url or a directory", dest="find_links", action="append", default=[]) ap.add_argument('--extra-index-url', help="Extra URLs for package indexes", dest="index_urls", action="append", default=['https://pypi.python.org/simple/']) ap.add_argument('-o', '--output', default=None, help="Write generated environment to file") options = ap.parse_args() if not options.requirements and not options.files: options.files = ['requirements.txt'] all_req = [] finder = PackageFinder( find_links=options.find_links, index_urls=options.index_urls, use_wheel=False, ) for r in options.requirements: all_req.append(InstallRequirement.from_line(r)) for f in options.files: print("F", f) all_req.extend(parse_requirements(f, finder=finder)) if options.output: envname = os.path.splitext(os.path.basename(options.output))[0] else: envname = 'unnamed' with (open(options.output, 'wt') if options.output else sys.stdout) as out: out.write('{pkgs, ' 'fetchurl ? pkgs.fetchurl, ' 'python ? pkgs.python, pythonPackages ? pkgs.pythonPackages, ' 'myEnvFun ? pkgs.myEnvFun}:\n') out.write('let\n') all_names = [] for req in all_req: link = finder.find_requirement(req, True) prefix, _ext = link.splitext() name = req.name.lower() version = finder._egg_info_matches(prefix, name, link) if link.hash_name: hash = link.hash hash_name = link.hash_name else: hash_name = 'sha256' stdout, _stderr = subprocess.Popen(['nix-prefetch-url', '--type', hash_name, link.url_without_fragment], stdout=subprocess.PIPE, ).communicate() hash = stdout.decode('ascii').strip() all_names.append(name) out.write('{} = pythonPackages.buildPythonPackage {{\n' .format(name)) out.write(' name = "{}-{}";\n'.format(name, version)) out.write(' src = fetchurl {\n') out.write(' url = "{}";\n'.format(link.url_without_fragment)) out.write(' {} = "{}";\n'.format(hash_name, hash)) out.write(' };\n') out.write('};\n') out.write('in myEnvFun {\n') out.write(' name = "{}";\n'.format(envname)) out.write(' buildInputs = [\n') for name in all_names: out.write(' {}\n'.format(name)) out.write(' ];\n') out.write('}') sys.stderr.write(""" Done. Now you can add the following to the ~/.nixpkgs/config.nix: packageOverrides = pkgs: rec {{ {name} = import ./{name}.nix {{ inherit pkgs; python = pkgs.python{pyver}; # Or whatever version you prefer pythonPackages = pkgs.python{pyver}Packages; }}; }} Then run: nix-env -i env-{name} load-env-{name} """.format(name=envname, pyver='{0.major}{0.minor}'.format(sys.version_info)))
def test_find_all_versions_nothing(data): """Find nothing without anything""" finder = PackageFinder([], [], session=PipSession()) assert not finder._find_all_versions('pip')
def run(self, options, args): self.check_required_packages() index_urls = [options.index_url] + options.extra_index_urls if options.no_index: logger.info('Ignoring indexes: %s', ','.join(index_urls)) index_urls = [] if options.use_mirrors: warnings.warn( "--use-mirrors has been deprecated and will be removed in the " "future. Explicit uses of --index-url and/or --extra-index-url" " is suggested.", RemovedInPip7Warning, ) if options.mirrors: warnings.warn( "--mirrors has been deprecated and will be removed in the " "future. Explicit uses of --index-url and/or --extra-index-url" " is suggested.", RemovedInPip7Warning, ) index_urls += options.mirrors if options.download_cache: warnings.warn( "--download-cache has been deprecated and will be removed in " "the future. Pip now automatically uses and configures its " "cache.", RemovedInPip8Warning, ) if options.build_dir: options.build_dir = os.path.abspath(options.build_dir) with self._build_session(options) as session: finder = PackageFinder( find_links=options.find_links, index_urls=index_urls, use_wheel=options.use_wheel, allow_external=options.allow_external, allow_unverified=options.allow_unverified, allow_all_external=options.allow_all_external, allow_all_prereleases=options.pre, trusted_hosts=options.trusted_hosts, process_dependency_links=options.process_dependency_links, session=session, ) build_delete = (not (options.no_clean or options.build_dir)) with BuildDirectory(options.build_dir, delete=build_delete) as build_dir: requirement_set = RequirementSet( build_dir=build_dir, src_dir=options.src_dir, download_dir=None, ignore_dependencies=options.ignore_dependencies, ignore_installed=True, isolated=options.isolated_mode, session=session, wheel_download_dir=options.wheel_dir) # make the wheelhouse options.wheel_dir = normalize_path(options.wheel_dir) if not os.path.exists(options.wheel_dir): os.makedirs(options.wheel_dir) # parse args and/or requirements files for name in args: requirement_set.add_requirement( InstallRequirement.from_line( name, None, isolated=options.isolated_mode, )) for name in options.editables: requirement_set.add_requirement( InstallRequirement.from_editable( name, default_vcs=options.default_vcs, isolated=options.isolated_mode, )) for filename in options.requirements: for req in parse_requirements(filename, finder=finder, options=options, session=session): requirement_set.add_requirement(req) # fail if no requirements if not requirement_set.has_requirements: logger.error( "You must give at least one requirement to %s " "(see \"pip help %s\")", self.name, self.name, ) return try: # build wheels wb = WheelBuilder( requirement_set, finder, options.wheel_dir, build_options=options.build_options or [], global_options=options.global_options or [], ) if not wb.build(): raise CommandError( "Failed to build one or more wheels") except PreviousBuildDirError: options.no_clean = True raise finally: if not options.no_clean: requirement_set.cleanup_files()
def test_find_all_versions_find_links(data): finder = PackageFinder( [data.find_links], [], session=PipSession()) versions = finder._find_all_versions('simple') assert [str(v.version) for v in versions] == ['3.0', '2.0', '1.0']
def setup(self): self.version = '1.0' self.parsed_version = parse_version(self.version) self.search_name = 'pytest' self.finder = PackageFinder([], [], use_wheel=True)
def test_find_all_versions_index(data): finder = PackageFinder( [], [data.index_url('simple')], session=PipSession()) versions = finder._find_all_versions('simple') assert [str(v.version) for v in versions] == ['1.0']
def test_finder_detects_latest_find_links(data): """Test PackageFinder detects latest using find-links""" req = InstallRequirement.from_line('simple', None) finder = PackageFinder([data.find_links], [], session=PipSession()) link = finder.find_requirement(req, False) assert link.url.endswith("simple-3.0.tar.gz")
def test_find_all_versions_find_links_and_index(data): finder = PackageFinder( [data.find_links], [data.index_url('simple')], session=PipSession()) versions = finder._find_all_versions('simple') # first the find-links versions then the page versions assert [str(v.version) for v in versions] == ['3.0', '2.0', '1.0', '1.0']
gLogger.notice( "Requesting installation of %s" % ", ".join(["%s%s" % (reqName, reqDict[reqName][0]) for reqName in reqDict])) from pip.index import PackageFinder from pip.req import InstallRequirement, RequirementSet from pip.locations import build_prefix, src_prefix requirement_set = RequirementSet(build_dir=build_prefix, src_dir=src_prefix, download_dir=None) for reqName in reqDict: requirement_set.add_requirement( InstallRequirement.from_line("%s%s" % (reqName, reqDict[reqName][0]), None)) install_options = [] global_options = [] finder = PackageFinder(find_links=[], index_urls=["http://pypi.python.org/simple/"]) requirement_set.prepare_files(finder, force_root_egg_info=False, bundle=False) requirement_set.locate_files() requirement_set.install(install_options, global_options) gLogger.notice("Installed %s" % "".join( [str(package.name) for package in requirement_set.successfully_installed]))
def run(self, options, args): # confirm requirements try: import wheel.bdist_wheel except ImportError: raise CommandError("'pip wheel' requires bdist_wheel from the 'wheel' distribution.") if not wheel_setuptools_support(): raise CommandError("'pip wheel' requires %s." % setuptools_requirement) index_urls = [options.index_url] + options.extra_index_urls if options.no_index: logger.notify('Ignoring indexes: %s' % ','.join(index_urls)) index_urls = [] finder = PackageFinder(find_links=options.find_links, index_urls=index_urls, use_mirrors=options.use_mirrors, mirrors=options.mirrors, use_wheel=options.use_wheel, allow_external=options.allow_external, allow_insecure=options.allow_insecure, allow_all_external=options.allow_all_external, allow_all_insecure=options.allow_all_insecure, allow_all_prereleases=options.pre, ) options.build_dir = os.path.abspath(options.build_dir) requirement_set = RequirementSet( build_dir=options.build_dir, src_dir=None, download_dir=None, download_cache=options.download_cache, ignore_dependencies=options.ignore_dependencies, ignore_installed=True) #parse args and/or requirements files for name in args: if name.endswith(".whl"): logger.notify("ignoring %s" % name) continue requirement_set.add_requirement( InstallRequirement.from_line(name, None)) for filename in options.requirements: for req in parse_requirements(filename, finder=finder, options=options): if req.editable or (req.name is None and req.url.endswith(".whl")): logger.notify("ignoring %s" % req.url) continue requirement_set.add_requirement(req) #fail if no requirements if not requirement_set.has_requirements: opts = {'name': self.name} msg = ('You must give at least one requirement ' 'to %(name)s (see "pip help %(name)s")' % opts) logger.error(msg) return try: #build wheels wb = WheelBuilder( requirement_set, finder, options.wheel_dir, build_options = options.build_options or [], global_options = options.global_options or [] ) wb.build() except PreviousBuildDirError: return finally: if not options.no_clean: requirement_set.cleanup_files()
def test_secure_origin(location, trusted, expected): finder = PackageFinder([], [], session=[], trusted_hosts=trusted) logger = MockLogger() finder._validate_secure_origin(logger, location) assert logger.called == expected
def get_finder() -> PackageFinder: return PackageFinder([], ['https://pypi.python.org/simple'], session=requests.Session())