-
Notifications
You must be signed in to change notification settings - Fork 7
/
setup.py
executable file
·111 lines (96 loc) · 3.88 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# pylint: disable=
# mkvenv: no-deps
""" Debian packaging for Sentry, a modern realtime error logging and aggregation platform.
| Copyright © 2017, 2018 1&1 Group
| BSD 3-clause license, see LICENSE for details.
|
| Copyright (c) 2017 Sentry (https://sentry.io) and individual contributors.
| All rights reserved.
This puts the ``sentry`` Python package and its dependencies as released
on PyPI into a DEB package, using ``dh-virtualenv``.
The resulting *omnibus package* is thus easily installed to and removed
from a machine, but is not a ‘normal’ Debian ``python-*`` package.
Services are controlled by ``systemd`` units.
The final package includes the official ``sentry-plugins`` and some other
commonly needed plugins.
See the `GitHub README`_ for more.
.. _`GitHub README`: https://github.com/1and1/debianized-sentry#sentryio-debian-packaging
"""
import os
import re
import sys
import json
import rfc822
import textwrap
import subprocess
try:
from setuptools import setup
except ImportError as exc:
raise RuntimeError("setuptools is missing ({0})".format(exc))
# get external project data (and map Debian version semantics to PEP440)
pkg_version = subprocess.check_output("parsechangelog | grep ^Version:", shell=True)
upstream_version, maintainer_version = pkg_version.split()[1].split('~', 1)[0].split('-', 1)
maintainer_version = maintainer_version.replace('~~rc', 'rc').replace('~~dev', '.dev')
pypi_version = upstream_version + '.' + maintainer_version
with open('debian/control') as control_file:
deb_source = rfc822.Message(control_file)
deb_binary = rfc822.Message(control_file)
maintainer, email = re.match(r'(.+) <([^>]+)>', deb_source['Maintainer']).groups()
desc, long_desc = deb_binary['Description'].split('.', 1)
desc, pypi_desc = __doc__.split('\n', 1)
long_desc = textwrap.dedent(pypi_desc) + textwrap.dedent(long_desc).replace('\n.\n', '\n\n')
dev_status = 'Development Status :: 5 - Production/Stable'
if '~~rc' in pkg_version:
rc_tag = pkg_version.split('~')[-1].split('~')[0].split('-')[0]
upstream_version += rc_tag
pypi_version += rc_tag
dev_status = 'Development Status :: 4 - Beta'
# build setuptools metadata
project = dict(
name='debianized-' + deb_source['Source'].replace('.io', ''),
version=pypi_version,
author=maintainer,
author_email=email,
license='BSD 3-clause',
description=desc.strip(),
long_description=textwrap.dedent(long_desc).strip(),
url=deb_source['Homepage'],
classifiers=[
# Details at http://pypi.python.org/pypi?:action=list_classifiers
dev_status,
'Environment :: Web Environment',
'Framework :: Django',
'Intended Audience :: Developers',
'Intended Audience :: Information Technology',
'Intended Audience :: System Administrators',
'License :: OSI Approved :: BSD License',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 2.7',
'Topic :: Software Development :: Bug Tracking',
'Topic :: System :: Monitoring',
'Topic :: System :: Logging',
],
keywords='debian-packages dh-virtualenv sentry deployment devops omnibus-packages'.split(),
install_requires=[
# core
'sentry[postgres]==' + upstream_version,
'sentry-plugins==' + upstream_version,
# 3rd party
'sentry-ldap-auth==2.7',
'sentry-kafka==1.1',
],
packages=[],
)
# 'main'
__all__ = ['project']
if __name__ == '__main__':
if '--metadata' in sys.argv[:2]:
json.dump(project, sys.stdout, default=repr, indent=4, sort_keys=True)
sys.stdout.write('\n')
elif '--tag' in sys.argv[:2]:
subprocess.call("git tag -a 'v{version}' -m 'Release v{version}'"
.format(version=pypi_version), shell=True)
else:
setup(**project)