setup.py 文件源码

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

项目:notebook-molecular-visualization 作者: Autodesk 项目源码 文件源码
def run(self):
        has_npm = self.has_npm()
        if not has_npm:
            log.error("`npm` unavailable. If you're running this command using sudo, "
                      "make sure `npm` is available to sudo")

        env = os.environ.copy()
        env['PATH'] = npm_path

        vjson = os.path.join(node_root, '.VERSION.json')
        with open(vjson, 'w') as vjsonfile:
            vjsonfile.write('{"version":"%s"}\n' % VERSION)

        if self.should_run_npm_install():
            log.info("Installing build dependencies with npm.  This may take a while...")
            check_call(['npm', 'install'], cwd=node_root, stdout=sys.stdout, stderr=sys.stderr)
            os.utime(self.node_modules, None)

        # TODO: do this with NPM/webpack, not in python
        shutil.copy(os.path.join(node_root, 'src', 'nbmolviz.css'),
                    os.path.join(here, 'nbmolviz', 'static', 'nbmolviz.css'))

        with open(self.verfile_path, 'w') as verfile:
            verfile.write(VERSION)

        for t in self.targets:
            if not os.path.exists(t):
                msg = 'Missing file: %s' % t
                if not has_npm:
                    msg += '\nnpm is required to build a development version of nbmolviz-js'
                raise ValueError(msg)

        print('Wrote version "%s" to "%s"' % (VERSION, self.verfile_path))

        # update package data in case this created new files
        update_package_data(self.distribution)


###################################################################
#   Actual setup command                                          #
###################################################################
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号