-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathsetup.py
123 lines (94 loc) · 3.5 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
112
113
114
115
116
117
118
119
120
121
122
123
#!/usr/bin/env python
# --------------------------------------------------
# Copyright The IETF Trust 2018-2019, All Rights Reserved
# --------------------------------------------------
import re
from setuptools import setup, find_packages
from codecs import open
from os import path
import rfctools_common
here = path.abspath(path.dirname(__file__))
# Get the long description from the README file
with open(path.join(here, 'README.rst'), encoding='utf-8') as file:
long_description = file.read()
long_description = long_description.replace('\r', '')
# Get the requirements from the local requirements.txt file
with open(path.join(here, 'requirements.txt'), encoding='utf-8') as file:
requirements = file.read().splitlines()
# Get additional items from the local MANIFEST.in file
with open(path.join(here, 'MANIFEST.in'), encoding='utf-8') as file:
extra_files = [l.split()[1] for l in file.read().splitlines() if l]
def parse(changelog):
ver_line = "^([a-z0-9+-]+) \(([^)]+)\)(.*?) *$"
sig_line = "^ ?-- ([^<]+) <([^>]+)> (.*?) *$"
entries = []
if isinstance(changelog, type('')):
changelog = open(changelog, mode='rU', encoding='utf-8')
for line in changelog:
if re.match(ver_line, line):
package, version, rest = re.match(ver_line, line).groups()
entry = {}
entry["package"] = package
entry["version"] = version
entry["logentry"] = ""
elif re.match(sig_line, line):
author, email, date = re.match(sig_line, line).groups()
entry["author"] = author
entry["email"] = email
entry["datetime"] = date
entry["date"] = " ".join(date.split()[:3])
entries += [entry]
else:
entry["logentry"] += line.rstrip() + '\n'
changelog.close()
return entries
changelog_entry_template = """
Version %(version)s (%(date)s)
------------------------------------------------
%(logentry)s
"""
long_description += """
Changelog
=========
""" + "\n".join([changelog_entry_template % entry for entry in parse("changelog")[:3]])
long_description = long_description.replace('\r', '')
setup(
name='rfctools_common',
# Versions should comply with PEP440.
version=rfctools_common.__version__,
description="Common routines for a set of RFC Production center tools",
long_description=long_description,
# The projects main homepage.
url='https://github.com/ietf-tools/RfcEditor/tree/master/rfctools_common',
# Author details
author='Jim Schaad',
author_email='ietf@augustcellars.com',
# Choose your license
license='Simplified BSD',
# Classifiers
classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: Other Audience',
'Topic :: Text Processing',
'Topic :: Text Processing :: Markup :: XML',
'License :: OSI Approved :: BSD License',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.7',
],
# What does your project relate to?
keywords='RFC common',
#
packages=find_packages(exclude=['contrib', 'docs', 'Tests']),
# List run-time dependencies here.
install_requires=requirements,
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4',
# List additional gorups of dependencies here.
# extras_require=(
# 'dev':['twine',],
# ]
package_data={
'rfctools-common': ['templates/*']
},
include_package_data=True,
zip_safe=False
)