forked from xolox/python-humanfriendly
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
executable file
·106 lines (91 loc) · 3.7 KB
/
setup.py
File metadata and controls
executable file
·106 lines (91 loc) · 3.7 KB
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
#!/usr/bin/env python
"""Setup script for the `humanfriendly` package."""
# Author: Peter Odding <peter@peterodding.com>
# Last Change: February 20, 2016
# URL: https://humanfriendly.readthedocs.org
# Standard library modules.
import codecs
import os
import re
import sys
# De-facto standard solution for Python packaging.
from setuptools import find_packages, setup
def get_contents(filename):
"""Get the contents of a file relative to the source distribution directory."""
directory = os.path.dirname(os.path.abspath(__file__))
pathname = os.path.join(directory, filename)
with codecs.open(pathname, 'r', 'utf-8') as handle:
return handle.read()
def get_version(filename):
"""Extract the version number from a Python module."""
contents = get_contents(filename)
metadata = dict(re.findall('__([a-z]+)__ = [\'"]([^\'"]+)', contents))
return metadata['version']
def have_environment_marker_support():
"""
Check whether setuptools has support for PEP-426 environment marker support.
Based on the ``setup.py`` script of the ``pytest`` package:
https://bitbucket.org/pytest-dev/pytest/src/default/setup.py
"""
try:
from pkg_resources import parse_version
from setuptools import __version__
return parse_version(__version__) >= parse_version('0.7.2')
except Exception:
return False
# Conditional importlib dependency for Python 2.6 and 3.0 when creating a source distribution.
install_requires = []
if 'bdist_wheel' not in sys.argv:
if sys.version_info[:2] <= (2, 6) or sys.version_info[:2] == (3, 0):
install_requires.append('importlib')
# Conditional importlib dependency for Python 2.6 and 3.0 when creating a wheel distribution.
extras_require = {}
if have_environment_marker_support():
extras_require[':python_version == "2.6" or python_version == "3.0"'] = ['importlib']
setup(
name='humanfriendly',
version=get_version('humanfriendly/__init__.py'),
description="Human friendly output for text interfaces using Python",
long_description=get_contents('README.rst'),
url='https://humanfriendly.readthedocs.org',
author='Peter Odding',
author_email='peter@peterodding.com',
packages=find_packages(),
install_requires=install_requires,
extras_require=extras_require,
entry_points=dict(console_scripts=[
'humanfriendly = humanfriendly.cli:main'
]),
test_suite='humanfriendly.tests',
tests_require=[
'capturer >= 2.1',
'coloredlogs >= 2.0',
],
classifiers=[
'Development Status :: 6 - Mature',
'Environment :: Console',
'Framework :: Sphinx :: Extension',
'Intended Audience :: Developers',
'Intended Audience :: System Administrators',
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Topic :: Communications',
'Topic :: Scientific/Engineering :: Human Machine Interfaces',
'Topic :: Software Development',
'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: Software Development :: User Interfaces',
'Topic :: System :: Shells',
'Topic :: System :: System Shells',
'Topic :: System :: Systems Administration',
'Topic :: Terminals',
'Topic :: Text Processing :: General',
'Topic :: Text Processing :: Linguistic',
'Topic :: Utilities',
])