From 1d9ad14fa918866c418067e774f65cede8e38682 Mon Sep 17 00:00:00 2001 From: Vincent Jacques Date: Fri, 22 Mar 2013 18:29:14 +0100 Subject: [PATCH] Use bash for manage.sh --- manage.sh | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ publish.sh | 33 -------------------------- setup.py | 61 ------------------------------------------------ 3 files changed, 68 insertions(+), 94 deletions(-) create mode 100755 manage.sh delete mode 100755 publish.sh diff --git a/manage.sh b/manage.sh new file mode 100755 index 00000000..c9d5ea3b --- /dev/null +++ b/manage.sh @@ -0,0 +1,68 @@ +#!/bin/bash +# -*- coding: utf-8 -*- + +function publish { + check + test + bump + readme + doc + push +} + +function check { + pep8 --ignore=E501 github setup.py || exit +} + +function test { + python3 setup.py test --quiet || exit + + coverage run --branch --include=github/*.py --omit=github/tests/*.py setup.py test --quiet || exit + coverage report --show-missing || exit +} + +function bump { + previousVersion=$( grep '^version =' setup.py | sed 's/version = \"\(.*\)\"/\1/' ) + echo "Next version number? (previous: '$previousVersion')" + read version + sed -i -b "s/version = .*/version = \"$version\"/" setup.py +} + +function readme { + git log v$previousVersion.. --oneline + + echo "Edit README.rst and doc/changes.rst now, then press enter" + read foobar +} + +function doc { + rm -rf doc/build + mkdir doc/build + cd doc/build + git init + sphinx-build -b html -d doctrees .. . || exit + touch .nojekyll + echo /doctrees/ > .gitignore + git add . || exit + git commit --message "Automatic generation" || exit + git push --force ../.. HEAD:gh-pages || exit +} + +function push { + echo "Break (Ctrl+c) here if something is wrong. Else, press enter" + read foobar + + git commit -am "Publish version $version" + + cp COPYING* github + python setup.py sdist upload + rm -rf github/COPYING* + + git tag -m "Version $version" v$version + + git push github master master:develop + git push --force github gh-pages + git push --tags +} + +$1 diff --git a/publish.sh b/publish.sh deleted file mode 100755 index 4c04e2a3..00000000 --- a/publish.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -# -*- coding: utf-8 -*- - -python setup.py publish || exit - -### @todo make_doc AFTER having incremented version - -previousVersion=$( grep '^version =' setup.py | sed 's/version = \"\(.*\)\"/\1/' ) -echo "Next version number? (previous: '$previousVersion')" -read version -sed -i -b "s/version = .*/version = \"$version\"/" setup.py -git add setup.py - -git log v$previousVersion.. --oneline - -echo "Edit README.rst and doc/changes.rst now, then press enter" -read foobar -git add README.rst doc/changes.rst - -git commit -m "Publish version $version" - -echo "Break (Ctrl+c) here if something is wrong. Else, press enter" -read foobar - -cp COPYING* github -python setup.py sdist upload -rm -rf github/COPYING* - -git tag -m "Version $version" v$version - -git push github master master:develop -git push --force github gh-pages -git push --tags diff --git a/setup.py b/setup.py index 830e4834..7abd6e21 100755 --- a/setup.py +++ b/setup.py @@ -23,61 +23,6 @@ import os.path version = "1.12.2" -def execute(*args): - subprocess.check_call(args) - - -class SimpleCommand(setuptools.Command): - user_options = [] - - def __init__(self, dist, *args, **kwds): - setuptools.Command.__init__(self, dist, *args, **kwds) - self.dist = dist - - def initialize_options(self): - pass - - def finalize_options(self): - pass - - -class Check(SimpleCommand): - def run(self): - execute("pep8", "--ignore=E501", "github", "setup.py") # pip install pep8 - - -class Coverage(SimpleCommand): - def run(self): - execute("coverage", "run", "--branch", "--include=github/*.py", "--omit=github/tests/*.py", "setup.py", "test", "--quiet") - execute("python3", "setup.py", "test", "--quiet") - execute("coverage", "report", "--show-missing") - - -class MakeDoc(SimpleCommand): - def run(self): - d = "doc/build" - if os.path.exists(d): - shutil.rmtree(d) - os.makedirs(d) - os.chdir(d) - execute("git", "init") - execute("sphinx-build", "-b", "html", "-d", "doctrees", "..", ".") - open(".nojekyll", "w").close() - f = open(".gitignore", "w") - f.write("/doctrees/\n") - f.close() - execute("git", "add", ".") - execute("git", "commit", "--message", "Automatic generation") - execute("git", "push", "--force", "../..", "HEAD:gh-pages") - - -class Publish(SimpleCommand): - def run(self): - Check(self.dist).run() - Coverage(self.dist).run() - MakeDoc(self.dist).run() - - if __name__ == "__main__": setuptools.setup( name="PyGithub", @@ -132,11 +77,5 @@ if __name__ == "__main__": "Topic :: Software Development", ], test_suite="github.tests.AllTests", - cmdclass={ - "check_": Check, - "coverage": Coverage, - "make_doc": MakeDoc, - "publish": Publish, - }, use_2to3=True )