コード例 #1
0
    def upload_requirement(self, work_dir, req, python):
        dest_dir = self.get_file_dir(req.project_name).strip()
        if not os.path.exists(dest_dir):
            os.makedirs(dest_dir)

        def fetch_requirement(req, dest_dir, force_download):
            from setuptools.package_index import PackageIndex  # @Reimport
            from pkg_resources import working_set  # @Reimport  # NOQA
            i = PackageIndex()
            if force_download:
                [i.remove(i[req.key][0]) for _ in xrange(len(i[req.key]))]
                d = i.download(req, dest_dir)
            else:
                d = i.fetch_distribution(req, dest_dir, force_scan=True)
            d = getattr(d, 'location', d) if d else ''
            return (d if d else working_set.resolve([req])[0].location)
        with set_env(COVERAGE_DISABLE_WARNINGS="1"):
            fetched = run_in_subprocess(fetch_requirement, python=python, cd=self.workspace
                                        )(req, dest_dir, force_download=False)

            if not fetched or not os.path.exists(fetched):
                err_msg = "Unable to find requirement: %r\n%s" % (str(req), fetched)
                raise RuntimeError(err_msg)

            if os.path.isdir(fetched):
                fetched = self.create_egg_for_package(fetched, work_dir, python)

        print("Fetched %r" % fetched)
        return fetched
コード例 #2
0
ファイル: pyenv.py プロジェクト: pombredanne/pkglib
    def __enter__(self):
        if not self.dir:
            raise RuntimeError("Virtual environment does not exist or has "
                               "been deleted")

        self.log.info("Using virtual environment located at: %s" % self.dir)
        self.environ = cmdline.set_env(**self._make_env())
        self.environ.__enter__()
        return self
コード例 #3
0
ファイル: pyenv.py プロジェクト: agiledata/pkglib
    def __enter__(self):
        if not self.dir:
            raise RuntimeError("Virtual environment does not exist or has "
                               "been deleted")

        self.log.info("Using virtual environment located at: %s" % self.dir)
        self.environ = cmdline.set_env(**self._make_env())
        self.environ.__enter__()
        return self
コード例 #4
0
ファイル: pyenv.py プロジェクト: pombredanne/pkglib
 def _local_temp(self):
     tmp = reduce(lambda x, y: x if x else os.environ.get(y),
                  ["TMPDIR", "TEMP", "TMP"], None)
     if not tmp:
         old_tempdir = tempfile.tempdir
         tempfile.tempdir = tmp
         try:
             tmp = os.path.join(self.prefix, ".temp")
             with cmdline.set_env(TMPDIR=tmp):
                 yield tmp
         finally:
             tempfile.tempdir = old_tempdir
     else:
         yield tmp
コード例 #5
0
ファイル: pyenv.py プロジェクト: agiledata/pkglib
 def _local_temp(self):
     tmp = reduce(lambda x, y: x if x else os.environ.get(y),
                  ["TMPDIR", "TEMP", "TMP"], None)
     if not tmp:
         old_tempdir = tempfile.tempdir
         tempfile.tempdir = tmp
         try:
             tmp = os.path.join(self.prefix, ".temp")
             with cmdline.set_env(TMPDIR=tmp):
                 yield tmp
         finally:
             tempfile.tempdir = old_tempdir
     else:
         yield tmp