Exemplo n.º 1
0
    def rendered(self):
        """String representation"""
        result = ["Dependency tree:"]
        seen = set()

        if self.install_requires:
            self.render_section(result, seen, "install_requires", self.install_requires.value)

        if self.extras_require and self.extras_require.value:
            for name, value in self.extras_require.value.items():
                self.render_section(result, seen, "extras_require[%s]" % name, value)

        other = set(self.packages.values()) - seen
        if other:
            other = sorted(p.key for p in other if not p.required_by)
            self.render_section(result, seen, "other", other)

        if self.conflicts:
            result.append("\n%s conflicts: %s" % (len(self.conflicts), setupmeta.represented_args(self.conflicts, separator=", ")))

        if self.cycles:
            result.append("\n%s cycles found:" % len(self.cycles))
            for c in sorted(self.cycles.values()):
                result.append(setupmeta.represented_args(c, separator=" -> "))

        if len(result) < 2:
            result.append("- no dependencies -")

        return "\n".join(result)
Exemplo n.º 2
0
    def run_command(self, message, *args):
        if not self.commit:
            print("Would %s: %s" % (message, setupmeta.represented_args(args)))
            return

        first, _, rest = message.partition(" ")
        first = "%s%s" % (first[0].upper(), first[1:])
        message = "%sing %s..." % (first, rest)
        print(message)
        setupmeta.run_program(*args, fatal=True)
Exemplo n.º 3
0
    def __init__(self, ws, definitions):
        self.packages = dict((d.key, PipPackage(self, d)) for d in ws)
        self.setup = definitions.get("setup_requires")
        self.install_requires = definitions.get("install_requires")
        self.extras_require = definitions.get("extras_require")
        self.conflicts = set()
        self.cycles = {}

        for p in sorted(self.packages.values()):
            p.resolve()
            self.conflicts.update(r.key for r in p.requires if r.is_conflicting)

        for p in sorted(self.packages.values()):
            p.resolve_transitive()
            if p.cycle:
                key = setupmeta.represented_args(sorted(p.cycle))
                if key not in self.cycles:
                    self.cycles[key] = [p] + p.cycle
Exemplo n.º 4
0
def run_program(program, *args, **kwargs):
    capture = kwargs.pop("capture", True)
    fatal = kwargs.pop("fatal", True)
    represented = "%s %s" % (program, setupmeta.represented_args(args))
    print("Running: %s" % represented)
    if not setupmeta.WINDOWS and "PYCHARM_HOSTED" in os.environ and "python" in program and args and args[
            0].startswith("-m"):
        # Temporary workaround for https://youtrack.jetbrains.com/issue/PY-40692
        wrapper = os.path.join(os.path.dirname(__file__), "pydev-wrapper.sh")
        args = [wrapper, program] + list(args)
        program = "/bin/sh"

    output = setupmeta.run_program(program,
                                   *args,
                                   capture=capture,
                                   fatal=fatal,
                                   **kwargs)
    if output and capture:
        print("output:")
        print(output)

    return output