-
Notifications
You must be signed in to change notification settings - Fork 61
/
setup.py
176 lines (143 loc) · 4.98 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
# Copyright (c) 2021. yoshida-lab. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
# -*- coding: utf-8 -*-
# uncomment this for compatibility with py27
# from __future__ import print_function
import os
from pathlib import Path
from ruamel.yaml import YAML
from setuptools import setup, find_packages
# YOUR PACKAGE NAME
__package__ = 'xenonpy'
class PackageInfo(object):
"""
Appendix
--------
classifiers: https://pypi.python.org/pypi?%3Aaction=list_classifiers
"""
def __init__(self, conf_file):
yaml = YAML(typ='safe')
yaml.indent(mapping=2, sequence=4, offset=2)
with open(conf_file, 'r') as f:
self._info = yaml.load(f)
self.name = __package__
@staticmethod
def requirements(filename="requirements.txt"):
"""
Return requirements list from a text file.
Parameters
----------
filename: str
Name of requirement file.
Returns
-------
str-list
"""
try:
require = list()
f = open(filename, "rb")
for line in f.read().decode("utf-8").split("\n"):
line = line.strip()
if "#" in line:
line = line[:line.find("#")].strip()
if line:
require.append(line)
except IOError:
print("'{}' not found!".format(filename))
require = list()
return require
def __getattr__(self, item: str):
try:
return self._info[item]
except KeyError:
return None
if __name__ == "__main__":
# --- Automatically generate setup parameters ---
cwd = Path(__file__).parent / __package__ / 'conf.yml'
package = PackageInfo(str(cwd))
# Your package name
PKG_NAME = package.name
# Your GitHub user name
GITHUB_USERNAME = package.github_username
# Short description will be the description on PyPI
SHORT_DESCRIPTION = package.short_description # GitHub Short Description
# Long description will be the body of content on PyPI page
LONG_DESCRIPTION = package.long_description
# Version number, VERY IMPORTANT!
VERSION = package.version + package.release
# Author and Maintainer
AUTHOR = package.author
# Author email
AUTHOR_EMAIL = package.author_email
MAINTAINER = package.maintainer
MAINTAINER_EMAIL = package.maintainer_email
PACKAGES, INCLUDE_PACKAGE_DATA, PACKAGE_DATA, PY_MODULES = (
None,
None,
None,
None,
)
# It's a directory style package
if os.path.exists(__file__[:-8] + PKG_NAME):
# Include all sub packages in package directory
PACKAGES = find_packages(exclude=["*.tests", "*.tests.*", "tests.*", "tests"])
# Include everything in package directory
INCLUDE_PACKAGE_DATA = True
PACKAGE_DATA = {
"": ["*.*"],
}
# It's a single script style package
elif os.path.exists(__file__[:-8] + PKG_NAME + ".py"):
PY_MODULES = [
PKG_NAME,
]
# Project Url
GITHUB_URL = "https://github.com/{0}/{1}".format(GITHUB_USERNAME, PKG_NAME)
# Use todays date as GitHub release tag
RELEASE_TAG = 'v' + VERSION
# Source code download url
DOWNLOAD_URL = "https://github.com/{0}/{1}/archive/{2}.tar.gz".format(GITHUB_USERNAME, PKG_NAME, RELEASE_TAG)
LICENSE = package.license or "'__license__' not found in '%s.__init__.py'!" % PKG_NAME
PLATFORMS = [
"Windows",
"MacOS",
"Unix",
]
CLASSIFIERS = [
"Development Status :: 4 - Beta",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
"Natural Language :: English",
"Operating System :: Microsoft :: Windows",
"Operating System :: MacOS",
"Operating System :: Unix",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
]
# Read requirements.txt, ignore comments
INSTALL_REQUIRES = PackageInfo.requirements()
SETUP_REQUIRES = ['pytest-runner', 'ruamel.yaml']
TESTS_REQUIRE = ['pytest']
setup(python_requires='~=3.7',
name=PKG_NAME,
description=SHORT_DESCRIPTION,
long_description=LONG_DESCRIPTION,
version=VERSION,
author=AUTHOR,
author_email=AUTHOR_EMAIL,
maintainer=MAINTAINER,
maintainer_email=MAINTAINER_EMAIL,
packages=PACKAGES,
include_package_data=INCLUDE_PACKAGE_DATA,
package_data=PACKAGE_DATA,
py_modules=PY_MODULES,
url=GITHUB_URL,
download_url=DOWNLOAD_URL,
classifiers=CLASSIFIERS,
platforms=PLATFORMS,
license=LICENSE,
setup_requires=SETUP_REQUIRES,
install_requires=INSTALL_REQUIRES,
tests_require=TESTS_REQUIRE)