-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.py
151 lines (122 loc) · 4.49 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
import os
import io
import sys
import subprocess
from shutil import rmtree
from setuptools import setup, Command
# Package metadata.
NAME = 'pacumen'
DESCRIPTION = 'Exploring Artificial Intelligence with Pac-Man'
URL = 'http://github.com/jeffnyman/pacumen'
AUTHOR = 'Jeff Nyman'
EMAIL = 'jeffnyman@gmail.com'
REQUIRES_PYTHON = '>=3.6.0'
VERSION = None
here = os.path.abspath(os.path.dirname(__file__))
# Import the README and use it as the long-description. It is critical that
# the MANIFEST.in file lists the README.md file. Otherwise, this will not
# work.
try:
with io.open(os.path.join(here, 'README.md'), encoding='utf-8') as f:
long_description = '\n' + f.read()
except FileNotFoundError:
long_description = DESCRIPTION
# This load the package's __version__.py module as a dictionary. Part of the
# strategy here is that the __version__ attribute is part of __init__.py,
# which makes it an attribute of the module, as recommended in PEP 396. This
# does require the version string being reassembled here as part of the about
# dictionary. This enables the following behavior:
# >>> import quendor
# >>> print(quendor.__version__)
about = {}
if not VERSION:
project_slug = NAME.lower().replace("-", "_").replace(" ", "_")
with open(os.path.join(here, project_slug, '__version__.py')) as f:
exec(f.read(), about)
about['__version__'] = '.'.join(map(str, about['VERSION']))
else:
about['__version__'] = VERSION
# This class is used to support an upload command. This allows you to do this:
# $ python3 setup.py upload
# This command will create a universal wheel (and sdist) and upload the package
# to PyPi using Twine. This avoids the need to have a setup.cfg file in place.
# This will also create/upload a new git tag automatically. Do note: that to
# use the 'upload' functionality of this file, you must do the following:
# $ pip install twine
# One thing to note here is the upload command is apparently going to be
# deprecated by setuptools. See:
# https://github.com/pypa/setuptools/pull/1410
class UploadCommand(Command):
""" Support setup.py upload. """
description = 'Build and publish the package.'
user_options = []
@staticmethod
def status(message):
""" Custom method to print status updates in bold. """
print('\033[1m{0}\033[0m'.format(message))
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
try:
self.status('Removing previous builds...')
rmtree(os.path.join(here, 'dist'))
except OSError:
pass
self.status('Building Source and Wheel (pure Python) distribution...')
subprocess.check_call(
[sys.executable, 'setup.py', 'sdist', 'bdist_wheel']
)
self.status('Uploading the package to PyPI via Twine...')
subprocess.check_call(['twine', 'upload', 'dist/*'])
self.status('Pushing git tags...')
subprocess.check_call(
['git', 'tag', 'v{0}'.format(about['__version__'])]
)
subprocess.check_call(['git', 'push', '--tags'])
sys.exit()
# This is the standard setup for a Python project.
setup(
name=NAME,
version=about['__version__'],
description=DESCRIPTION,
long_description=long_description,
long_description_content_type='text/markdown',
keywords='artificial intelligence machine learning'.split(),
url=URL,
author=AUTHOR,
author_email=EMAIL,
license='MIT',
packages=[
'pacumen',
'pacumen.mechanics',
'pacumen.library',
'pacumen.displays',
'pacumen.rules'
],
zip_safe=False,
include_package_data=True,
python_requires=REQUIRES_PYTHON,
classifiers=[
# Reference: <URL:https://pypi.org/pypi?:action=list_classifiers>
'License :: OSI Approved :: MIT License',
'Programming Language :: Python',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Operating System :: POSIX',
'Operating System :: Microsoft :: Windows',
'Development Status :: 3 - Alpha',
'Intended Audience :: End Users/Desktop',
'Topic :: Scientific/Engineering :: Artificial Intelligence'
],
entry_points={
'console_scripts': [
'pacumen=pacumen.__main__:main'
],
},
cmdclass={
'upload': UploadCommand
}
)