Search code examples
python-3.xdistutilspybuilder

Pybuilder - Non-python files are not packaged


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.

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 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',))

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?


Solution

  • 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.

    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 !

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

    My configuration in the build.py are as follows,

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