<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def install(self, req, editable=False, sources=[]):
 """Install a package into the virtualenv :param req: A requirement to install :type req: :class:`requirementslib.models.requirement.Requirement` :param bool editable: Whether the requirement is editable, defaults to False :param list sources: A list of pip sources to consult, defaults to [] :return: A return code, 0 if successful :rtype: int """


        try:
            packagebuilder = self.safe_import("packagebuilder")
        except ImportError:
            packagebuilder = None
        with self.activated(include_extras=False):
            if not packagebuilder:
                return 2
            ireq = req.as_ireq()
            sources = self.filter_sources(req, sources)
            cache_dir = os.environ.get('PASSA_CACHE_DIR',
                os.environ.get(
                    'PIPENV_CACHE_DIR',
                    vistir.path.create_tracked_tempdir(prefix="passabuild")
                )
            )
            built = packagebuilder.build.build(ireq, sources, cache_dir)
            if isinstance(built, distlib.wheel.Wheel):
                maker = distlib.scripts.ScriptMaker(None, None)
                built.install(self.paths, maker)
            else:
                path = vistir.compat.Path(built.path)
                cd_path = path.parent
                setup_py = cd_path.joinpath("setup.py")
                return self.setuptools_install(
                    cd_path.as_posix(), req.name, setup_py.as_posix(),
                    editable=req.editable
                )
            return 0