Skip to content

Commit 0bc6f59

Browse files
committed
2 parents 97e5815 + bfe723b commit 0bc6f59

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

setup.py

+28-5
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,16 @@
4646
PACKAGES = find_packages(exclude=['ez_setup', 'examples', 'tests'])
4747
EXTRAS_REQUIRE = {
4848
}
49+
# You do not need to read beyond this line
4950
PUBLISH_COMMAND = '{0} setup.py sdist bdist_wheel upload -r pypi'.format(
5051
sys.executable)
5152
GS_COMMAND = ('gs pyexcel-pygal v0.0.2 ' +
5253
"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__))
5459

5560

5661
class PublishCommand(Command):
@@ -73,17 +78,36 @@ def finalize_options(self):
7378
def run(self):
7479
try:
7580
self.status('Removing previous builds...')
76-
rmtree(os.path.join(here, 'dist'))
81+
rmtree(os.path.join(HERE, 'dist'))
7782
except OSError:
7883
pass
7984

8085
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)
8394

8495
sys.exit()
8596

8697

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+
87111
def read_files(*files):
88112
"""Read files into setup"""
89113
text = ""
@@ -144,7 +168,6 @@ def filter_out_test_code(file_handle):
144168
include_package_data=True,
145169
zip_safe=False,
146170
classifiers=CLASSIFIERS,
147-
setup_requires=['gease'],
148171
cmdclass={
149172
'publish': PublishCommand,
150173
}

0 commit comments

Comments
 (0)