X Tutup
Skip to content

Commit 657b38f

Browse files
committed
SESPRINGPYTHON-50: Updated make_release and the setup.py scripts, so that sub-versioning can be embedded. See make_release.py --help for more information. Now has options for --clean, --build (which just calls --package), --test, --package, --publish, and --register. Optional --version allows appending a subversion tag for build and package. See --help for more details on what this will be. All output is put into target directory.
git-svn-id: https://src.springframework.org/svn/se-springpython-py/trunk/springpython@63 ce8fead1-4192-4296-8608-a705134b927f
1 parent 9a170d2 commit 657b38f

File tree

3 files changed

+70
-44
lines changed

3 files changed

+70
-44
lines changed

make_release.py

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -20,44 +20,44 @@
2020
import sys
2121
from optparse import OptionParser
2222

23-
def main(argv):
24-
"""This script is a shortcut to making the python distribution releases. This should be run from the folder it is in."""
25-
26-
parser = OptionParser(usage="usage: %prog [-h|--help] [options]")
27-
parser.add_option("-c", "--clean", action="store_true", dest="clean", default=False, help="Clean out current target build.")
28-
parser.add_option("-b", "--build", action="store", dest="build", help="Build everything, and optionally put a special tag on the end of the version.")
29-
parser.add_option("-t", "--test", action="store_true", dest="test", default=False, help="Test everything, generating JUnit-style XML outputs.")
30-
parser.add_option("", "--package", action="store_true", dest="package", default=False, help="Package everything up into a tarball for release to sourceforge.")
31-
parser.add_option("", "--publish", action="store_true", dest="publish", default=False, help="Publish this release to the deployment server.")
32-
parser.add_option("-r", "--register", action="store_true", dest="register", default=False, help="Register this release with http://pypi.python.org/pypi")
33-
(options, args) = parser.parse_args()
34-
35-
parser.set_defaults(build="")
36-
37-
if options.clean:
38-
print "Cleaning out the target directory"
39-
os.system("rm -rf target")
40-
41-
elif options.build is not "":
42-
print "+++ Working on this option."
43-
44-
elif options.build:
45-
print "+++ Working on this option."
46-
47-
elif options.package:
48-
# Make the main source code distribution
49-
os.system("cd src ; python setup.py sdist ; mv dist/* .. ; \\rm -rf dist ; \\rm -f MANIFEST ")
50-
51-
# Make the sample distribution
52-
os.system("cd samples ; python setup.py sdist ; mv dist/* .. ; \\rm -rf dist ; \\rm -f MANIFEST ")
53-
54-
elif options.publish:
55-
print "+++ Upload the tarballs using sftp manually to <user>@frs.sourceforge.net, into dir uploads and create a release."
56-
57-
elif options.register:
58-
os.system("cd src ; python setup.py register")
59-
os.system("cd samples ; python setup.py register")
60-
61-
62-
if __name__ == "__main__":
63-
main(sys.argv[1:])
23+
"""This script is a shortcut to making the python distribution releases. This should be run from the folder it is in."""
24+
25+
# This is the base version of this release.
26+
version = "0.6.0"
27+
28+
parser = OptionParser(usage="usage: %prog [-h|--help] [options]")
29+
parser.add_option("-c", "--clean", action="store_true", dest="clean", default=False, help="Clean out current target build.")
30+
parser.add_option("-b", "--build", action="store_true", dest="package", default=False, help="Same as the package option.")
31+
parser.add_option("-v", "--version", action="store", dest="version", default="", help="For --package, this specifies a special tag, generate version tag %s-<version>" % version)
32+
parser.add_option("-t", "--test", action="store_true", dest="test", default=False, help="Test everything, generating JUnit-style XML outputs.")
33+
parser.add_option("", "--package", action="store_true", dest="package", default=False, help="Package everything up into a tarball for release to sourceforge.")
34+
parser.add_option("", "--publish", action="store_true", dest="publish", default=False, help="Publish this release to the deployment server.")
35+
parser.add_option("-r", "--register", action="store_true", dest="register", default=False, help="Register this release with http://pypi.python.org/pypi")
36+
(options, args) = parser.parse_args()
37+
38+
if options.version:
39+
version += "-%s" % options.version
40+
41+
if options.clean:
42+
print "Cleaning out the target directory"
43+
os.system("rm -rf target")
44+
45+
elif options.test:
46+
os.system("mkdir -p target/test-results")
47+
os.system("nosetests --with-nosexunit --source-folder=src --where=test/springpythontest --xml-report-folder=target/test-results")
48+
49+
elif options.package:
50+
os.system("mkdir -p target/test-results")
51+
os.system("cd src ; python setup.py --version %s sdist ; mv dist/* .. ; \\rm -rf dist ; \\rm -f MANIFEST" % version)
52+
os.system("cd samples ; python setup.py --version %s sdist ; mv dist/* .. ; \\rm -rf dist ; \\rm -f MANIFEST" % version)
53+
os.system("mv *.tar.gz target")
54+
55+
elif options.publish:
56+
# TODO(8/28/2008 GLT): Implement automated solution for this.
57+
print "+++ Upload the tarballs using sftp manually to <user>@frs.sourceforge.net, into dir uploads and create a release."
58+
59+
elif options.register:
60+
# TODO(8/28/2008 GLT): Test this part when making official release and registering to PyPI.
61+
os.system("cd src ; python setup.py --version %s register" % version)
62+
os.system("cd samples ; python setup.py --version %s register" % version)
63+

samples/setup.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,24 @@
1919
NOTE: This setup.py lists two licenses, Apache Server License and GPL. That is because
2020
the stylesheet inside SpringWiki is GPL. Everything else is ASL.
2121
"""
22-
22+
import re
23+
import sys
2324
from distutils.core import setup
25+
from optparse import OptionParser
26+
27+
parser = OptionParser(usage="usage: %prog [-h|--help] [options]")
28+
parser.add_option("", "--version", action="store", dest="version", help="Define the version of this build.")
29+
(options, args) = parser.parse_args()
30+
31+
if re.match(r"\d\.\d", options.version):
32+
# Remove version argument
33+
sys.argv = [sys.argv[0]] + sys.argv[-1:]
34+
else:
35+
print "Version not correctly specified => version = %s Arguments => %s" % (options.version, sys.argv)
36+
sys.exit(1)
2437

2538
setup(name='springpython-samples',
26-
version='0.6.0',
39+
version=options.version,
2740
description='Spring Python samples',
2841
long_description='A collection of small samples utilizing the features of Spring Python.',
2942
author='Greg L. Turnquist',

src/setup.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,28 @@
1414
See the License for the specific language governing permissions and
1515
limitations under the License.
1616
"""
17+
import re
1718
import sys
1819
from distutils.core import setup
20+
from optparse import OptionParser
1921

2022
if sys.version_info < (2, 3):
2123
print "Spring Python only supports Python 2.3 and higher"
2224
sys.exit(1)
2325

26+
parser = OptionParser(usage="usage: %prog [-h|--help] [options]")
27+
parser.add_option("", "--version", action="store", dest="version", help="Define the version of this build.")
28+
(options, args) = parser.parse_args()
29+
30+
if re.match(r"\d\.\d", options.version):
31+
# Remove version argument
32+
sys.argv = [sys.argv[0]] + sys.argv[-1:]
33+
else:
34+
print "Version not correctly specified => version = %s Arguments => %s" % (options.version, sys.argv)
35+
sys.exit(1)
36+
2437
setup(name='springpython',
25-
version='0.6.0',
38+
version=options.version,
2639
description='Spring Python',
2740
long_description='Spring Python is an offshoot of the Java-based SpringFramework, targeted for Python. Spring provides many useful features, and I wanted those same features available when working with Python.',
2841
author='Greg L. Turnquist',

0 commit comments

Comments
 (0)
X Tutup