Beispiel #1
0
    def setup_py_path(self):

        try:
            content_file = self._repo.repo.get_contents(path='setup.py',
                                                        ref=self.commit.sha)
        except UnknownObjectException:
            raise exceptions.SetupPyNotFoundException(
                repo=self._repo.repo.full_name)

        setup_py_file = os.path.join(tempfile.mkdtemp(), 'setup.py')

        with open(setup_py_file, 'w') as stream:
            stream.write(content_file.decoded_content.decode('utf-8'))

        return setup_py_file
Beispiel #2
0
    def _setup_py_argument(self, argument):

        if not os.path.exists(self._setup_py_path):
            err = exceptions.SetupPyNotFoundException(repo=self._repo_location)

        else:
            self._debug('Reading {} from setup.py...'.format(argument))
            value = self._setup_py.get(argument)
            if value is None:
                err = exceptions.MissingSetupPyArgumentException(
                    repo=self._repo_location, argument=argument)
            else:
                return value

        raise exceptions.FailedDetectingPackageMetadataException(
            argument=argument, reason=err)
Beispiel #3
0
 def _binary(*_, **__):
     raise exceptions.FailedDetectingPackageMetadataException(
         argument='entry_points',
         reason=exceptions.SetupPyNotFoundException(repo=repo_path))
Beispiel #4
0
    def wheel(self, universal=False, wheel_version=None):
        """
        Create a wheel package.

        This method will create a wheel package, according the the regular python wheel standards.

        Under the hood, this uses the bdist_wheel command provided by the wheel project.

        For more information please visit https://pythonwheels.com/

        Args:
            universal (:bool, optional): True if the created will should be universal, False otherwise.
            wheel_version (:str, optional): Which wheel version to use.

        Raises:
            WheelExistsException: Destination file already exists.
            DirectoryDoesntExistException: Destination directory does not exist.

        """

        temp_dir = tempfile.mkdtemp()
        try:

            dist_dir = os.path.join(temp_dir, 'dist')
            bdist_dir = os.path.join(temp_dir, 'bdist')

            if not os.path.exists(self._setup_py_path):
                raise exceptions.SetupPyNotFoundException(
                    repo=self._repo_location)

            name = self._name

            with self._create_virtualenv(name) as virtualenv:

                self._logger.debug('Installing wheel...')

                pip_path = utils.get_python_executable('pip',
                                                       exec_home=virtualenv)
                self._runner.run('{} wheel=={}'.format(
                    self._pip_install(pip_path), wheel_version
                    or DEFAULT_WHEEL_VERSION),
                                 cwd=self._repo_dir)

                command = '{} {} bdist_wheel --bdist-dir {} --dist-dir {}'.format(
                    utils.get_python_executable('python',
                                                exec_home=virtualenv),
                    self._setup_py_path, bdist_dir, dist_dir)

                if universal:
                    command = '{0} --universal'.format(command)

                self._debug('Running bdist_wheel...', universal=universal)

                self._runner.run(command, cwd=self._repo_dir)

            self._debug('Finished running bdist_wheel.', universal=universal)

            actual_name = utils.lsf(dist_dir)[0]

            destination = os.path.join(self._target_dir, actual_name)

            try:
                utils.validate_file_does_not_exist(path=destination)
            except exceptions.FileExistException as e:
                raise exceptions.WheelExistsException(path=e.path)

            shutil.copy(os.path.join(dist_dir, actual_name), destination)
            self._debug('Packaged successfully.', package=destination)
            return os.path.abspath(destination)

        finally:
            utils.rmf(temp_dir)
Beispiel #5
0
    def _nsis(*_, **__):

        raise exceptions.FailedDetectingPackageMetadataException(
            argument='something',
            reason=exceptions.SetupPyNotFoundException(repo=repo_path))
Beispiel #6
0
 def _wheel(**__):
     raise exceptions.SetupPyNotFoundException(repo=repo_path)