Skip to content

Commit 6a0fa0a

Browse files
committed
feat: get self-packaging to work again via dh multi-binary pkg build
1 parent 984ab6c commit 6a0fa0a

File tree

2 files changed

+48
-8
lines changed

2 files changed

+48
-8
lines changed

debian/rules

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,56 @@
33
import sys
44
from pathlib import Path
55

6-
repo_root = Path(__file__).parent.parent / "src"
7-
sys.path.append(str(repo_root))
6+
packages_root = Path(__file__).parent.parent / "packages"
7+
sys.path.extend(
8+
[
9+
str(packages_root / "debmagic-common" / "src"),
10+
str(packages_root / "debmagic-pkg" / "src"),
11+
]
12+
)
813

9-
from debmagic.v0 import package
10-
from debmagic.v0 import dh as dh_mod
14+
from debmagic.v0 import package, dh, Build
1115

12-
dh = dh_mod.Preset(dh_args=["--with", "python3", "--buildsystem=pybuild"])
16+
dhp = dh.Preset(dh_args=["--with", "python3", "--buildsystem=pybuild"])
1317

1418
pkg = package(
15-
preset=[dh],
19+
preset=[dhp],
1620
)
1721

18-
pkg.pack()
22+
packages = {
23+
"python3-debmagic-common": ("packages/debmagic-common", "debmagic-common"),
24+
"debmagic": ("packages/debmagic", "debmagic"),
25+
"debmagic-pkg": ("packages/debmagic-pkg", "debmagic-pkg"),
26+
}
27+
28+
def dh_auto(build: Build, stage: str, use_destdir: bool = False):
29+
for pkg_name, (path, python_pkg_name) in packages.items():
30+
destdir = f" --destdir debian/{pkg_name} " if use_destdir else ""
31+
build.cmd(f"{stage} -p {pkg_name} --sourcedirectory {path} --buildsystem=pybuild {destdir} -- --name {python_pkg_name}")
32+
33+
@dhp.override
34+
def dh_auto_configure(build: Build):
35+
dh_auto(build, "dh_auto_configure")
36+
37+
38+
@dhp.override
39+
def dh_auto_build(build: Build):
40+
dh_auto(build, "dh_auto_build")
41+
42+
43+
@dhp.override
44+
def dh_auto_install(build: Build):
45+
dh_auto(build, "dh_auto_install", use_destdir=True)
46+
47+
48+
@dhp.override
49+
def dh_auto_test(build: Build):
50+
dh_auto(build, "dh_auto_test")
51+
52+
53+
@dhp.override
54+
def dh_auto_clean(build: Build):
55+
dh_auto(build, "dh_auto_clean")
56+
57+
58+
pkg.pack()

packages/debmagic/src/debmagic/cli/_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
class DebmagicConfig(BaseModel):
99
# driver: BuildDriverType | None = None
10-
temp_build_dir = Path("/tmp/debmagic")
10+
temp_build_dir: Path = Path("/tmp/debmagic")
1111

1212

1313
def merge_configs(configs: Sequence[DebmagicConfig]) -> DebmagicConfig:

0 commit comments

Comments
 (0)