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


Python install_data.install_data方法代码示例

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


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

示例1: finalize_options

# 需要导入模块: from distutils.command import install_data [as 别名]
# 或者: from distutils.command.install_data import install_data [as 别名]
def finalize_options(self):
        self.set_undefined_options('install',
            ('install_lib', 'install_dir')
        )
        install_data.install_data.finalize_options(self) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:7,代码来源:dist.py

示例2: warn

# 需要导入模块: from distutils.command import install_data [as 别名]
# 或者: from distutils.command.install_data import install_data [as 别名]
def warn (self, msg):
        sys.stderr.write ("warning: %s: %s\n" %
                          ("install_data", msg)) 
开发者ID:00nanhai,项目名称:captchacker2,代码行数:5,代码来源:my_install_data.py

示例3: test_simple_run

# 需要导入模块: from distutils.command import install_data [as 别名]
# 或者: from distutils.command.install_data import install_data [as 别名]
def test_simple_run(self):
        pkg_dir, dist = self.create_dist()
        cmd = install_data(dist)
        cmd.install_dir = inst = os.path.join(pkg_dir, 'inst')

        # data_files can contain
        #  - simple files
        #  - a tuple with a path, and a list of file
        one = os.path.join(pkg_dir, 'one')
        self.write_file(one, 'xxx')
        inst2 = os.path.join(pkg_dir, 'inst2')
        two = os.path.join(pkg_dir, 'two')
        self.write_file(two, 'xxx')

        cmd.data_files = [one, (inst2, [two])]
        self.assertEqual(cmd.get_inputs(), [one, (inst2, [two])])

        # let's run the command
        cmd.ensure_finalized()
        cmd.run()

        # let's check the result
        self.assertEqual(len(cmd.get_outputs()), 2)
        rtwo = os.path.split(two)[-1]
        self.assertTrue(os.path.exists(os.path.join(inst2, rtwo)))
        rone = os.path.split(one)[-1]
        self.assertTrue(os.path.exists(os.path.join(inst, rone)))
        cmd.outfiles = []

        # let's try with warn_dir one
        cmd.warn_dir = 1
        cmd.ensure_finalized()
        cmd.run()

        # let's check the result
        self.assertEqual(len(cmd.get_outputs()), 2)
        self.assertTrue(os.path.exists(os.path.join(inst2, rtwo)))
        self.assertTrue(os.path.exists(os.path.join(inst, rone)))
        cmd.outfiles = []

        # now using root and empty dir
        cmd.root = os.path.join(pkg_dir, 'root')
        inst3 = os.path.join(cmd.install_dir, 'inst3')
        inst4 = os.path.join(pkg_dir, 'inst4')
        three = os.path.join(cmd.install_dir, 'three')
        self.write_file(three, 'xx')
        cmd.data_files = [one, (inst2, [two]),
                          ('inst3', [three]),
                          (inst4, [])]
        cmd.ensure_finalized()
        cmd.run()

        # let's check the result
        self.assertEqual(len(cmd.get_outputs()), 4)
        self.assertTrue(os.path.exists(os.path.join(inst2, rtwo)))
        self.assertTrue(os.path.exists(os.path.join(inst, rone))) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:58,代码来源:test_install_data.py

示例4: run

# 需要导入模块: from distutils.command import install_data [as 别名]
# 或者: from distutils.command.install_data import install_data [as 别名]
def run(self):
        """
        Copy libraries from the bin directory and place them as appropriate
        """

        self.announce("Moving library files", level=3)

        # We have already built the libraries in the previous build_ext step

        self.skip_build = True

        bin_dir = self.distribution.bin_dir

        libs = [os.path.join(bin_dir, _lib) for _lib in 
                os.listdir(bin_dir) if 
                os.path.isfile(os.path.join(bin_dir, _lib)) and 
                os.path.splitext(_lib)[1] in [".dll", ".so"]
                and not (_lib.startswith("python") or _lib.startswith("bpy"))]

        for lib in libs:

            shutil.move(lib, os.path.join(self.build_dir,
                                          os.path.basename(lib)))

        # Mark the libs for installation, adding them to 
        # distribution.data_files seems to ensure that setuptools' record 
        # writer appends them to installed-files.txt in the package's egg-info
        #
        # Also tried adding the libraries to the distribution.libraries list, 
        # but that never seemed to add them to the installed-files.txt in the 
        # egg-info, and the online recommendation seems to be adding libraries 
        # into eager_resources in the call to setup(), which I think puts them 
        # in data_files anyways. 
        # 
        # What is the best way?

        self.distribution.data_files = [os.path.join(self.install_dir, 
                                                     os.path.basename(lib))
                                        for lib in libs]

        # Must be forced to run after adding the libs to data_files

        self.distribution.run_command("install_data")

        super().run() 
开发者ID:TylerGubala,项目名称:blenderpy,代码行数:47,代码来源:setup.py

示例5: get_setup_args

# 需要导入模块: from distutils.command import install_data [as 别名]
# 或者: from distutils.command.install_data import install_data [as 别名]
def get_setup_args(**kw):
    if 'twisted_subproject' in kw:
        if 'twisted' not in os.listdir('.'):
            raise RuntimeError("Sorry, you need to run setup.py from the "
                               "toplevel source directory.")
        projname = kw['twisted_subproject']
        projdir = os.path.join('twisted', projname)

        kw['packages'] = getPackages(projdir, parent='twisted')
        kw['version'] = getVersion(projname)

        plugin = "twisted/plugins/twisted_" + projname + ".py"
        if os.path.exists(plugin):
            kw.setdefault('py_modules', []).append(
                plugin.replace("/", ".")[:-3])

        kw['data_files'] = getDataFiles(projdir, parent='twisted')

        del kw['twisted_subproject']
    else:
        if 'plugins' in kw:
            py_modules = []
            for plg in kw['plugins']:
                py_modules.append("twisted.plugins." + plg)
            kw.setdefault('py_modules', []).extend(py_modules)
            del kw['plugins']

    if 'cmdclass' not in kw:
        kw['cmdclass'] = {
            'install_data': install_data_twisted,
            'build_scripts': build_scripts_twisted}
        if sys.version_info[:3] < (2, 3, 0):
            kw['cmdclass']['build_py'] = build_py_twisted

    if "conditionalExtensions" in kw:
        extensions = kw["conditionalExtensions"]
        del kw["conditionalExtensions"]

        if 'ext_modules' not in kw:
            # This is a workaround for distutils behavior; ext_modules isn't
            # actually used by our custom builder.  distutils deep-down checks
            # to see if there are any ext_modules defined before invoking
            # the build_ext command.  We need to trigger build_ext regardless
            # because it is the thing that does the conditional checks to see
            # if it should build any extensions.  The reason we have to delay
            # the conditional checks until then is that the compiler objects
            # are not yet set up when this code is executed.
            kw["ext_modules"] = extensions

        class my_build_ext(build_ext_twisted):
            conditionalExtensions = extensions
        kw.setdefault('cmdclass', {})['build_ext'] = my_build_ext
    return kw 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:55,代码来源:dist.py

示例6: setup

# 需要导入模块: from distutils.command import install_data [as 别名]
# 或者: from distutils.command.install_data import install_data [as 别名]
def setup(**kw):
    """
    An alternative to distutils' setup() which is specially designed
    for Twisted subprojects.

    Pass twisted_subproject=projname if you want package and data
    files to automatically be found for you.

    Pass detectExtensions=detectorFunction if your project has
    extension modules. detectorFunction will be called with an
    instance of build_ext_twisted and should return a list of
    distutils Extensions.
    """
    if 'twisted_subproject' in kw:
        if 'twisted' not in os.listdir('.'):
            raise RuntimeError("Sorry, you need to run setup.py from the "
                               "toplevel source directory.")
        projname = kw['twisted_subproject']
        projdir = os.path.join('twisted', projname)

        kw['packages'] = getPackages(projdir, parent='twisted')
        kw['version'] = getVersion(projname)

        plugin = "twisted/plugins/twisted_" + projname + ".py"
        if os.path.exists(plugin):
            kw.setdefault('py_modules', []).append(plugin.replace("/", ".")[:-3])

        kw['data_files'] = getDataFiles(projdir, parent='twisted')

        del kw['twisted_subproject']
    else:
        if 'plugins' in kw:
            py_modules = []
            for plg in kw['plugins']:
                py_modules.append("twisted.plugins." + plg)
            kw.setdefault('py_modules', []).extend(py_modules)
            del kw['plugins']

    if 'cmdclass' not in kw:
        kw['cmdclass'] = {
            'install_data': install_data_twisted,
            'build_scripts': build_scripts_twisted}
        if sys.version_info[:3] < (2, 3, 0):
            kw['cmdclass']['build_py'] = build_py_twisted

    if 'detectExtensions' in kw:
        if 'ext_modules' not in kw:
            kw['ext_modules'] = [True] # distutils is so lame

        dE = kw['detectExtensions']
        del kw['detectExtensions']
        class my_build_ext(build_ext_twisted):
            detectExtensions = dE
        kw.setdefault('cmdclass', {})['build_ext'] = my_build_ext
    return core.setup(**kw) 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:57,代码来源:dist.py


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