Skip to content

Commit 62f0b77

Browse files
committed
update setup.py
1 parent df0a44e commit 62f0b77

File tree

1 file changed

+45
-20
lines changed

1 file changed

+45
-20
lines changed

setup.py

Lines changed: 45 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,26 @@
2020
from reversion_compare import __version__
2121

2222

23+
PACKAGE_ROOT = os.path.dirname(os.path.abspath(__file__))
24+
25+
26+
# convert README.creole on-the-fly to ReSt, see also:
27+
# https://github.com/jedie/python-creole/wiki/Use-In-Setup/
28+
check_readme="publish" in sys.argv or "check" in sys.argv or "register" in sys.argv or "sdist" in sys.argv or "--long-description" in sys.argv
29+
try:
30+
from creole.setup_utils import get_long_description
31+
except ImportError as err:
32+
if check_readme:
33+
raise ImportError("%s - Please install python-creole >= v0.8 - e.g.: pip install python-creole" % err)
34+
long_description = None
35+
else:
36+
if check_readme:
37+
print("\nCheck creole2ReSt:")
38+
long_description = get_long_description(PACKAGE_ROOT)
39+
if check_readme:
40+
print("OK")
41+
42+
2343
if "publish" in sys.argv:
2444
"""
2545
Build and upload to PyPi, if...
@@ -32,6 +52,8 @@
3252
The cli arguments will be pass to 'twine'. So this is possible:
3353
* Display 'twine' help page...: ./setup.py publish --help
3454
* use testpypi................: ./setup.py publish --repository=test
55+
56+
TODO: Look at: https://github.com/zestsoftware/zest.releaser
3557
"""
3658
# Imports here, so it's easier to copy&paste this complete code block ;)
3759
import subprocess
@@ -101,14 +123,24 @@ def verbose_check_call(*args):
101123
print(output)
102124
sys.exit(-1)
103125

104-
print("\ngit tag version (will raise a error of tag already exists)")
105-
verbose_check_call("git", "tag", "v%s" % __version__)
126+
print("\ncheck if pull is needed")
127+
verbose_check_call("git", "fetch", "--all")
128+
call_info, output = verbose_check_output("git", "log", "HEAD..origin/master", "--oneline")
129+
print("\t%s" % call_info)
130+
if output == "":
131+
print("OK")
132+
else:
133+
print("\n *** ERROR: git repro is not up-to-date:")
134+
print(output)
135+
sys.exit(-1)
136+
verbose_check_call("git", "push")
106137

107138
print("\nCleanup old builds:")
108139
def rmtree(path):
109140
path = os.path.abspath(path)
110-
print("\tremove tree:", path)
111-
shutil.rmtree(path)
141+
if os.path.isdir(path):
142+
print("\tremove tree:", path)
143+
shutil.rmtree(path)
112144
rmtree("./dist")
113145
rmtree("./build")
114146

@@ -124,6 +156,9 @@ def rmtree(path):
124156
log.write(output)
125157
print("Build output is in log file: %r" % log_filename)
126158

159+
print("\ngit tag version (will raise a error of tag already exists)")
160+
verbose_check_call("git", "tag", "v%s" % __version__)
161+
127162
print("\nUpload with twine:")
128163
twine_args = sys.argv[1:]
129164
twine_args.remove("publish")
@@ -132,26 +167,12 @@ def rmtree(path):
132167
from twine.commands.upload import main as twine_upload
133168
twine_upload(twine_args)
134169

135-
print("\ngit push to server")
136-
verbose_check_call("git", "push")
170+
print("\ngit push tag to server")
137171
verbose_check_call("git", "push", "--tags")
138172

139173
sys.exit(0)
140174

141175

142-
PACKAGE_ROOT = os.path.dirname(os.path.abspath(__file__))
143-
144-
145-
# convert creole to ReSt on-the-fly, see also:
146-
# https://code.google.com/p/python-creole/wiki/UseInSetup
147-
try:
148-
from creole.setup_utils import get_long_description
149-
except ImportError as err:
150-
if "check" in sys.argv or "register" in sys.argv or "sdist" in sys.argv or "--long-description" in sys.argv:
151-
raise ImportError("%s - Please install python-creole >= v0.8 - e.g.: pip install python-creole" % err)
152-
long_description = None
153-
else:
154-
long_description = get_long_description(PACKAGE_ROOT)
155176

156177

157178
def get_authors():
@@ -193,7 +214,11 @@ def get_authors():
193214
# "Intended Audience :: End Users/Desktop",
194215
"License :: OSI Approved :: GNU General Public License (GPL)",
195216
"Programming Language :: Python",
196-
'Framework :: Django',
217+
"Programming Language :: Python :: 2.7",
218+
"Programming Language :: Python :: 3.4",
219+
"Framework :: Django",
220+
"Framework :: Django :: 1.7",
221+
"Framework :: Django :: 1.8",
197222
"Topic :: Database :: Front-Ends",
198223
"Topic :: Documentation",
199224
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",

0 commit comments

Comments
 (0)