46
46
PACKAGES = find_packages (exclude = ['ez_setup' , 'examples' , 'tests' ])
47
47
EXTRAS_REQUIRE = {
48
48
}
49
+ # You do not need to read beyond this line
49
50
PUBLISH_COMMAND = '{0} setup.py sdist bdist_wheel upload -r pypi' .format (
50
51
sys .executable )
51
52
GS_COMMAND = ('gs pyexcel-pygal v0.0.2 ' +
52
53
"Find 0.0.2 in changelog for more details" )
53
- here = os .path .abspath (os .path .dirname (__file__ ))
54
+ NO_GS_MESSAGE = ('Automatic github release is disabled. ' +
55
+ 'Please install gease to enable it.' )
56
+ UPLOAD_FAILED_MSG = (
57
+ 'Upload failed. please run "%s" yourself.' % PUBLISH_COMMAND )
58
+ HERE = os .path .abspath (os .path .dirname (__file__ ))
54
59
55
60
56
61
class PublishCommand (Command ):
@@ -73,17 +78,36 @@ def finalize_options(self):
73
78
def run (self ):
74
79
try :
75
80
self .status ('Removing previous builds...' )
76
- rmtree (os .path .join (here , 'dist' ))
81
+ rmtree (os .path .join (HERE , 'dist' ))
77
82
except OSError :
78
83
pass
79
84
80
85
self .status ('Building Source and Wheel (universal) distribution...' )
81
- if os .system (GS_COMMAND ) == 0 :
82
- os .system (PUBLISH_COMMAND )
86
+ run_status = True
87
+ if has_gease ():
88
+ run_status = os .system (GS_COMMAND ) == 0
89
+ else :
90
+ self .status (NO_GS_MESSAGE )
91
+ if run_status :
92
+ if os .system (PUBLISH_COMMAND ) != 0 :
93
+ self .status (UPLOAD_FAILED_MSG % PUBLISH_COMMAND )
83
94
84
95
sys .exit ()
85
96
86
97
98
+ def has_gease ():
99
+ """
100
+ test if github release command is installed
101
+
102
+ visit http://github.com/moremoban/gease for more info
103
+ """
104
+ try :
105
+ import gease # noqa
106
+ return True
107
+ except ImportError :
108
+ return False
109
+
110
+
87
111
def read_files (* files ):
88
112
"""Read files into setup"""
89
113
text = ""
@@ -144,7 +168,6 @@ def filter_out_test_code(file_handle):
144
168
include_package_data = True ,
145
169
zip_safe = False ,
146
170
classifiers = CLASSIFIERS ,
147
- setup_requires = ['gease' ],
148
171
cmdclass = {
149
172
'publish' : PublishCommand ,
150
173
}
0 commit comments