当前位置: 首页>>代码示例>>Python>>正文


Python errors.DistutilsSetupError方法代码示例

本文整理汇总了Python中distutils.errors.DistutilsSetupError方法的典型用法代码示例。如果您正苦于以下问题:Python errors.DistutilsSetupError方法的具体用法?Python errors.DistutilsSetupError怎么用?Python errors.DistutilsSetupError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在distutils.errors的用法示例。


在下文中一共展示了errors.DistutilsSetupError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: validate_line_list

# 需要导入模块: from distutils import errors [as 别名]
# 或者: from distutils.errors import DistutilsSetupError [as 别名]
def validate_line_list(dist, attr, value):
    """
    Validate that the value is compatible
    """

    # does not work as reliably in Python 2.
    if isinstance(value, str):
        value = value.split()
    value = list(value)

    try:
        check = (' '.join(value)).split()
        if check == value:
            return True
    except Exception:
        pass
    raise DistutilsSetupError("%r must be a list of valid identifiers" % attr) 
开发者ID:calmjs,项目名称:calmjs,代码行数:19,代码来源:dist.py

示例2: test_check_restructuredtext

# 需要导入模块: from distutils import errors [as 别名]
# 或者: from distutils.errors import DistutilsSetupError [as 别名]
def test_check_restructuredtext(self):
        # let's see if it detects broken rest in long_description
        broken_rest = 'title\n===\n\ntest'
        pkg_info, dist = self.create_dist(long_description=broken_rest)
        cmd = check(dist)
        cmd.check_restructuredtext()
        self.assertEqual(cmd._warnings, 1)

        # let's see if we have an error with strict=1
        metadata = {'url': 'xxx', 'author': 'xxx',
                    'author_email': 'xxx',
                    'name': 'xxx', 'version': 'xxx',
                    'long_description': broken_rest}
        self.assertRaises(DistutilsSetupError, self._run, metadata,
                          **{'strict': 1, 'restructuredtext': 1})

        # and non-broken rest, including a non-ASCII character to test #12114
        metadata['long_description'] = u'title\n=====\n\ntest \u00df'
        cmd = self._run(metadata, strict=1, restructuredtext=1)
        self.assertEqual(cmd._warnings, 0)

        # check that includes work to test #31292
        metadata['long_description'] = 'title\n=====\n\n.. include:: includetest.rst'
        cmd = self._run(metadata, cwd=HERE, strict=1, restructuredtext=1)
        self.assertEqual(cmd._warnings, 0) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:27,代码来源:test_check.py

示例3: test_build_libraries

# 需要导入模块: from distutils import errors [as 别名]
# 或者: from distutils.errors import DistutilsSetupError [as 别名]
def test_build_libraries(self):

        pkg_dir, dist = self.create_dist()
        cmd = build_clib(dist)
        class FakeCompiler:
            def compile(*args, **kw):
                pass
            create_static_lib = compile

        cmd.compiler = FakeCompiler()

        # build_libraries is also doing a bit of typo checking
        lib = [('name', {'sources': 'notvalid'})]
        self.assertRaises(DistutilsSetupError, cmd.build_libraries, lib)

        lib = [('name', {'sources': list()})]
        cmd.build_libraries(lib)

        lib = [('name', {'sources': tuple()})]
        cmd.build_libraries(lib) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:22,代码来源:test_build_clib.py

示例4: test_check_metadata

# 需要导入模块: from distutils import errors [as 别名]
# 或者: from distutils.errors import DistutilsSetupError [as 别名]
def test_check_metadata(self):
        # let's run the command with no metadata at all
        # by default, check is checking the metadata
        # should have some warnings
        cmd = self._run()
        self.assertEqual(cmd._warnings, 2)

        # now let's add the required fields
        # and run it again, to make sure we don't get
        # any warning anymore
        metadata = {'url': 'xxx', 'author': 'xxx',
                    'author_email': 'xxx',
                    'name': 'xxx', 'version': 'xxx'}
        cmd = self._run(metadata)
        self.assertEqual(cmd._warnings, 0)

        # now with the strict mode, we should
        # get an error if there are missing metadata
        self.assertRaises(DistutilsSetupError, self._run, {}, **{'strict': 1})

        # and of course, no error when all metadata are present
        cmd = self._run(metadata, strict=1)
        self.assertEqual(cmd._warnings, 0) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:25,代码来源:test_check.py

示例5: test_check_restructuredtext

# 需要导入模块: from distutils import errors [as 别名]
# 或者: from distutils.errors import DistutilsSetupError [as 别名]
def test_check_restructuredtext(self):
        if not HAS_DOCUTILS: # won't test without docutils
            return
        # let's see if it detects broken rest in long_description
        broken_rest = 'title\n===\n\ntest'
        pkg_info, dist = self.create_dist(long_description=broken_rest)
        cmd = check(dist)
        cmd.check_restructuredtext()
        self.assertEqual(cmd._warnings, 1)

        # let's see if we have an error with strict=1
        metadata = {'url': 'xxx', 'author': 'xxx',
                    'author_email': 'xxx',
                    'name': 'xxx', 'version': 'xxx',
                    'long_description': broken_rest}
        self.assertRaises(DistutilsSetupError, self._run, metadata,
                          **{'strict': 1, 'restructuredtext': 1})

        # and non-broken rest
        metadata['long_description'] = 'title\n=====\n\ntest'
        cmd = self._run(metadata, strict=1, restructuredtext=1)
        self.assertEqual(cmd._warnings, 0) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:24,代码来源:test_check.py

示例6: test_get_source_files

# 需要导入模块: from distutils import errors [as 别名]
# 或者: from distutils.errors import DistutilsSetupError [as 别名]
def test_get_source_files(self):
        pkg_dir, dist = self.create_dist()
        cmd = build_clib(dist)

        # "in 'libraries' option 'sources' must be present and must be
        # a list of source filenames
        cmd.libraries = [('name', {})]
        self.assertRaises(DistutilsSetupError, cmd.get_source_files)

        cmd.libraries = [('name', {'sources': 1})]
        self.assertRaises(DistutilsSetupError, cmd.get_source_files)

        cmd.libraries = [('name', {'sources': ['a', 'b']})]
        self.assertEqual(cmd.get_source_files(), ['a', 'b'])

        cmd.libraries = [('name', {'sources': ('a', 'b')})]
        self.assertEqual(cmd.get_source_files(), ['a', 'b'])

        cmd.libraries = [('name', {'sources': ('a', 'b')}),
                         ('name2', {'sources': ['c', 'd']})]
        self.assertEqual(cmd.get_source_files(), ['a', 'b', 'c', 'd']) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:23,代码来源:test_build_clib.py

示例7: test_build_libraries

# 需要导入模块: from distutils import errors [as 别名]
# 或者: from distutils.errors import DistutilsSetupError [as 别名]
def test_build_libraries(self):

        pkg_dir, dist = self.create_dist()
        cmd = build_clib(dist)
        class FakeCompiler:
            def compile(*args, **kw):
                pass
            create_static_lib = compile

        cmd.compiler = FakeCompiler()

        # build_libraries is also doing a bit of typoe checking
        lib = [('name', {'sources': 'notvalid'})]
        self.assertRaises(DistutilsSetupError, cmd.build_libraries, lib)

        lib = [('name', {'sources': list()})]
        cmd.build_libraries(lib)

        lib = [('name', {'sources': tuple()})]
        cmd.build_libraries(lib) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:22,代码来源:test_build_clib.py

示例8: test_check_restructuredtext

# 需要导入模块: from distutils import errors [as 别名]
# 或者: from distutils.errors import DistutilsSetupError [as 别名]
def test_check_restructuredtext(self):
        # let's see if it detects broken rest in long_description
        broken_rest = 'title\n===\n\ntest'
        pkg_info, dist = self.create_dist(long_description=broken_rest)
        cmd = check(dist)
        cmd.check_restructuredtext()
        self.assertEqual(cmd._warnings, 1)

        # let's see if we have an error with strict=1
        metadata = {'url': 'xxx', 'author': 'xxx',
                    'author_email': 'xxx',
                    'name': 'xxx', 'version': 'xxx',
                    'long_description': broken_rest}
        self.assertRaises(DistutilsSetupError, self._run, metadata,
                          **{'strict': 1, 'restructuredtext': 1})

        # and non-broken rest, including a non-ASCII character to test #12114
        metadata['long_description'] = u'title\n=====\n\ntest \u00df'
        cmd = self._run(metadata, strict=1, restructuredtext=1)
        self.assertEqual(cmd._warnings, 0) 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:22,代码来源:test_check.py

示例9: validate_json_field

# 需要导入模块: from distutils import errors [as 别名]
# 或者: from distutils.errors import DistutilsSetupError [as 别名]
def validate_json_field(dist, attr, value):
    """
    Check for json validity.
    """

    try:
        is_json_compat(value)
    except ValueError as e:
        raise DistutilsSetupError("%r %s" % (attr, e))

    return True 
开发者ID:calmjs,项目名称:calmjs,代码行数:13,代码来源:dist.py

示例10: test_validate_json_field_bad

# 需要导入模块: from distutils import errors [as 别名]
# 或者: from distutils.errors import DistutilsSetupError [as 别名]
def test_validate_json_field_bad(self):
        with self.assertRaises(DistutilsSetupError) as e:
            calmjs_dist.validate_json_field(
                self.dist, self.optname, "{},")

        self.assertTrue(str(e.exception).startswith(
            "'default_json' JSON decoding error:"
        )) 
开发者ID:calmjs,项目名称:calmjs,代码行数:10,代码来源:test_dist.py

示例11: test_validate_line_list_bad

# 需要导入模块: from distutils import errors [as 别名]
# 或者: from distutils.errors import DistutilsSetupError [as 别名]
def test_validate_line_list_bad(self):
        with self.assertRaises(DistutilsSetupError) as e:
            calmjs_dist.validate_line_list(self.dist, 'items', [
                'in valid', 'value'])
        self.assertTrue(str(e.exception).startswith(
            "'items' must be a list of valid identifiers"))

        with self.assertRaises(DistutilsSetupError) as e:
            calmjs_dist.validate_line_list(self.dist, 'items', [
                'this', object()])

        with self.assertRaises(DistutilsSetupError) as e:
            calmjs_dist.validate_line_list(self.dist, 'items', [
                'this', object()]) 
开发者ID:calmjs,项目名称:calmjs,代码行数:16,代码来源:test_dist.py

示例12: gen_header

# 需要导入模块: from distutils import errors [as 别名]
# 或者: from distutils.errors import DistutilsSetupError [as 别名]
def gen_header(self):
        epm = EntryPoint.parse_map(self.distribution.entry_points or '')
        ep = epm.get('setuptools.installation', {}).get('eggsecutable')
        if ep is None:
            return 'w'  # not an eggsecutable, do it the usual way.

        if not ep.attrs or ep.extras:
            raise DistutilsSetupError(
                "eggsecutable entry point (%r) cannot have 'extras' "
                "or refer to a module" % (ep,)
            )

        pyver = sys.version[:3]
        pkg = ep.module_name
        full = '.'.join(ep.attrs)
        base = ep.attrs[0]
        basename = os.path.basename(self.egg_output)

        header = (
            "#!/bin/sh\n"
            'if [ `basename $0` = "%(basename)s" ]\n'
            'then exec python%(pyver)s -c "'
            "import sys, os; sys.path.insert(0, os.path.abspath('$0')); "
            "from %(pkg)s import %(base)s; sys.exit(%(full)s())"
            '" "$@"\n'
            'else\n'
            '  echo $0 is not the correct name for this egg file.\n'
            '  echo Please rename it back to %(basename)s and try again.\n'
            '  exec false\n'
            'fi\n'
        ) % locals()

        if not self.dry_run:
            mkpath(os.path.dirname(self.egg_output), dry_run=self.dry_run)
            f = open(self.egg_output, 'w')
            f.write(header)
            f.close()
        return 'a' 
开发者ID:jpush,项目名称:jbox,代码行数:40,代码来源:bdist_egg.py

示例13: assert_relative

# 需要导入模块: from distutils import errors [as 别名]
# 或者: from distutils.errors import DistutilsSetupError [as 别名]
def assert_relative(path):
    if not os.path.isabs(path):
        return path
    from distutils.errors import DistutilsSetupError

    msg = textwrap.dedent("""
        Error: setup script specifies an absolute path:

            %s

        setup() arguments must *always* be /-separated paths relative to the
        setup.py directory, *never* absolute paths.
        """).lstrip() % path
    raise DistutilsSetupError(msg) 
开发者ID:jpush,项目名称:jbox,代码行数:16,代码来源:build_py.py

示例14: check_library_list

# 需要导入模块: from distutils import errors [as 别名]
# 或者: from distutils.errors import DistutilsSetupError [as 别名]
def check_library_list(self, libraries):
        """Ensure that the list of libraries is valid.

        `library` is presumably provided as a command option 'libraries'.
        This method checks that it is a list of 2-tuples, where the tuples
        are (library_name, build_info_dict).

        Raise DistutilsSetupError if the structure is invalid anywhere;
        just returns otherwise.
        """
        if not isinstance(libraries, list):
            raise DistutilsSetupError, \
                  "'libraries' option must be a list of tuples"

        for lib in libraries:
            if not isinstance(lib, tuple) and len(lib) != 2:
                raise DistutilsSetupError, \
                      "each element of 'libraries' must a 2-tuple"

            name, build_info = lib

            if not isinstance(name, str):
                raise DistutilsSetupError, \
                      "first element of each tuple in 'libraries' " + \
                      "must be a string (the library name)"
            if '/' in name or (os.sep != '/' and os.sep in name):
                raise DistutilsSetupError, \
                      ("bad library name '%s': " +
                       "may not contain directory separators") % \
                      lib[0]

            if not isinstance(build_info, dict):
                raise DistutilsSetupError, \
                      "second element of each tuple in 'libraries' " + \
                      "must be a dictionary (build info)" 
开发者ID:glmcdona,项目名称:meddle,代码行数:37,代码来源:build_clib.py

示例15: get_source_files

# 需要导入模块: from distutils import errors [as 别名]
# 或者: from distutils.errors import DistutilsSetupError [as 别名]
def get_source_files(self):
        self.check_library_list(self.libraries)
        filenames = []
        for (lib_name, build_info) in self.libraries:
            sources = build_info.get('sources')
            if sources is None or not isinstance(sources, (list, tuple)):
                raise DistutilsSetupError, \
                      ("in 'libraries' option (library '%s'), "
                       "'sources' must be present and must be "
                       "a list of source filenames") % lib_name

            filenames.extend(sources)
        return filenames 
开发者ID:glmcdona,项目名称:meddle,代码行数:15,代码来源:build_clib.py


注:本文中的distutils.errors.DistutilsSetupError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。