def __init__(self, pkg_info): """ :param PackageInfo pkg_info: PKG-INFO, when available """ self.links_source = None self.install = self.get_requirements(True, pkg_info.requires_txt, "requirements.txt", "pinned.txt") self.test = self.get_requirements( False, "tests/requirements.txt", # Preferred "requirements-dev.txt", # Also accept other common variations "dev-requirements.txt", "test-requirements.txt", "requirements-test.txt", ) if pkg_info.dependency_links_txt: self.links_source = setupmeta.relative_path( pkg_info.dependency_links_txt) self.links = load_list(pkg_info.dependency_links_txt) else: self.links = [] self.add_links(self.install) self.add_links(self.test)
def parse_with_comments(self): # We're abstracting, allow comments to tweak how we do that current_section = None for line in load_list(self.source, comment=None): if line.startswith("#"): # Lines containing only a comment can start a "section", all requirements below this will respect that section word = first_word(line[1:]) if word in KNOWN_SECTIONS: current_section = word continue line_section = current_section note = None if "# " in line: # Trailing comments can direct us to treat that particular line in a certain way regarding pinning i = line.index("# ") word = first_word(line[i + 2:]) line = line[:i].strip() if word in KNOWN_SECTIONS: line_section = word note = "'%s' stated on line" % word if line_section == "indirect": # 'indirect' means the pinning was done to satisfy some indirect dependency, # but should not be considered as our project's dep self.ignored.append("%s # %s" % (line, note or "indirect section")) continue if (not line_section or line_section == "abstract") and "==" in line: # By default (or if in explicit 'abstract' section), trim away simple '==' pinning i = line.index("==") line = line[:i].strip() if not note: if line_section: note = "in '%s' section" % line_section else: note = "abstracted by default" self.abstracted.append("%s # %s" % (line, note)) elif line and (line[0].isalnum() or line.startswith("-e")): # Count as untouched only actual deps (ignore flags such as -i) if note: self.untouched.append("%s # %s" % (line, note)) else: self.untouched.append(line) if note: self.notes[line] = note or "abstract by default" self.reqs.append(line) if any(is_complex_requirement(line) for line in self.reqs): reqs, links = parse_requirements(self.reqs) if reqs: self.reqs = reqs self.links = links
def __init__(self, path): self.source = relative_path(path) self.reqs = load_list(path) self.links = None if any(self.is_complex_requirement(line) for line in self.reqs): reqs, links = self.parse_requirements(path) if reqs: self.reqs = reqs self.links = links
def auto_fill_classifiers(self): """ Add classifiers from classifiers.txt, if present """ # https://pypi.python.org/pypi?%3Aaction=list_classifiers self.add_definition("classifiers", load_list(CLASSIFIERS), CLASSIFIERS)
def auto_fill_classifiers(self): """ Add classifiers from classifiers.txt, if present """ # https://pypi.python.org/pypi?%3Aaction=list_classifiers classifiers = load_list('classifiers.txt') if classifiers: self.add_definition('classifiers', classifiers, 'classifiers.txt')