• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pybuilder / pybuilder / 16613314016

30 Jul 2025 04:14AM UTC coverage: 84.008% (-0.1%) from 84.146%
16613314016

push

github

arcivanov
Release 0.13.16

2167 of 2671 branches covered (81.13%)

Branch coverage included in aggregate %.

5534 of 6496 relevant lines covered (85.19%)

36.25 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

62.5
/src/main/python/pybuilder/plugins/python/stdeb_plugin.py
1
#   -*- coding: utf-8 -*-
2
#
3
#   This file is part of PyBuilder
4
#
5
#   Copyright 2011-2020 PyBuilder Team
6
#
7
#   Licensed under the Apache License, Version 2.0 (the "License");
8
#   you may not use this file except in compliance with the License.
9
#   You may obtain a copy of the License at
10
#
11
#       http://www.apache.org/licenses/LICENSE-2.0
12
#
13
#   Unless required by applicable law or agreed to in writing, software
14
#   distributed under the License is distributed on an "AS IS" BASIS,
15
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
#   See the License for the specific language governing permissions and
17
#   limitations under the License.
18
#
19

20
from pybuilder.core import NAME_ATTRIBUTE
44✔
21
from pybuilder.core import (after,
44✔
22
                            task,
23
                            init,
24
                            use_plugin,
25
                            depends)
26
from pybuilder.errors import BuildFailedException
44✔
27
from pybuilder.utils import (tail_log
44✔
28
                             )
29

30
__author__ = 'Marcel Wolf'
44✔
31

32
DEB_PACKAGE_MAINTAINER = "John Doe <changeme@example.com>"
44✔
33

34
use_plugin("core")
44✔
35

36

37
@init
44✔
38
def initialize_make_deb_plugin(project):
44✔
39
    project.plugin_depends_on("stdeb")
×
40

41
    package_name = project.name + "-" + project.version + ".tar.gz"
×
42

43
    PATH_TO_SOURCE_TARBALL = project.expand_path("$dir_dist", "dist", package_name)
×
44
    PATH_FINAL_BUILD = project.expand_path("$dir_dist", "dist")
×
45

46
    project.set_property_if_unset(
×
47
        "deb_package_maintainer", DEB_PACKAGE_MAINTAINER)
48
    project.set_property_if_unset(
×
49
        "path_final_build", PATH_FINAL_BUILD)
50
    project.set_property_if_unset(
×
51
        "path_to_source_tarball", PATH_TO_SOURCE_TARBALL)
52

53

54
@after("prepare")
44✔
55
def assert_py2dsc_deb_is_available(project, logger, reactor):
44✔
56
    """Asserts that the py2dsc-deb is available.
57
    """
58
    logger.debug("Checking if py2dsc-deb is available.")
44✔
59

60
    reactor.pybuilder_venv.verify_can_execute(["py2dsc-deb", "-h"], "py2dsc-deb",
44✔
61
                                              "plugin python.stdeb")
62

63

64
@after("prepare")
44✔
65
def assert_dpkg_is_available(project, logger, reactor):
44✔
66
    """Asserts that the dpkg-buildpackage is available.
67
    """
68
    logger.debug("Checking if dpkg-buildpackage is available")
44✔
69

70
    reactor.pybuilder_venv.verify_can_execute(["dpkg-buildpackage", "--help"], "dpkg-buildpackage",
44✔
71
                                              "plugin python.stdeb")
72

73

74
@task("make_deb", "converts a source tarball into a Debian source package and build a .deb package")
44✔
75
@depends("publish")
44✔
76
def py2dsc_deb(project, logger, reactor):
44✔
77
    """Runs py2dsc-deb against the setup.py for the given project.
78
    """
79
    task_name = getattr(py2dsc_deb, NAME_ATTRIBUTE)
×
80
    build_command = get_py2dsc_deb_command(project)
×
81
    run_py2dsc_deb_build(reactor.pybuilder_venv, build_command, task_name, logger, project)
×
82

83

84
def get_py2dsc_deb_command(project):
44✔
85
    """Builds the py2dsc_deb command using project properties.
86
        py2dsc_deb parameters:
87
        :param --maintainer: maintainer name and email to use.
88
        :param -d: directory to put final built.
89
    """
90

91
    return ["py2dsc-deb", "--maintainer", project.get_property("deb_package_maintainer"),
44✔
92
            "-d", project.get_property("path_final_build"),
93
            project.get_property("path_to_source_tarball")]
94

95

96
def run_py2dsc_deb_build(python_env, build_command, task_name, logger, project):
44✔
97
    logger.info("Running %s" % task_name)
×
98
    log_file = project.expand_path("$dir_target", "reports", task_name)
×
99
    if project.get_property("verbose"):
×
100
        logger.info(build_command)
×
101
        exit_code = python_env.execute_command(build_command, log_file, shell=True)
×
102
        if exit_code != 0:
×
103
            raise BuildFailedException(
×
104
                "py2dsc_deb build command failed. See %s for full details:\n%s", log_file, tail_log(log_file))
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc