Build and documentation updates

This commit is contained in:
Bastian Kleineidam 2012-12-17 18:14:58 +01:00
parent ee3b2497ea
commit bf1e937db4
8 changed files with 93 additions and 71 deletions

107
Makefile
View File

@ -1,12 +1,20 @@
# This Makefile is only used by developers. # This Makefile is only used by developers.
PYVER:=2.7 PYVER:=2.7
PYTHON:=python$(PYVER) PYTHON:=python$(PYVER)
APPNAME:=patool
VERSION:=$(shell $(PYTHON) setup.py --version) VERSION:=$(shell $(PYTHON) setup.py --version)
ARCHIVE_SOURCE:=$(APPNAME)-$(VERSION).tar.gz MAINTAINER:=$(shell $(PYTHON) setup.py --maintainer)
ARCHIVE_RPM:=$(APPNAME)-$(VERSION)-1.x86_64.rpm AUTHOR:=$(shell $(PYTHON) setup.py --author)
ARCHIVE_WIN32:=$(APPNAME)-$(VERSION).exe APPNAME:=$(shell $(PYTHON) setup.py --name)
PY_FILES_DIRS := patool setup.py patoolib tests 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 ?= PY2APPOPTS ?=
ifeq ($(shell uname),Darwin) ifeq ($(shell uname),Darwin)
CHMODMINUSMINUS:= CHMODMINUSMINUS:=
@ -31,7 +39,8 @@ chmod:
dist: dist:
$(PYTHON) setup.py bdist_rpm $(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 [ ! -f ../$(ARCHIVE_WIN32) ] || cp ../$(ARCHIVE_WIN32) dist
sign: sign:
@ -39,23 +48,37 @@ sign:
[ -f dist/$(ARCHIVE_WIN32).asc ] || gpg --detach-sign --armor dist/$(ARCHIVE_WIN32) [ -f dist/$(ARCHIVE_WIN32).asc ] || gpg --detach-sign --armor dist/$(ARCHIVE_WIN32)
[ -f dist/$(ARCHIVE_RPM).asc ] || gpg --detach-sign --armor dist/$(ARCHIVE_RPM) [ -f dist/$(ARCHIVE_RPM).asc ] || gpg --detach-sign --armor dist/$(ARCHIVE_RPM)
upload: dist/README.md sign upload:
github-upload wummel patool dist/* github-upload $(GITUSER) $(GITREPO) dist/$(ARCHIVE_SOURCE)* dist/$(ARCHIVE_WIN32)* dist/$(ARCHIVE_RPM)*
make -C $(HOMEPAGE)
dist/README.md: doc/README-Download.md.tmpl doc/changelog.txt homepage:
# copying readme for release # update metadata
sed -e 's/{APPNAME}/$(APPNAME)/g' -e 's/{VERSION}/$(VERSION)/g' $< > $@ @echo "version: $(VERSION)" > $(HOMEPAGE)/info.yaml
# append changelog @echo "name: $(APPNAME)" >> $(HOMEPAGE)/info.yaml
awk '/released/ {c++}; c==2 {exit}; {print " " $$0}' doc/changelog.txt >> $@ @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 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..." @echo "Register at Python Package Index..."
$(PYTHON) setup.py register $(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 \ @if egrep -i "xx\.|xxxx|\.xx" doc/changelog.txt > /dev/null; then \
echo "Could not release: edit doc/changelog.txt release date"; false; \ echo "Could not release: edit doc/changelog.txt release date"; false; \
fi fi
@ -63,48 +86,70 @@ releasecheck: check test
echo "Missing WIN32 distribution archive at ../$(ARCHIVE_WIN32)"; \ echo "Missing WIN32 distribution archive at ../$(ARCHIVE_WIN32)"; \
false; \ false; \
fi fi
@if ! grep "Version: $(VERSION)" patool.freecode > /dev/null; then \ @if ! grep "Version: $(VERSION)" $(LAPPNAME).freecode > /dev/null; then \
echo "Could not release: edit patool.freecode version"; false; \ echo "Could not release: edit $(LAPPNAME).freecode version"; false; \
fi fi
# Build OSX installer
app: clean chmod app: clean chmod
# Build OSX installer
$(PYTHON) setup.py py2app $(PY2APPOPTS) $(PYTHON) setup.py py2app $(PY2APPOPTS)
check:
# The check programs used here are mostly local scripts on my private system. # 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. # So for other developers there is no need to execute this target.
check:
[ ! -d .svn ] || check-nosvneolstyle -v
check-copyright check-copyright
check-pofiles -v check-pofiles -v
py-tabdaddy py-tabdaddy
py-unittest2-compat tests/ py-unittest2-compat tests/
$(MAKE) doccheck
doccheck:
py-check-docstrings --force \
patoolib \
patool \
*.py
pyflakes: pyflakes:
pyflakes $(PY_FILES_DIRS) pyflakes setup.py patool patoolib tests
count: count:
@sloccount patool patoolib | grep "Total Physical Source Lines of Code" # print some code statistics
@sloccount patool patoolib
clean: clean:
find . -name \*.pyc -delete find . -name \*.pyc -delete
find . -name \*.pyo -delete find . -name \*.pyo -delete
rm -rf build dist doc/README.md rm -rf build dist
test: test:
$(PYTHON) -m pytest $(PYTESTOPTS) $(TESTOPTS) $(TESTS) $(PYTHON) -m pytest $(PYTESTOPTS) $(TESTOPTS) $(TESTS)
doc/patool.txt: doc/patool.1 doc/$(LAPPNAME).txt: doc/$(LAPPNAME).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 # 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: 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:
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: 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: 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

View File

@ -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
---------------------------

View File

@ -1,5 +1,5 @@
Project: patool Project: patool
Version: 0.17 Version: 0.18
Release-Focus: Minor feature enhancements Release-Focus: Minor feature enhancements
Hide: N Hide: N
Website-URL: http://github.com/wummel/patool 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 Windows-installer-URL: http://github.com/downloads/wummel/patool/patool-${version}.win32.exe
Support has been added for chmlib and archmage handling Support has been added for chmlib and archmage handling
Microsoft ITSS/CHM (.chm) archives. Also the project moved from Microsoft ITSS/CHM (.chm) archives. The project moved from
sourceforge to github. Sourceforge to Github.

View File

@ -526,6 +526,7 @@ def _handle_archive (archive, command, *args, **kwargs):
def get_archive_cmdlist_func (program, command, format): def get_archive_cmdlist_func (program, command, format):
"""Get the Python function that executes the given program."""
# get python module for given archive program # get python module for given archive program
key = util.stripext(os.path.basename(program).lower()) key = util.stripext(os.path.basename(program).lower())
modulename = ".programs." + ProgramModules.get(key, key) modulename = ".programs." + ProgramModules.get(key, key)

View File

@ -107,7 +107,9 @@ def totype(v, default):
return v return v
class CommandError(Exception): pass class CommandError(Exception):
"""Error for baker commands."""
pass
class Cmd(object): class Cmd(object):
@ -116,6 +118,7 @@ class Cmd(object):
def __init__(self, name, fn, argnames, keywords, shortopts, def __init__(self, name, fn, argnames, keywords, shortopts,
has_varargs, has_kwargs, docstring, paramdocs): has_varargs, has_kwargs, docstring, paramdocs):
"""Store given metadata."""
self.name = name self.name = name
self.fn = fn self.fn = fn
self.argnames = argnames self.argnames = argnames
@ -129,7 +132,10 @@ class Cmd(object):
class Baker(object): class Baker(object):
"""Main class."""
def __init__(self): def __init__(self):
"""Initialize command variables."""
self.commands = {} self.commands = {}
self.defaultcommand = None self.defaultcommand = None
@ -343,6 +349,7 @@ class Baker(object):
sys.exit(0) sys.exit(0)
def parse_args(self, scriptname, cmd, argv): def parse_args(self, scriptname, cmd, argv):
"""Parse command arguments."""
keywords = cmd.keywords keywords = cmd.keywords
shortopts = cmd.shortopts shortopts = cmd.shortopts

View File

@ -34,5 +34,6 @@ def create_ape (archive, compression, cmd, *args, **kwargs):
def test_ape (archive, compression, cmd, **kwargs): def test_ape (archive, compression, cmd, **kwargs):
"""Test an APE archive."""
cmdlist = [cmd, archive, '-v'] cmdlist = [cmd, archive, '-v']
return cmdlist return cmdlist

View File

@ -42,6 +42,7 @@ def create_tar (archive, compression, cmd, *args, **kwargs):
return cmdlist return cmdlist
def add_tar_opts (cmdlist, compression, verbose): def add_tar_opts (cmdlist, compression, verbose):
"""Add tar options to cmdlist."""
progname = os.path.basename(cmdlist[0]) progname = os.path.basename(cmdlist[0])
if compression == 'gzip': if compression == 'gzip':
cmdlist.append('-z') cmdlist.append('-z')

View File

@ -91,10 +91,13 @@ class memoized (object):
not re-evaluated.""" not re-evaluated."""
def __init__(self, func): def __init__(self, func):
"""Set func and init cache."""
self.func = func self.func = func
self.cache = {} self.cache = {}
def __call__(self, *args): 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: try:
return self.cache[args] return self.cache[args]
except KeyError: except KeyError: