# Path: poet/locations.py
# CACHE_DIR = user_cache_dir('pypoet')
# 
# Path: poet/package/pip_dependency.py
# class PipDependency(Dependency):
# 
#     def __init__(self, name, constraint, category='main', checksum=None):
#         # Normalizing name for easier dependencies resolving
#         name = canonicalize_name(name)
# 
#         super(PipDependency, self).__init__(name, constraint, category=category)
# 
#         self._checksum = checksum
# 
#     @property
#     def checksum(self):
#         return self._checksum
# 
#     @property
#     def normalized_name(self):
#         normalized_name = self._name
#         normalized_constraint = self.normalized_constraint
# 
#         if normalized_constraint:
#             if self.is_vcs_dependency():
#                 normalized_name = normalized_constraint
#             else:
#                 normalized_name += normalized_constraint
# 
#         return normalized_name
# 
#     def as_requirement(self):
#         if self.is_vcs_dependency():
#             return InstallRequirement.from_editable(self.normalized_name)
# 
#         return InstallRequirement.from_line(self.normalized_name)
# 
#     def _normalize_vcs_constraint(self, constraint):
#         if 'git' in constraint:
#             repo = constraint['git']
#             if 'branch' in constraint:
#                 revision = constraint['branch']
#             elif 'tag' in constraint:
#                 revision = constraint['tag']
#             elif 'rev' in constraint:
#                 revision = constraint['rev']
#             else:
#                 revision = 'master'
# 
#             if not repo.startswith('git+'):
#                 repo = 'git+' + repo
# 
#             return '{}@{}#egg={}'.format(repo, revision, self._name)
# 
#         raise ValueError('Unsupported VCS.')
# 
# Path: poet/utils/helpers.py
# def call(args):
#     """
#     Calls a command and return the output.
#     
#     :param args: The command args.
#     :type args: list
#     
#     :rtype: str 
#     """
#     output = subprocess.check_output(args, stderr=subprocess.STDOUT)
# 
#     if PY3K:
#         return decode(output)
# 
#     return output
# 
# def template(name):
#     """
#     Returns a template given a name.
#     
#     :param name: The name of the template.
#     :type name: str
#     
#     :rtype: jinja2.Template 
#     """
#     if not name.endswith('.jinja2'):
#         name += '.jinja2'
# 
#     return TEMPLATE_ENV.get_template(name)


import tempfile
import os
import shutil
import subprocess
from packaging.utils import canonicalize_name
from pip.download import unpack_url
from pip.index import Link
from piptools.resolver import Resolver
from piptools.repositories import PyPIRepository
from piptools.scripts.compile import get_pip_command
from piptools.cache import DependencyCache
from piptools.utils import is_pinned_requirement, key_from_req
from .locations import CACHE_DIR
from .package.pip_dependency import PipDependency
from .utils.helpers import call, template
        if name not in reversed_dependencies:
            # Main dependency
            for dep in deps:
                if name == dep.name:
                    for p in dep.python:
                        pythons.add(str(p))

                    break

            if not len(pythons):
                pythons.add('*')

            return pythons

        parents = reversed_dependencies[name]

        for parent in parents:
            parent_pythons = self._get_pythons_for_package(
                parent, reversed_dependencies, deps
            )

            pythons = pythons.union(parent_pythons)

        if not len(pythons):
            pythons.add('*')

        return pythons

    def _call(self, cmd, error_message):
        try:

# Path: poet/locations.py
# CACHE_DIR = user_cache_dir('pypoet')
# 
# Path: poet/package/pip_dependency.py
# class PipDependency(Dependency):
# 
#     def __init__(self, name, constraint, category='main', checksum=None):
#         # Normalizing name for easier dependencies resolving
#         name = canonicalize_name(name)
# 
#         super(PipDependency, self).__init__(name, constraint, category=category)
# 
#         self._checksum = checksum
# 
#     @property
#     def checksum(self):
#         return self._checksum
# 
#     @property
#     def normalized_name(self):
#         normalized_name = self._name
#         normalized_constraint = self.normalized_constraint
# 
#         if normalized_constraint:
#             if self.is_vcs_dependency():
#                 normalized_name = normalized_constraint
#             else:
#                 normalized_name += normalized_constraint
# 
#         return normalized_name
# 
#     def as_requirement(self):
#         if self.is_vcs_dependency():
#             return InstallRequirement.from_editable(self.normalized_name)
# 
#         return InstallRequirement.from_line(self.normalized_name)
# 
#     def _normalize_vcs_constraint(self, constraint):
#         if 'git' in constraint:
#             repo = constraint['git']
#             if 'branch' in constraint:
#                 revision = constraint['branch']
#             elif 'tag' in constraint:
#                 revision = constraint['tag']
#             elif 'rev' in constraint:
#                 revision = constraint['rev']
#             else:
#                 revision = 'master'
# 
#             if not repo.startswith('git+'):
#                 repo = 'git+' + repo
# 
#             return '{}@{}#egg={}'.format(repo, revision, self._name)
# 
#         raise ValueError('Unsupported VCS.')
# 
# Path: poet/utils/helpers.py
# def call(args):
#     """
#     Calls a command and return the output.
#     
#     :param args: The command args.
#     :type args: list
#     
#     :rtype: str 
#     """
#     output = subprocess.check_output(args, stderr=subprocess.STDOUT)
# 
#     if PY3K:
#         return decode(output)
# 
#     return output
# 
# def template(name):
#     """
#     Returns a template given a name.
#     
#     :param name: The name of the template.
#     :type name: str
#     
#     :rtype: jinja2.Template 
#     """
#     if not name.endswith('.jinja2'):
#         name += '.jinja2'
# 
#     return TEMPLATE_ENV.get_template(name)


# Path: poet/installer.py
import tempfile
import os
import shutil
import subprocess
from packaging.utils import canonicalize_name
from pip.download import unpack_url
from pip.index import Link
from piptools.resolver import Resolver
from piptools.repositories import PyPIRepository
from piptools.scripts.compile import get_pip_command
from piptools.cache import DependencyCache
from piptools.utils import is_pinned_requirement, key_from_req
from .locations import CACHE_DIR
from .package.pip_dependency import PipDependency
from .utils.helpers import call, template

        if name not in reversed_dependencies:
            # Main dependency
            for dep in deps:
                if name == dep.name:
                    for p in dep.python:
                        pythons.add(str(p))

                    break

            if not len(pythons):
                pythons.add('*')

            return pythons

        parents = reversed_dependencies[name]

        for parent in parents:
            parent_pythons = self._get_pythons_for_package(
                parent, reversed_dependencies, deps
            )

            pythons = pythons.union(parent_pythons)

        if not len(pythons):
            pythons.add('*')

        return pythons

    def _call(self, cmd, error_message):
        try:

            return call(cmd)