1
1
#!/usr/bin/env python3
2
2
# -*- Mode: Python; indent-tabs-mode: nil; tab-width: 4; coding: utf-8 -*-
7
8
from distutils.core import setup
8
9
from subprocess import check_output
10
from DistUtilsExtra.command import (
11
build_extra, build_i18n, build_help)
11
from DistUtilsExtra.command import build_extra, build_help, build_i18n
16
def make_pep440_compliant(version: str) -> str:
17
"""Convert the version into a PEP440 compliant version."""
20
version = version.split(":", 1)[1]
21
public_version_re = re.compile(
22
r"^([0-9][0-9.]*(?:(?:a|b|rc|.post|.dev)[0-9]+)*)\+?"
24
_, public, local = public_version_re.split(version, maxsplit=1)
27
sanitized_local = re.sub("[+~]+", ".", local).strip(".")
28
pep440_version = f"{public}+{sanitized_local}"
30
"^[a-zA-Z0-9.]+$", sanitized_local
31
), f"'{pep440_version}' not PEP440 compliant"
19
return [os.path.join('janitor/plugincore/plugins', name)
20
for name in os.listdir('janitor/plugincore/plugins')
21
if name.endswith('_plugin.py') and name not in disabled]
24
for line in check_output('dpkg-parsechangelog --format rfc822'.split(),
25
universal_newlines=True).splitlines():
26
header, colon, value = line.lower().partition(':')
27
if header == 'version':
28
version = value.strip()
38
os.path.join("janitor/plugincore/plugins", name)
39
for name in os.listdir("janitor/plugincore/plugins")
40
if name.endswith("_plugin.py") and name not in disabled
44
for line in check_output(
45
"dpkg-parsechangelog --format rfc822".split(), universal_newlines=True
47
header, colon, value = line.lower().partition(":")
48
if header == "version":
49
VERSION = make_pep440_compliant(value.strip())
31
raise RuntimeError('No version found in debian/changelog')
52
raise RuntimeError("No version found in debian/changelog")
34
55
class CustomBuild(build_extra.build_extra):
36
with open("UpdateManager/UpdateManagerVersion.py", "w") as f:
37
f.write("VERSION = '%s'\n" % version)
57
version_py = pathlib.Path("UpdateManager/UpdateManagerVersion.py")
58
version_py.write_text(f"VERSION = '{VERSION}'\n", encoding="utf-8")
38
59
build_extra.build_extra.run(self)
41
setup(name='update-manager',
43
packages=['UpdateManager',
44
'UpdateManager.backend',
50
scripts=['update-manager',
51
'ubuntu-security-status',
54
data_files=[('share/update-manager/gtkbuilder',
55
glob.glob("data/gtkbuilder/*.ui")
60
('share/GConf/gsettings/',
61
['data/update-manager.convert']),
63
cmdclass={"build": CustomBuild,
64
"build_i18n": build_i18n.build_i18n,
65
"build_help": build_help.build_help}
63
name="update-manager",
67
"UpdateManager.backend",
73
scripts=["update-manager", "ubuntu-security-status", "hwe-support-status"],
75
("share/update-manager/gtkbuilder", glob.glob("data/gtkbuilder/*.ui")),
76
("share/man/man8", glob.glob("data/*.8")),
77
("share/GConf/gsettings/", ["data/update-manager.convert"]),
81
"build_i18n": build_i18n.build_i18n,
82
"build_help": build_help.build_help,