setup.py 文件源码

python
阅读 15 收藏 0 点赞 0 评论 0

项目:solaris-ips 作者: oracle 项目源码 文件源码
def run(self):
                """At the end of the install function, we need to rename some
                files because distutils provides no way to rename files as they
                are placed in their install locations.
                """

                _install.run(self)

                for o_src, o_dest in hardlink_modules:
                        for e in [".py", ".pyc"]:
                                src = util.change_root(self.root_dir, o_src + e)
                                dest = util.change_root(
                                    self.root_dir, o_dest + e)
                                if ostype == "posix":
                                        if os.path.exists(dest) and \
                                            os.stat(src)[stat.ST_INO] != \
                                            os.stat(dest)[stat.ST_INO]:
                                                os.remove(dest)
                                        file_util.copy_file(src, dest,
                                            link="hard", update=1)
                                else:
                                        file_util.copy_file(src, dest, update=1)

                # XXX Uncomment it when we need to deliver python 3.4 version
                # of modules.
                # Don't install the scripts for python 3.4.
                if py_version == '3.4':
                        return
                for d, files in six.iteritems(scripts[osname]):
                        for (srcname, dstname) in files:
                                dst_dir = util.change_root(self.root_dir, d)
                                dst_path = util.change_root(self.root_dir,
                                       os.path.join(d, dstname))
                                dir_util.mkpath(dst_dir, verbose=True)
                                file_util.copy_file(srcname, dst_path,
                                    update=True)
                                # make scripts executable
                                os.chmod(dst_path,
                                    os.stat(dst_path).st_mode
                                    | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)

                for target, o_dest in symlink_modules:
                        dest = util.change_root(self.root_dir, o_dest)
                        dir_util.mkpath(os.path.dirname(dest), verbose=True)
                        try:
                                os.unlink(dest)
                        except Exception:
                                pass
                        os.symlink(target, dest)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号