forked from tsionyx/pynogram
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
212 lines (168 loc) · 5.42 KB
/
setup.py
File metadata and controls
212 lines (168 loc) · 5.42 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
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
The main distribution file of a package.
Uses ideas from https://github.com/kennethreitz/setup.py
Note: To use the 'upload' functionality of this file, you must:
$ pip install twine
"""
from __future__ import unicode_literals, print_function
import io
import os
import sys
from shutil import rmtree
from setuptools import (
setup,
find_packages,
Command,
)
# noinspection PyPep8Naming
from setuptools.command.test import test as TestCommand
CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
ME = 'tsionyx'
def read_file(file_name, base_dir=CURRENT_DIR):
with io.open(os.path.join(base_dir, file_name), encoding='utf-8') as f:
return '\n' + f.read()
# Package meta-data.
# Do not rely on the current dir: it fails when install from sources
# NAME = os.path.basename(CURRENT_DIR)
NAME = 'pynogram'
DESCRIPTION = 'Nonogram solver'
URL = 'https://github.com/{}/{}'.format(ME, NAME),
EMAIL = '{}@gmail.com'.format(ME)
AUTHOR = 'Ivan Ladelschikov'
LICENSE = 'Apache License 2.0',
REQUIRED = [
'six',
'memoized',
'svgwrite',
]
# http://setuptools.readthedocs.io/en/latest/setuptools.html#declaring-extras-optional-features-with-their-own-dependencies
REQUIRED_EXTRAS = {
'web: python_version < "3.2"': ['futures'],
'web': ['tornado'],
}
TEST_WITH = [
'flake8',
'pytest',
'coverage',
'tox',
]
KEYWORDS = [
'game',
'nonogram',
'solver',
]
CLASSIFIERS = [
# Trove classifiers
# Full list: https://pypi.python.org/pypi?%3Aaction=list_classifiers
'Development Status :: 3 - Alpha',
'Environment :: Console',
'Environment :: Web Environment',
'Intended Audience :: Developers',
'Intended Audience :: Information Technology',
'License :: OSI Approved :: Apache Software License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Topic :: Games/Entertainment :: Puzzle Games',
]
# Load the package's __version__.py module as a dictionary.
about = {}
exec(read_file(os.path.join(NAME, '__version__.py')), about)
VERSION = about['__version__']
DOWNLOAD_URL = 'https://pypi.python.org/pypi/{}/{}'.format(NAME, VERSION),
SCRIPTS = [
'{0}={0}.__main__:main'.format(NAME),
'{0}-{1}={0}.{1}.__main__:main [{1}]'.format(NAME, 'web'),
]
class ToxTest(TestCommand):
description = 'Run tests with tox'
user_options = []
def initialize_options(self):
pass
@classmethod
def finalize_options(cls):
if 'test' in sys.argv:
sys.argv.remove('test')
def run(self):
self.install_dists(self.distribution)
# noinspection PyUnresolvedReferences
import tox
tox.cmdline()
class UploadCommand(Command):
"""
Support setup.py upload.
https://github.com/kennethreitz/setup.py/blob/master/setup.py
"""
description = 'Build and publish the package.'
user_options = []
@staticmethod
def status(s):
"""Prints things in bold."""
print('\033[1m{0}\033[0m'.format(s))
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
try:
self.status('Removing previous builds')
rmtree(os.path.join(CURRENT_DIR, 'dist'))
except OSError:
pass
self.status('Building Source and Wheel (universal) distribution')
os.system('{0} setup.py sdist bdist_wheel --universal'.format(sys.executable))
self.status('Uploading the package to PyPi via Twine')
os.system('twine upload dist/*')
sys.exit()
if __name__ == '__main__':
setup(
name=NAME,
version=VERSION,
packages=find_packages(exclude=('tests',)),
install_requires=REQUIRED,
# INCLUDING DATA FILES:
# http://setuptools.readthedocs.io/en/latest/setuptools.html#including-data-files
include_package_data=True,
# examples should ship with the package
# package_data={
# # explicitly str, not unicode
# # https://github.com/myint/language-check/issues/30
# str(NAME): ['examples/*.txt'],
# },
# LICENSE and docs are listed in MANIFEST.in
# so they will be included in source distribution
# but excluded from installation
exclude_package_data={
# explicitly str, not unicode
# https://github.com/myint/language-check/issues/30
str(''): ['LICENSE', '*.md', '*.gif']
},
# As it appears these files are not included in any package
# so they will be excluded anyway. However i kept this to be more verbose.
# REQUIREMENTS:
extras_require=REQUIRED_EXTRAS,
tests_require=TEST_WITH,
entry_points={
'console_scripts': SCRIPTS,
},
# PyPI metadata
author=AUTHOR,
author_email=EMAIL,
description=DESCRIPTION,
license=LICENSE,
keywords=KEYWORDS,
url=URL,
download_url=DOWNLOAD_URL,
long_description=read_file('README.rst'),
classifiers=CLASSIFIERS,
cmdclass={
'test': ToxTest,
'upload': UploadCommand,
}
)