Ejemplo n.º 1
0
 def test_wheel_supported_true(self, mock_get_distribution):
     """
     Test wheel_supported returns true, when setuptools is installed and requirement is met
     """
     mock_get_distribution.return_value = pkg_resources.Distribution(
         project_name='setuptools', version='0.9')
     assert wheel.wheel_setuptools_support()
Ejemplo n.º 2
0
 def test_wheel_supported_false_req_fail(self, mock_get_distribution):
     """
     Test wheel_supported returns false, when setuptools is installed, but req is not met
     """
     mock_get_distribution.return_value = pkg_resources.Distribution(
         project_name='setuptools', version='0.7')
     assert not wheel.wheel_setuptools_support()
Ejemplo n.º 3
0
 def test_wheel_supported_false_req_fail(self, mock_get_distribution):
     """
     Test wheel_supported returns false, when setuptools is installed, but req is not met
     """
     mock_get_distribution.return_value = pkg_resources.Distribution(project_name='setuptools', version='0.7')
     assert not wheel.wheel_setuptools_support()
Ejemplo n.º 4
0
 def test_wheel_supported_false_no_install(self, mock_get_distribution):
     """
     Test wheel_supported returns false, when setuptools not installed
     """
     mock_get_distribution.side_effect = self.raise_not_found
     assert not wheel.wheel_setuptools_support()
Ejemplo n.º 5
0
 def test_wheel_supported_true(self, mock_get_distribution):
     """
     Test wheel_supported returns true, when setuptools is installed and requirement is met
     """
     mock_get_distribution.return_value = pkg_resources.Distribution(project_name='setuptools', version='0.9')
     assert wheel.wheel_setuptools_support()
Ejemplo n.º 6
0
    def run(self, options, args):

        # confirm requirements
        try:
            import wheel.bdist_wheel
        except ImportError:
            raise CommandError("'pip wheel' requires the 'wheel' package. To fix this, run:  pip install wheel")
        if not wheel_setuptools_support():
            raise CommandError("'pip wheel' requires setuptools>=0.8. To fix this, run: pip install --upgrade setuptools")

        index_urls = [options.index_url] + options.extra_index_urls
        if options.no_index:
            logger.notify('Ignoring indexes: %s' % ','.join(index_urls))
            index_urls = []

        if options.use_mirrors:
            logger.deprecated("1.7",
                        "--use-mirrors has been deprecated and will be removed"
                        " in the future. Explicit uses of --index-url and/or "
                        "--extra-index-url is suggested.")

        if options.mirrors:
            logger.deprecated("1.7",
                        "--mirrors has been deprecated and will be removed in "
                        " the future. Explicit uses of --index-url and/or "
                        "--extra-index-url is suggested.")
            index_urls += options.mirrors

        session = self._build_session(options)

        finder = PackageFinder(find_links=options.find_links,
                               index_urls=index_urls,
                               use_wheel=options.use_wheel,
                               allow_external=options.allow_external,
                               allow_unverified=options.allow_unverified,
                               allow_all_external=options.allow_all_external,
                               allow_all_prereleases=options.pre,
                               process_dependency_links=
                                options.process_dependency_links,
                               session=session,
                            )

        options.build_dir = os.path.abspath(options.build_dir)
        requirement_set = RequirementSet(
            build_dir=options.build_dir,
            src_dir=None,
            download_dir=None,
            download_cache=options.download_cache,
            ignore_dependencies=options.ignore_dependencies,
            ignore_installed=True,
            session=session,
        )

        #parse args and/or requirements files
        for name in args:
            if name.endswith(".whl"):
                logger.notify("ignoring %s" % name)
                continue
            requirement_set.add_requirement(
                InstallRequirement.from_line(name, None))

        for filename in options.requirements:
            for req in parse_requirements(filename, finder=finder, options=options, session=session):
                if req.editable or (req.name is None and req.url.endswith(".whl")):
                    logger.notify("ignoring %s" % req.url)
                    continue
                requirement_set.add_requirement(req)

        #fail if no requirements
        if not requirement_set.has_requirements:
            opts = {'name': self.name}
            msg = ('You must give at least one requirement '
                   'to %(name)s (see "pip help %(name)s")' % opts)
            logger.error(msg)
            return

        try:
            #build wheels
            wb = WheelBuilder(
                requirement_set,
                finder,
                options.wheel_dir,
                build_options = options.build_options or [],
                global_options = options.global_options or []
                )
            wb.build()
        except PreviousBuildDirError:
            options.no_clean = True
            raise
        finally:
            if not options.no_clean:
                requirement_set.cleanup_files()
Ejemplo n.º 7
0
 def test_wheel_supported_false_no_install(self, monkeypatch):
     """
     Test wheel_supported returns false, when setuptools not installed or does not meet the requirement
     """
     monkeypatch.delattr('pkg_resources.DistInfoDistribution')
     assert not wheel.wheel_setuptools_support()
Ejemplo n.º 8
0
 def test_wheel_supported_true(self, monkeypatch):
     """
     Test wheel_supported returns true, when setuptools is installed and requirement is met
     """
     monkeypatch.setattr('pkg_resources.DistInfoDistribution', True)
     assert wheel.wheel_setuptools_support()
Ejemplo n.º 9
0
 def use_wheel(self, value):
     self._use_wheel = value
     if self._use_wheel and not wheel_setuptools_support():
         raise InstallationError("pip's wheel support requires %s." % setuptools_requirement)
Ejemplo n.º 10
0
    def run(self, options, args):

        # confirm requirements
        try:
            import wheel.bdist_wheel
        except ImportError:
            raise CommandError("'pip wheel' requires bdist_wheel from the 'wheel' distribution.")
        if not wheel_setuptools_support():
            raise CommandError("'pip wheel' requires %s." % setuptools_requirement)

        index_urls = [options.index_url] + options.extra_index_urls
        if options.no_index:
            logger.notify('Ignoring indexes: %s' % ','.join(index_urls))
            index_urls = []

        finder = PackageFinder(find_links=options.find_links,
                               index_urls=index_urls,
                               use_mirrors=options.use_mirrors,
                               mirrors=options.mirrors,
                               use_wheel=options.use_wheel,
                               allow_external=options.allow_external,
                               allow_insecure=options.allow_insecure,
                               allow_all_external=options.allow_all_external,
                               allow_all_insecure=options.allow_all_insecure,
                               allow_all_prereleases=options.pre,
                            )

        options.build_dir = os.path.abspath(options.build_dir)
        requirement_set = RequirementSet(
            build_dir=options.build_dir,
            src_dir=None,
            download_dir=None,
            download_cache=options.download_cache,
            ignore_dependencies=options.ignore_dependencies,
            ignore_installed=True)

        #parse args and/or requirements files
        for name in args:
            if name.endswith(".whl"):
                logger.notify("ignoring %s" % name)
                continue
            requirement_set.add_requirement(
                InstallRequirement.from_line(name, None))

        for filename in options.requirements:
            for req in parse_requirements(filename, finder=finder, options=options):
                if req.editable or (req.name is None and req.url.endswith(".whl")):
                    logger.notify("ignoring %s" % req.url)
                    continue
                requirement_set.add_requirement(req)

        #fail if no requirements
        if not requirement_set.has_requirements:
            opts = {'name': self.name}
            msg = ('You must give at least one requirement '
                   'to %(name)s (see "pip help %(name)s")' % opts)
            logger.error(msg)
            return

        try:
            #build wheels
            wb = WheelBuilder(
                requirement_set,
                finder,
                options.wheel_dir,
                build_options = options.build_options or [],
                global_options = options.global_options or []
                )
            wb.build()
        except PreviousBuildDirError:
            return
        finally:
            if not options.no_clean:
                requirement_set.cleanup_files()
Ejemplo n.º 11
0
 def test_wheel_supported_false_no_install(self, mock_get_distribution):
     """
     Test wheel_supported returns false, when setuptools not installed
     """
     mock_get_distribution.side_effect = self.raise_not_found
     assert not wheel.wheel_setuptools_support()
Ejemplo n.º 12
0
 def use_wheel(self, value):
     self._use_wheel = value
     if self._use_wheel and not wheel_setuptools_support():
         raise InstallationError("pip's wheel support requires %s." %
                                 setuptools_requirement)
Ejemplo n.º 13
0
 def use_wheel(self, value):
     self._use_wheel = value
     if self._use_wheel and not wheel_setuptools_support():
         raise InstallationError("pip's wheel support requires setuptools >= 0.8 for dist-info support.")
Ejemplo n.º 14
0
 def use_wheel(self, value):
     self._use_wheel = value
     if self._use_wheel and not wheel_setuptools_support():
         raise InstallationError(
             "pip's wheel support requires setuptools >= 0.8 for dist-info support."
         )
Ejemplo n.º 15
0
    def run(self, options, args):

        # confirm requirements
        try:
            import wheel.bdist_wheel
        except ImportError:
            raise CommandError(
                "'pip wheel' requires the 'wheel' package. To fix this, run:  pip install wheel"
            )
        if not wheel_setuptools_support():
            raise CommandError(
                "'pip wheel' requires setuptools>=0.8. To fix this, run: pip install --upgrade setuptools"
            )

        index_urls = [options.index_url] + options.extra_index_urls
        if options.no_index:
            logger.notify('Ignoring indexes: %s' % ','.join(index_urls))
            index_urls = []

        if options.use_mirrors:
            logger.deprecated(
                "1.7", "--use-mirrors has been deprecated and will be removed"
                " in the future. Explicit uses of --index-url and/or "
                "--extra-index-url is suggested.")

        if options.mirrors:
            logger.deprecated(
                "1.7", "--mirrors has been deprecated and will be removed in "
                " the future. Explicit uses of --index-url and/or "
                "--extra-index-url is suggested.")
            index_urls += options.mirrors

        session = self._build_session(options)

        finder = PackageFinder(
            find_links=options.find_links,
            index_urls=index_urls,
            use_wheel=options.use_wheel,
            allow_external=options.allow_external,
            allow_unverified=options.allow_unverified,
            allow_all_external=options.allow_all_external,
            allow_all_prereleases=options.pre,
            process_dependency_links=options.process_dependency_links,
            session=session,
        )

        options.build_dir = os.path.abspath(options.build_dir)
        requirement_set = RequirementSet(
            build_dir=options.build_dir,
            src_dir=None,
            download_dir=None,
            download_cache=options.download_cache,
            ignore_dependencies=options.ignore_dependencies,
            ignore_installed=True,
            session=session,
        )

        #parse args and/or requirements files
        for name in args:
            if name.endswith(".whl"):
                logger.notify("ignoring %s" % name)
                continue
            requirement_set.add_requirement(
                InstallRequirement.from_line(name, None))

        for filename in options.requirements:
            for req in parse_requirements(filename,
                                          finder=finder,
                                          options=options,
                                          session=session):
                if req.editable or (req.name is None
                                    and req.url.endswith(".whl")):
                    logger.notify("ignoring %s" % req.url)
                    continue
                requirement_set.add_requirement(req)

        #fail if no requirements
        if not requirement_set.has_requirements:
            opts = {'name': self.name}
            msg = ('You must give at least one requirement '
                   'to %(name)s (see "pip help %(name)s")' % opts)
            logger.error(msg)
            return

        try:
            #build wheels
            wb = WheelBuilder(requirement_set,
                              finder,
                              options.wheel_dir,
                              build_options=options.build_options or [],
                              global_options=options.global_options or [])
            wb.build()
        except PreviousBuildDirError:
            options.no_clean = True
            raise
        finally:
            if not options.no_clean:
                requirement_set.cleanup_files()