1

I'm new to python and writing an application which I want to package for debian. Therefore, I'd like to (and I have to) use pybuilder. My goal is to create a .deb package (currently using stdeb), which makes sure, that all required libraries are installed, too.
My application uses a third party library, that is only available via pip(3) install (no debian package).

My build.py looks like:

[...]
use_plugin("python.core")
use_plugin("python.unittest")
use_plugin("python.install_dependencies")
use_plugin("python.distutils")
use_plugin("copy_resources")
use_plugin("source_distribution")
use_plugin("python.flake8")
use_plugin("python.coverage")
use_plugin("python.stdeb")

@init
def initialize(project):
    project.build_depends_on('coverage')
    project.build_depends_on('flake8')
    project.build_depends_on('jsonmerge')
    project.build_depends_on('mock')
    project.build_depends_on('setuptools')
    project.build_depends_on('stdeb')
    project.build_depends_on('unittest-xml-reporting')
    project.build_depends_on('xmlrunner')

    project.depends_on('<pip-only-library>')

    project.set_property('coverage_threshold_warn', 50)
    project.set_property('flake8_break_build', False)
    project.set_property('flake8_ignore', 'E501,E402,E731')
    project.set_property('flake8_include_test_sources', True)
    project.set_property('flake8_verbose_output', True)
    project.set_property('verbose', True)
    project.set_property("copy_resources_target", "$dir_dist")
    project.set_property("coverage_break_build", False)
    project.set_property("coverage_reset_modules", True)
    project.set_property("dir_dist_scripts", 'scripts')

    project.set_property("distutils_classifiers", [
                         'Programming Language :: Python :: 3',
                         'Programming Language :: Python :: 3.3',
                         'Programming Language :: Python :: 3.4',
                         'Development Status :: 4',
                         'Environment :: Console',
                         'Intended Audience :: Systems Administration',
                         'License :: OSI Approved :: BSD License'])

    project.set_property('distutils_commands', ['bdist'])
    project.set_property('distutils_commands', ['sdist'])

Generation of debian package works in general. Calling pyb successfully creates a python3-mypackage_1.0-1_all.deb package.
The generated setup.py looks like:

# `target/dist/mypackage-1.0/setup.py`
[...]
if __name__ == '__main__':
    setup(
        [...]
        packages = [],
        [...]
        entry_points = {},
        data_files = [],
        package_data = {},
        install_requires = ['pip-only-library'],
        dependency_links = [],
        zip_safe=True,
        cmdclass={'install': install},
    )

Testing package installation using sudo dpkg -i python3-mypackage_1.0-1_all.deb fails as dpkg refers to a dependent package python3-<pip-only-library>, which is not available.

During build time, the library is present on the local machine. So, now comes the newbie question: How to change build.py to make sure, that the created debian package provides my application and makes sure, that library requirements are met.
Maybe, is it possible to bundle the pip-only library (i.e. taken from /usr/local/lib/python3.4/dist-packages during build-time) to my application and ship them within an 'application with all dependencies'-package? Or is there an alternative approach?

I've already seen this answer but it doesn't help.

Community
  • 1
  • 1
ITL
  • 422
  • 1
  • 5
  • 17

0 Answers0