66
66
'xlsx' : ['pyexcel-xlsx>=0.4.0' ],
67
67
'ods' : ['pyexcel-ods3>=0.4.0' ],
68
68
}
69
+ # You do not need to read beyond this line
69
70
PUBLISH_COMMAND = '{0} setup.py sdist bdist_wheel upload -r pypi' .format (
70
71
sys .executable )
71
72
GS_COMMAND = ('gs django-excel v0.0.9 ' +
72
73
"Find 0.0.9 in changelog for more details" )
73
- here = os .path .abspath (os .path .dirname (__file__ ))
74
+ NO_GS_MESSAGE = ('Automatic github release is disabled. ' +
75
+ 'Please install gease to enable it.' )
76
+ UPLOAD_FAILED_MSG = ('Upload failed. please run "%s" yourself.' )
77
+ HERE = os .path .abspath (os .path .dirname (__file__ ))
74
78
75
79
76
80
class PublishCommand (Command ):
@@ -93,17 +97,36 @@ def finalize_options(self):
93
97
def run (self ):
94
98
try :
95
99
self .status ('Removing previous builds...' )
96
- rmtree (os .path .join (here , 'dist' ))
100
+ rmtree (os .path .join (HERE , 'dist' ))
97
101
except OSError :
98
102
pass
99
103
100
104
self .status ('Building Source and Wheel (universal) distribution...' )
101
- if os .system (GS_COMMAND ) == 0 :
102
- os .system (PUBLISH_COMMAND )
105
+ run_status = True
106
+ if has_gease ():
107
+ run_status = os .system (GS_COMMAND ) == 0
108
+ else :
109
+ self .status (NO_GS_MESSAGE )
110
+ if run_status :
111
+ if os .system (PUBLISH_COMMAND ) != 0 :
112
+ self .status (UPLOAD_FAILED_MSG % PUBLISH_COMMAND )
103
113
104
114
sys .exit ()
105
115
106
116
117
+ def has_gease ():
118
+ """
119
+ test if github release command is installed
120
+
121
+ visit http://github.com/moremoban/gease for more info
122
+ """
123
+ try :
124
+ import gease # noqa
125
+ return True
126
+ except ImportError :
127
+ return False
128
+
129
+
107
130
def read_files (* files ):
108
131
"""Read files into setup"""
109
132
text = ""
@@ -164,7 +187,6 @@ def filter_out_test_code(file_handle):
164
187
include_package_data = True ,
165
188
zip_safe = False ,
166
189
classifiers = CLASSIFIERS ,
167
- setup_requires = ['gease' ],
168
190
cmdclass = {
169
191
'publish' : PublishCommand ,
170
192
}
0 commit comments