-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsetup.py
176 lines (153 loc) · 6.16 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Markdown Superscript Extension Setup
:website: https://github.com/jambonrose/markdown_superscript_extension
:copyright: Copyright 2014-2018 Andrew Pinkham
:license: Simplified BSD, see LICENSE for details.
"""
from codecs import open as codec_open
from distutils.command.check import check as CheckCommand # noqa: N812
from os.path import abspath, dirname, join
from sys import argv
from setuptools import setup
HERE = abspath(dirname(__file__))
def load_file_contents(file_path, as_list=True):
"""Load file as string or list"""
abs_file_path = join(HERE, file_path)
with codec_open(abs_file_path, encoding="utf-8") as file_pointer:
if as_list:
return file_pointer.read().splitlines()
return file_pointer.read()
# Get the long description from the Read Me
LONG_DESCRIPTION = (
load_file_contents("README.rst", as_list=False)
.split(".. start-pypi-description")[1] # remove badge icons and title
.lstrip() # remove any extraneous spaces before title
)
# Get test dependencies
TESTS_REQUIRE = load_file_contents("requirements/test_requirements.txt")
SETUP_REQUIRES_PYTEST_RUNNER = (
["pytest-runner>=4.2,<5"]
if {"pytest", "test", "ptr"}.intersection(argv)
else []
)
class CustomCheckCommand(CheckCommand):
"""Customized distutils check command"""
# https://github.com/python/cpython/blob/master/Lib/distutils/command/check.py
user_options = CheckCommand.user_options + [
("disable-metadata", None, "don't check meta-data"),
("enforce-email", "e", "Ensure that all author/maintainer use email"),
]
negative_opt = {"disable-metadata": "metadata"}
def initialize_options(self):
"""Set new options after superclass"""
super().initialize_options()
self.enforce_email = 0 # pylint:disable=attribute-defined-outside-init
def check_metadata(self):
"""Ensure all required meta-data are supplied.
Specifically: name, version, URL, author or maintainer
Warns if any are missing.
If enforce-email option is true, author and/or maintainer must
specify an email.
"""
metadata = self.distribution.metadata
missing = []
for attr in ("name", "version", "url"):
if not (hasattr(metadata, attr) and getattr(metadata, attr)):
missing.append(attr)
# https://www.python.org/dev/peps/pep-0345/
# author or maintainer must be specified
# author is preferred; if identifcal, specify only author
if not metadata.author and not metadata.maintainer:
missing.append("author")
if self.enforce_email:
missing.append("author_email")
else:
# one or both of author or maintainer specified
if (
metadata.author
and self.enforce_email
and not metadata.author_email
):
missing.append("author_email")
if (
metadata.maintainer
and self.enforce_email
and not metadata.maintainer_email
):
missing.append("maintainer_email")
if (
metadata.author
and metadata.maintainer
and metadata.author == metadata.maintainer
):
self.warn(
"Maintainer should be omitted if identical to Author.\n"
"See https://www.python.org/dev/peps/pep-0345/"
"#maintainer-email-optional"
)
if (
metadata.author_email
and metadata.maintainer_email
and metadata.author_email == metadata.maintainer_email
):
self.warn(
"Maintainer Email should be omitted if"
"identical to Author's.\n"
"See https://www.python.org/dev/peps/pep-0345/"
"#maintainer-email-optional"
)
if missing:
self.warn("missing required meta-data: %s" % ", ".join(missing))
setup(
name="MarkdownSuperscript",
version="2.1.1", # PEP 440 Compliant Semantic Versioning
keywords=["text", "filter", "markdown", "html", "superscript"],
description="Python-Markdown extension to allow for superscript text.",
long_description=LONG_DESCRIPTION,
author="Andrew Pinkham",
url="https://github.com/jambonrose/markdown_superscript_extension",
project_urls={
"Documentation": (
"https://markdown-superscript-extension.rtfd.io/en/stable/"
),
"Source": (
"https://github.com/jambonrose/markdown_superscript_extension"
),
"Tracker": (
"https://github.com/jambonrose/"
"markdown_superscript_extension/issues"
),
},
cmdclass={"check": CustomCheckCommand},
py_modules=["mdx_superscript"],
install_requires=["Markdown>=2.5,<3.1"],
tests_require=TESTS_REQUIRE,
setup_requires=SETUP_REQUIRES_PYTEST_RUNNER,
license="Simplified BSD License",
classifiers=[
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Text Processing :: Filters",
"Topic :: Text Processing :: Markup :: HTML",
],
entry_points={
"markdown.extensions": [
"superscript = mdx_superscript:SuperscriptExtension"
]
},
)