我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用pip.req.parse_requirements()。
def run(self, options, args): session = self._build_session(options) requirement_set = RequirementSet( build_dir=None, src_dir=None, download_dir=None, session=session, ) for name in args: requirement_set.add_requirement( InstallRequirement.from_line(name)) for filename in options.requirements: for req in parse_requirements(filename, options=options, session=session): requirement_set.add_requirement(req) if not requirement_set.has_requirements: raise InstallationError('You must give at least one requirement ' 'to %(name)s (see "pip help %(name)s")' % dict(name=self.name)) requirement_set.uninstall(auto_confirm=options.yes)
def run(self, options, args): with self._build_session(options) as session: format_control = pip.index.FormatControl(set(), set()) wheel_cache = WheelCache(options.cache_dir, format_control) requirement_set = RequirementSet( build_dir=None, src_dir=None, download_dir=None, isolated=options.isolated_mode, session=session, wheel_cache=wheel_cache, ) for name in args: requirement_set.add_requirement( InstallRequirement.from_line( name, isolated=options.isolated_mode, wheel_cache=wheel_cache ) ) for filename in options.requirements: for req in parse_requirements( filename, options=options, session=session, wheel_cache=wheel_cache): requirement_set.add_requirement(req) if not requirement_set.has_requirements: raise InstallationError( 'You must give at least one requirement to %(name)s (see ' '"pip help %(name)s")' % dict(name=self.name) ) requirement_set.uninstall(auto_confirm=options.yes)
def reqs(path): return [str(r.req) for r in parse_requirements(path, session=PipSession())]
def load_requirements(): """ Helps to avoid storing requirements in more than one file""" reqs = parse_requirements('requirements-to-freeze.txt', session=False) reqs_list = [str(ir.req) for ir in reqs] return reqs_list # Configure the package build and distribution # @see https://github.com/pypa/setuptools_scm # @see http://stackoverflow.com/questions/14399534/how-can-i-reference-requirements-txt-for-the-install-requires-kwarg-in-setuptool # NOQA # # To record the files created use: # python setup.py install --record files.txt
def read_requirements(): # parses requirements from requirements.txt reqs_path = os.path.join(__location__, 'requirements.txt') install_reqs = parse_requirements(reqs_path, session=PipSession()) reqs = [str(ir.req) for ir in install_reqs] return reqs
def get_requirements(source): install_reqs = parse_requirements(source, **parse_args) return set([str(ir.req) for ir in install_reqs])
def requirements(requirements_file='requirements.txt'): reqs_from_file = parse_requirements( os.path.join(os.path.dirname(__file__), requirements_file), session=False ) reqs = [] for r in reqs_from_file: if r.req: reqs.append(str(r.req)) # else: # reqs.append(str(r.link)) return reqs
def parse_requirements(f): return [str(r.req) for r in requirements(f, session=PipSession())] # Read requirements
def requirements(requirements_file): """Return package mentioned in the given file. Args: requirements_file (str): path to the requirements file to be parsed. Returns: (list): 3rd-party package dependencies contained in the file. """ return [ str(package.req) for package in parse_requirements( requirements_file, session=pip.download.PipSession())]
def fetch_requirements(requirements_file_path): """ Return a list of requirements and links by parsing the provided requirements file. """ links = [] reqs = [] for req in parse_requirements(requirements_file_path, session=False): if getattr(req, 'link', None): links.append(str(req.link)) reqs.append(str(req.req)) return (reqs, links)
def extract_requirements(filename): return [str(r.req) for r in parse_requirements(filename, session=PipSession)]
def get_requirements(): requirements = parse_requirements( 'requirements.txt', session=pip.download.PipSession() ) return [str(r.req) for r in list(requirements)]
def _requirements(self): requirements_txt = os.path.join(self.target_directory, 'requirements.txt') logger.debug(requirements_txt) if os.path.isfile(requirements_txt): requirements = parse_requirements(requirements_txt, session=False) self.requirements = [req.name.strip().lower() for req in requirements] logger.debug('requirements modules count: {count} ({modules})'.format(count=len(self.requirements), modules=','.join(self.requirements))) else: logger.debug('requirements.txt not found!') self.requirements = []