Pybuilder-未打包非Python文件 [英] Pybuilder - Non-python files are not packaged

查看:165
本文介绍了Pybuilder-未打包非Python文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当前的项目在python中。为了生成生成程序包+运行单元测试,我使用的是 Pybuilder 实用程序,它非常酷。我使用轮分布将模块安装在其他系统中。

My current project is in python. For build package generation + unit test running, I'm using Pybuilder utility and it is pretty cool. I used the wheel distribution to install the module in other systems.

存在一个配置文件,应用程序可以从中读取某些设置。 settings.ini文件位于以下路径中,

There exist a config file from which certain settings are read by the application. settings.ini file is in following path,

PROJECT-ROOT
     |---- src
            |-main
                |-python
                     |- foo
                         |- conf
                         |   |- settings.ini
                         |
                         |-test.py
                         |-access.py

pybuilder自动创建来自build.py脚本的setup.py。问题是二进制车轮分发版没有打包非python文件(* .ini文件)。在搜索SO帖子时,获得诸如在MANIFEST.mf中添加的信息将解决此问题。但是在添加

pybuilder automatically creates setup.py from the build.py script. The problem is that the binary wheel distribution is not packaging the non-python files(*.ini file). While searching on SO posts, got information like adding in MANIFEST.mf will resolve this issue. But while adding

 project._manifest_include_directory('foo/conf', ('*.ini',))

仅在sdist中更新 foo / conf / settings.ini 而不是在bdist(wheel)上。我想要滚轮文件在conf /目录中包含settings.ini 。在谷歌搜索中,获得的信息表明,在setup.py中添加 package_data 字段将解决此问题。但是使用Pybuilder的build.py,我无法成功完成此操作。

It only updated foo/conf/settings.ini in sdist and not on the bdist(wheel). I want the wheel file to include settings.ini in the conf/ directory. On googling, got information that addition of package_data field in setup.py will resolve this issue. But with Pybuilder's build.py, I'm unable to do this successfully.

有人可以帮助我解决此问题吗?

Can any one help me to resolve this issue?

推荐答案

我已通过电子邮件发送给Max( https://github.com / mriehl ),他是github中PyBuilder代码的贡献者之一。他建议我尝试 project.install_file()选项。

I've emailed Max(https://github.com/mriehl), who is one among the contributor of PyBuilder code in github. He suggested me to try project.install_file() option.

我尝试了该选项,它对我有用。多亏了Max。我想在此线程中共享该信息,以便将来对某人有用!

I tried that option and it worked for me. Thanks to Max. I want to share that info in this thread, so that it will be useful to someone in future !

在后台 project.install_file() 正在修改 distutils setup.py data_files 部分。

In the background project.install_file() is modifying data_files part of setup.py of distutils.

我在 build.py 中的配置如下,

@init
def initialize (project):

    # File is installed relative to sys.prefix
    project.install_file("Lib/site-packages/foo/conf","foo/conf/settings.ini")

这篇关于Pybuilder-未打包非Python文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆