-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
73 lines (57 loc) · 2.05 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
# -*- coding: utf-8 -*-
"""
Setup for repo template.
The project contains a **single top-level package**.
The top-level package package.py stores all the project info.
"""
import codecs
from os import path
from setuptools import find_packages, setup
def get_long_description(readme):
"""Get the long description from the README file."""
with codecs.open(readme, encoding='utf-8') as _rf:
return _rf.read()
def get_package_name():
'The top-level package name.'
top_level_packages = [
p for p in find_packages(exclude=['tests']) if '.' not in p
]
if len(top_level_packages) != 1:
raise ValueError('Project must contain a single top-level package.')
return top_level_packages[0]
base_dir = path.abspath(path.dirname(__file__))
readme_file = path.join(base_dir, 'README.md')
# single top-level package
package_name = get_package_name()
# get project info from the package.py module of the top-level package
project_info = {}
with open(path.join(package_name, 'package.py')) as fp:
exec(fp.read(), project_info) # pylint: disable=exec-used
project_name = project_info['__title__']
version = project_info['__version__']
long_description = get_long_description(readme_file)
packages = find_packages(exclude=['tests'])
modules = []
SETUP_REQUIRES = []
INSTALL_REQUIRES = [
# # this is an example of URL based requirement (see PEP508):
# 'repo @ http://github.com/user/repo/archive/master.tar.gz',
]
EXTRAS_REQUIRES = {'test': ['pytest']}
setup(
name=project_name,
version=version,
description=project_info.get('__summary__'),
long_description=long_description,
author=project_info.get('__author__'),
author_email=project_info.get('__email__'),
url=project_info.get('__url__'),
py_modules=modules,
packages=packages,
setup_requires=SETUP_REQUIRES,
install_requires=INSTALL_REQUIRES,
extras_require=EXTRAS_REQUIRES,
license=project_info.get('__license__'),
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers=project_info.get('__classifiers__'),
)