6666 'xlsx' : ['pyexcel-xlsx>=0.4.0' ],
6767 'ods' : ['pyexcel-ods3>=0.4.0' ],
6868}
69+ # You do not need to read beyond this line
6970PUBLISH_COMMAND = '{0} setup.py sdist bdist_wheel upload -r pypi' .format (
7071 sys .executable )
7172GS_COMMAND = ('gs django-excel v0.0.9 ' +
7273 "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__ ))
7478
7579
7680class PublishCommand (Command ):
@@ -93,17 +97,36 @@ def finalize_options(self):
9397 def run (self ):
9498 try :
9599 self .status ('Removing previous builds...' )
96- rmtree (os .path .join (here , 'dist' ))
100+ rmtree (os .path .join (HERE , 'dist' ))
97101 except OSError :
98102 pass
99103
100104 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 )
103113
104114 sys .exit ()
105115
106116
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+
107130def read_files (* files ):
108131 """Read files into setup"""
109132 text = ""
@@ -164,7 +187,6 @@ def filter_out_test_code(file_handle):
164187 include_package_data = True ,
165188 zip_safe = False ,
166189 classifiers = CLASSIFIERS ,
167- setup_requires = ['gease' ],
168190 cmdclass = {
169191 'publish' : PublishCommand ,
170192 }
0 commit comments