From bf1e937db4b3b1d37acc55fe0c4f1b65aa003af2 Mon Sep 17 00:00:00 2001 From: Bastian Kleineidam Date: Mon, 17 Dec 2012 18:14:58 +0100 Subject: [PATCH] Build and documentation updates --- Makefile | 107 +++++++++++++++++++++++++----------- doc/README-Download.md.tmpl | 36 ------------ patool.freecode | 6 +- patoolib/__init__.py | 1 + patoolib/baker.py | 9 ++- patoolib/programs/mac.py | 1 + patoolib/programs/tar.py | 1 + patoolib/util.py | 3 + 8 files changed, 93 insertions(+), 71 deletions(-) delete mode 100644 doc/README-Download.md.tmpl diff --git a/Makefile b/Makefile index f3e760e..2753d19 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,20 @@ # This Makefile is only used by developers. PYVER:=2.7 PYTHON:=python$(PYVER) -APPNAME:=patool VERSION:=$(shell $(PYTHON) setup.py --version) -ARCHIVE_SOURCE:=$(APPNAME)-$(VERSION).tar.gz -ARCHIVE_RPM:=$(APPNAME)-$(VERSION)-1.x86_64.rpm -ARCHIVE_WIN32:=$(APPNAME)-$(VERSION).exe -PY_FILES_DIRS := patool setup.py patoolib tests +MAINTAINER:=$(shell $(PYTHON) setup.py --maintainer) +AUTHOR:=$(shell $(PYTHON) setup.py --author) +APPNAME:=$(shell $(PYTHON) setup.py --name) +LAPPNAME:=$(shell echo $(APPNAME)|tr "[A-Z]" "[a-z]") +ARCHIVE_SOURCE:=$(LAPPNAME)-$(VERSION).tar.gz +ARCHIVE_RPM:=$(LAPPNAME)-$(VERSION)-1.x86_64.rpm +ARCHIVE_WIN32:=$(LAPPNAME)-$(VERSION).exe +GITUSER:=wummel +GITREPO:=$(LAPPNAME) +HOMEPAGE:=$(HOME)/public_html/$(LAPPNAME).git +DEBUILDDIR:=$(HOME)/projects/debian/unofficial +DEBORIGFILE:=$(DEBUILDDIR)/$(LAPPNAME)_$(VERSION).orig.tar.gz +DEBPACKAGEDIR:=$(DEBUILDDIR)/$(LAPPNAME)-$(VERSION) PY2APPOPTS ?= ifeq ($(shell uname),Darwin) CHMODMINUSMINUS:= @@ -31,7 +39,8 @@ chmod: dist: $(PYTHON) setup.py bdist_rpm - git archive --format=tar --prefix=$(APPNAME)-$(VERSION)/ HEAD | gzip -9 > dist/$(ARCHIVE_SOURCE) + rm dist/*.src.rpm + git archive --format=tar --prefix=$(LAPPNAME)-$(VERSION)/ HEAD | gzip -9 > dist/$(ARCHIVE_SOURCE) [ ! -f ../$(ARCHIVE_WIN32) ] || cp ../$(ARCHIVE_WIN32) dist sign: @@ -39,23 +48,37 @@ sign: [ -f dist/$(ARCHIVE_WIN32).asc ] || gpg --detach-sign --armor dist/$(ARCHIVE_WIN32) [ -f dist/$(ARCHIVE_RPM).asc ] || gpg --detach-sign --armor dist/$(ARCHIVE_RPM) -upload: dist/README.md sign - github-upload wummel patool dist/* - make -C $(HOMEPAGE) +upload: + github-upload $(GITUSER) $(GITREPO) dist/$(ARCHIVE_SOURCE)* dist/$(ARCHIVE_WIN32)* dist/$(ARCHIVE_RPM)* -dist/README.md: doc/README-Download.md.tmpl doc/changelog.txt -# copying readme for release - sed -e 's/{APPNAME}/$(APPNAME)/g' -e 's/{VERSION}/$(VERSION)/g' $< > $@ -# append changelog - awk '/released/ {c++}; c==2 {exit}; {print " " $$0}' doc/changelog.txt >> $@ +homepage: +# update metadata + @echo "version: $(VERSION)" > $(HOMEPAGE)/info.yaml + @echo "name: $(APPNAME)" >> $(HOMEPAGE)/info.yaml + @echo "lname: $(LAPPNAME)" >> $(HOMEPAGE)/info.yaml + @echo "maintainer: $(MAINTAINER)" >> $(HOMEPAGE)/info.yaml + @echo "author: $(AUTHOR)" >> $(HOMEPAGE)/info.yaml +# generate static files + make -C $(HOMEPAGE) gen -release: clean releasecheck dist upload +tag: +# add and push the version tag git tag upstream/$(VERSION) + git push --tags origin upstream/$(VERSION) + +# Make a new release by calling all the distinct steps in the correct order. +# Each step is a separate target so that it's easy to do this manually if +# anything screwed up. +release: clean releasecheck + $(MAKE) dist sign upload homepage tag register deb + +register: @echo "Register at Python Package Index..." $(PYTHON) setup.py register - freecode-submit < patool.freecode + @echo "Submitting to freecode.org..." + freecode-submit < $(LAPPNAME).freecode -releasecheck: check test +releasecheck: test check @if egrep -i "xx\.|xxxx|\.xx" doc/changelog.txt > /dev/null; then \ echo "Could not release: edit doc/changelog.txt release date"; false; \ fi @@ -63,48 +86,70 @@ releasecheck: check test echo "Missing WIN32 distribution archive at ../$(ARCHIVE_WIN32)"; \ false; \ fi - @if ! grep "Version: $(VERSION)" patool.freecode > /dev/null; then \ - echo "Could not release: edit patool.freecode version"; false; \ + @if ! grep "Version: $(VERSION)" $(LAPPNAME).freecode > /dev/null; then \ + echo "Could not release: edit $(LAPPNAME).freecode version"; false; \ fi -# Build OSX installer app: clean chmod +# Build OSX installer $(PYTHON) setup.py py2app $(PY2APPOPTS) +check: # The check programs used here are mostly local scripts on my private system. # So for other developers there is no need to execute this target. -check: - [ ! -d .svn ] || check-nosvneolstyle -v check-copyright check-pofiles -v py-tabdaddy py-unittest2-compat tests/ + $(MAKE) doccheck + +doccheck: + py-check-docstrings --force \ + patoolib \ + patool \ + *.py pyflakes: - pyflakes $(PY_FILES_DIRS) + pyflakes setup.py patool patoolib tests count: - @sloccount patool patoolib | grep "Total Physical Source Lines of Code" +# print some code statistics + @sloccount patool patoolib clean: find . -name \*.pyc -delete find . -name \*.pyo -delete - rm -rf build dist doc/README.md + rm -rf build dist test: $(PYTHON) -m pytest $(PYTESTOPTS) $(TESTOPTS) $(TESTS) -doc/patool.txt: doc/patool.1 - cols=`stty size | cut -d" " -f2`; stty cols 72; man -l doc/patool.1 | perl -pe 's/.\cH//g' > doc/patool.txt; stty cols $$cols +doc/$(LAPPNAME).txt: doc/$(LAPPNAME).1 +# make text file from man page for Windows builds + cols=`stty size | cut -d" " -f2`; stty cols 72; man -l $< | sed -e 's/.\cH//g' > $@; stty cols $$cols deb: - git-buildpackage --git-upstream-branch=master --git-debian-branch=debian --git-ignore-new +# build a debian package + [ -f $(DEBORIGFILE) ] || cp dist/$(ARCHIVE_SOURCE) $(DEBORIGFILE) $(DEBUILDDIR)/$(APPNAME)_$(VERSION).orig.tar.gz + sed -i 's/VERSION:=.*/VERSION:=$(VERSION)/' $(DEBUILDDIR)/$(LAPPNAME).mak + [ -d $(DEBPACKAGEDIR) ] || (cd $(DEBUILDDIR); \ + patool extract $(DEBORIGFILE); \ + cd $(CURDIR); \ + git checkout debian; \ + cp -r debian $(DEBPACKAGEDIR); \ + git checkout master) + rm -f $(DEBUILDDIR)/$(PACKAGE) + $(MAKE) -C $(DEBUILDDIR) $(PACKAGE) update-copyright: - update-copyright --holder="Bastian Kleineidam" +# update-copyright is a local tool which updates the copyright year for each +# modified file. + update-copyright --holder="$(MAINTAINER)" changelog: - github-changelog $(DRYRUN) wummel patool doc/changelog.txt +# github-changelog is a local tool which parses the changelog and automatically +# closes issues mentioned in the changelog entries. + github-changelog $(DRYRUN) $(GITUSER) $(GITREPO) doc/changelog.txt .PHONY: changelog update-copyright deb test clean count pyflakes check app -.PHONY: releasecheck release upload sign dist chmod all +.PHONY: releasecheck release upload sign dist chmod all tag register diff --git a/doc/README-Download.md.tmpl b/doc/README-Download.md.tmpl deleted file mode 100644 index e0590ec..0000000 --- a/doc/README-Download.md.tmpl +++ /dev/null @@ -1,36 +0,0 @@ -{APPNAME} Downloads -====================== - -{APPNAME} {VERSION} is available for download for Windows and -Linux systems and in source format. - -Files ------- - -* `{APPNAME}-{VERSION}.exe`: - The Windows installer. If you run Windows, use this. The installer is - signed with a local certificate signature. -* `{APPNAME}-{VERSION}-1.x86_64.rpm`: - The Linux RPM package compiled for the x86/64bit architecture. - If you have an RPM based Linux distribution and a 64bit x86 processor, - use this. -* `{APPNAME}-{VERSION}.tar.gz`: - The source code. See `doc/install.txt` for compilation and installation - instructions. - -The `.asc` files are GPG signatures that you can use to verify that the -download is indeed made by the owner of the GPG key below (ie. me). -For example download the `.tar.gz.asc` file in the same directory as the -`.tar.gz` file and run `gpg --verify {APPNAME}-{VERSION}.tar.gz` - -The GPG key used to sign these packages is 32EC6F3E. It can be -downloaded with `gpg --keyserver wwwkeys.pgp.net --recv-keys 32EC6F3E`. - -The `.sha1` files contain checksums that you can use to verify the -file integrity. Download the `.sha1` file in the same directory as -the `.tar.gz` file and run `sha1sum -c {APPNAME}-{VERSION}.tar.gz.sha1` - - -Changelog for this release ---------------------------- - diff --git a/patool.freecode b/patool.freecode index b7bb5b1..7461c2a 100644 --- a/patool.freecode +++ b/patool.freecode @@ -1,5 +1,5 @@ Project: patool -Version: 0.17 +Version: 0.18 Release-Focus: Minor feature enhancements Hide: N Website-URL: http://github.com/wummel/patool @@ -9,5 +9,5 @@ GIT-Tree-URL: https://github.com/wummel/patool.git Windows-installer-URL: http://github.com/downloads/wummel/patool/patool-${version}.win32.exe Support has been added for chmlib and archmage handling -Microsoft ITSS/CHM (.chm) archives. Also the project moved from -sourceforge to github. +Microsoft ITSS/CHM (.chm) archives. The project moved from +Sourceforge to Github. diff --git a/patoolib/__init__.py b/patoolib/__init__.py index e4bda93..480846b 100644 --- a/patoolib/__init__.py +++ b/patoolib/__init__.py @@ -526,6 +526,7 @@ def _handle_archive (archive, command, *args, **kwargs): def get_archive_cmdlist_func (program, command, format): + """Get the Python function that executes the given program.""" # get python module for given archive program key = util.stripext(os.path.basename(program).lower()) modulename = ".programs." + ProgramModules.get(key, key) diff --git a/patoolib/baker.py b/patoolib/baker.py index 3cf3db1..c2cf8b3 100644 --- a/patoolib/baker.py +++ b/patoolib/baker.py @@ -107,7 +107,9 @@ def totype(v, default): return v -class CommandError(Exception): pass +class CommandError(Exception): + """Error for baker commands.""" + pass class Cmd(object): @@ -116,6 +118,7 @@ class Cmd(object): def __init__(self, name, fn, argnames, keywords, shortopts, has_varargs, has_kwargs, docstring, paramdocs): + """Store given metadata.""" self.name = name self.fn = fn self.argnames = argnames @@ -129,7 +132,10 @@ class Cmd(object): class Baker(object): + """Main class.""" + def __init__(self): + """Initialize command variables.""" self.commands = {} self.defaultcommand = None @@ -343,6 +349,7 @@ class Baker(object): sys.exit(0) def parse_args(self, scriptname, cmd, argv): + """Parse command arguments.""" keywords = cmd.keywords shortopts = cmd.shortopts diff --git a/patoolib/programs/mac.py b/patoolib/programs/mac.py index 608b526..53d38c6 100644 --- a/patoolib/programs/mac.py +++ b/patoolib/programs/mac.py @@ -34,5 +34,6 @@ def create_ape (archive, compression, cmd, *args, **kwargs): def test_ape (archive, compression, cmd, **kwargs): + """Test an APE archive.""" cmdlist = [cmd, archive, '-v'] return cmdlist diff --git a/patoolib/programs/tar.py b/patoolib/programs/tar.py index 3980059..5858e83 100644 --- a/patoolib/programs/tar.py +++ b/patoolib/programs/tar.py @@ -42,6 +42,7 @@ def create_tar (archive, compression, cmd, *args, **kwargs): return cmdlist def add_tar_opts (cmdlist, compression, verbose): + """Add tar options to cmdlist.""" progname = os.path.basename(cmdlist[0]) if compression == 'gzip': cmdlist.append('-z') diff --git a/patoolib/util.py b/patoolib/util.py index 1d07a56..13294eb 100644 --- a/patoolib/util.py +++ b/patoolib/util.py @@ -91,10 +91,13 @@ class memoized (object): not re-evaluated.""" def __init__(self, func): + """Set func and init cache.""" self.func = func self.cache = {} def __call__(self, *args): + """Try to find result for function arguments in local cache or + execute the function and fill the cache with the result.""" try: return self.cache[args] except KeyError: