How to use the pyp2rpm.exceptions.VirtualenvFailException function in pyp2rpm

To help you get started, we’ve selected a few pyp2rpm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fedora-python / pyp2rpm / pyp2rpm / metadata_extractors.py View on Github external
def inner(self):
        data = extraction_fce(self)
        if virtualenv is None or not self.venv:
            logger.debug("Skipping virtualenv metadata extraction.")
            return data

        temp_dir = tempfile.mkdtemp()
        try:
            extractor = virtualenv.VirtualEnv(self.local_file, self.version,
                                              temp_dir,
                                              self.name_convertor,
                                              self.base_python_version)
            data.set_from(extractor.get_venv_data, update=True)
        except exc.VirtualenvFailException as e:
            logger.error("{}, skipping virtualenv metadata extraction.".format(
                e))
        finally:
            shutil.rmtree(temp_dir)
        return data
    return inner
github fedora-python / pyp2rpm / pyp2rpm / virtualenv.py View on Github external
def get_dirs_differance(self):
        '''
        Makes final versions of site_packages and scripts using DirsContent
        sub method and filters
        '''
        try:
            diff = self.dirs_after_install - self.dirs_before_install
        except ValueError:
            raise VirtualenvFailException(
                "Some of the DirsContent attributes is uninicialized")
        self.data['has_pth'] = \
            any([x for x in diff.lib_sitepackages if x.endswith('.pth')])

        site_packages = site_packages_filter(diff.lib_sitepackages)
        self.data['packages'] = sorted(
            [p for p in site_packages if not p.endswith(MODULE_SUFFIXES)])
        self.data['py_modules'] = sorted(set(
            [os.path.splitext(m)[0] for m in site_packages - set(
                self.data['packages'])]))
        self.data['scripts'] = scripts_filter(sorted(diff.bindir))
        logger.debug('Data from files differance in virtualenv:')
        logger.debug(pprint.pformat(self.data))
github fedora-python / pyp2rpm / pyp2rpm / virtualenv.py View on Github external
def install_package_to_venv(self):
        '''
        Installs package given as first argument to virtualenv without
        dependencies
        '''
        try:
            self.env.install((self.name, self.version), force=True,
                             options=["--no-deps"])
        except (ve.PackageInstallationException,
                ve.VirtualenvReadonlyException):
            raise VirtualenvFailException(
                'Failed to install package to virtualenv')
        self.dirs_after_install.fill(self.temp_dir + '/venv/')
github fedora-python / pyp2rpm / pyp2rpm / virtualenv.py View on Github external
def __init__(self, name, version, temp_dir, name_convertor,
                 base_python_version):
        self.name = name
        self.version = version
        self.temp_dir = temp_dir
        self.name_convertor = name_convertor
        if not base_python_version:
            base_python_version = DEFAULT_PYTHON_VERSION
        python_version = 'python' + base_python_version
        self.env = VirtualEnvironment(temp_dir + '/venv',
                                      python=python_version)
        try:
            self.env.open_or_create()
        except (ve.VirtualenvCreationException,
                ve.VirtualenvReadonlyException):
            raise VirtualenvFailException('Failed to create virtualenv')
        self.dirs_before_install = DirsContent()
        self.dirs_after_install = DirsContent()
        self.dirs_before_install.fill(temp_dir + '/venv/')
        self.data = {}