-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
163 lines (143 loc) · 4.82 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (C) Brian Moe (2013-2014), Duncan Macleod (2014-)
#
# This file is part of LIGO CIS Core.
#
# LIGO CIS Core is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# LIGO CIS Core is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with LIGO CIS Core. If not, see <http://www.gnu.org/licenses/>.
import os
from setuptools import (find_packages, setup)
from setuptools.command import (build_py, egg_info)
from distutils import log
PACKAGENAME = 'cisserver'
PROVIDES = 'cisserver'
AUTHOR = 'Brian Moe, Duncan Macleod'
AUTHOR_EMAIL = '[email protected]'
LICENSE = 'GPLv3'
VERSION_PY = os.path.join(PROVIDES.replace('.', os.path.sep), 'version.py')
cmdclass = {}
# -----------------------------------------------------------------------------
# Custom builders to write version.py
class GitVersionMixin(object):
"""Mixin class to add methods to generate version information from git.
"""
def write_version_py(self, pyfile):
"""Generate target file with versioning information from git VCS
"""
log.info("generating %s" % pyfile)
import vcs
gitstatus = vcs.GitStatus()
try:
with open(pyfile, 'w') as fobj:
gitstatus.write(fobj, author=AUTHOR, email=AUTHOR_EMAIL)
except:
if os.path.exists(pyfile):
os.unlink(pyfile)
raise
return gitstatus
def update_metadata(self):
"""Import package base and update distribution metadata
"""
import cisserver
self.distribution.metadata.version = cisserver.__version__
desc, longdesc = cisserver.__doc__.split('\n', 1)
self.distribution.metadata.description = desc
self.distribution.metadata.long_description = longdesc.strip('\n')
class CisBuildPy(build_py.build_py, GitVersionMixin):
"""Custom build_py command to deal with version generation
"""
def __init__(self, *args, **kwargs):
build_py.build_py.__init__(self, *args, **kwargs)
def run(self):
try:
self.write_version_py(VERSION_PY)
except ImportError:
raise
except:
if not os.path.isfile(VERSION_PY):
raise
self.update_metadata()
build_py.build_py.run(self)
cmdclass['build_py']= CisBuildPy
class CisEggInfo(egg_info.egg_info, GitVersionMixin):
"""Custom egg_info command to deal with version generation
"""
def finalize_options(self):
try:
self.write_version_py(VERSION_PY)
except ImportError:
raise
except:
if not os.path.isfile(VERSION_PY):
raise
if not self.distribution.metadata.version:
self.update_metadata()
egg_info.egg_info.finalize_options(self)
cmdclass['egg_info']= CisEggInfo
# -----------------------------------------------------------------------------
# Run setup
packagenames = find_packages()
scriptsdir = 'bin'
scripts = [os.path.join(scriptsdir, exe) for
exe in list(os.walk(scriptsdir))[0][2]]
setup(
# distribution metadata
name=PACKAGENAME,
provides=[PROVIDES],
version=None,
description=None,
long_description=None,
author=AUTHOR,
author_email=AUTHOR_EMAIL,
license=LICENSE,
url=None,
# package metadata
packages=packagenames,
include_package_data=True,
scripts=scripts,
cmdclass=cmdclass,
setup_requires=[
'GitPython',
'jinja2',
],
install_requires=[
'django >= 1.7',
'django-reversion',
'mysql-python'
],
requires=[
'django',
'djangorestframework',
'MySQLdb',
'markdown',
],
use_2to3=True,
classifiers=[
'Programming Language :: Python',
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'Natural Language :: English',
'Topic :: Scientific/Engineering',
'Topic :: Scientific/Engineering :: Astronomy',
'Topic :: Scientific/Engineering :: Physics',
'Topic :: Internet :: WWW/HTTP',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
'Operating System :: POSIX',
'Operating System :: Unix',
'Operating System :: MacOS',
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Environment :: Web Environment',
'Framework :: Django',
],
)