當前位置: 首頁>>代碼示例>>Python>>正文


Python build_clib.build_clib方法代碼示例

本文整理匯總了Python中distutils.command.build_clib.build_clib方法的典型用法代碼示例。如果您正苦於以下問題:Python build_clib.build_clib方法的具體用法?Python build_clib.build_clib怎麽用?Python build_clib.build_clib使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在distutils.command.build_clib的用法示例。


在下文中一共展示了build_clib.build_clib方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_get_source_files

# 需要導入模塊: from distutils.command import build_clib [as 別名]
# 或者: from distutils.command.build_clib import build_clib [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:IronLanguages,項目名稱:ironpython2,代碼行數:23,代碼來源:test_build_clib.py

示例2: test_build_libraries

# 需要導入模塊: from distutils.command import build_clib [as 別名]
# 或者: from distutils.command.build_clib import build_clib [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

示例3: test_build_libraries

# 需要導入模塊: from distutils.command import build_clib [as 別名]
# 或者: from distutils.command.build_clib import build_clib [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

示例4: test_run

# 需要導入模塊: from distutils.command import build_clib [as 別名]
# 或者: from distutils.command.build_clib import build_clib [as 別名]
def test_run(self):
        pkg_dir, dist = self.create_dist()
        cmd = build_clib(dist)

        foo_c = os.path.join(pkg_dir, 'foo.c')
        self.write_file(foo_c, 'int main(void) { return 1;}\n')
        cmd.libraries = [('foo', {'sources': [foo_c]})]

        build_temp = os.path.join(pkg_dir, 'build')
        os.mkdir(build_temp)
        cmd.build_temp = build_temp
        cmd.build_clib = build_temp

        # Before we run the command, we want to make sure
        # all commands are present on the system.
        ccmd = missing_compiler_executable()
        if ccmd is not None:
            self.skipTest('The %r command is not found' % ccmd)

        # this should work
        cmd.run()

        # let's check the result
        self.assertIn('libfoo.a', os.listdir(build_temp)) 
開發者ID:CedricGuillemet,項目名稱:Imogen,代碼行數:26,代碼來源:test_build_clib.py

示例5: test_check_library_dist

# 需要導入模塊: from distutils.command import build_clib [as 別名]
# 或者: from distutils.command.build_clib import build_clib [as 別名]
def test_check_library_dist(self):
        pkg_dir, dist = self.create_dist()
        cmd = build_clib(dist)

        # 'libraries' option must be a list
        self.assertRaises(DistutilsSetupError, cmd.check_library_list, 'foo')

        # each element of 'libraries' must a 2-tuple
        self.assertRaises(DistutilsSetupError, cmd.check_library_list,
                          ['foo1', 'foo2'])

        # first element of each tuple in 'libraries'
        # must be a string (the library name)
        self.assertRaises(DistutilsSetupError, cmd.check_library_list,
                          [(1, 'foo1'), ('name', 'foo2')])

        # library name may not contain directory separators
        self.assertRaises(DistutilsSetupError, cmd.check_library_list,
                          [('name', 'foo1'),
                           ('another/name', 'foo2')])

        # second element of each tuple must be a dictionary (build info)
        self.assertRaises(DistutilsSetupError, cmd.check_library_list,
                          [('name', {}),
                           ('another', 'foo2')])

        # those work
        libs = [('name', {}), ('name', {'ok': 'good'})]
        cmd.check_library_list(libs) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:31,代碼來源:test_build_clib.py


注:本文中的distutils.command.build_clib.build_clib方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。