Skip to content
Permalink
Browse files

pypt update

Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Jun 29, 2015
1 parent 4b08611 commit a0892ec69888911676f7a5200639b9426d473fc8
Showing with 52 additions and 32 deletions.
  1. +11 −17 .pypt/README.rst
  2. +21 −8 .pypt/commitlog
  3. +1 −1 .pypt/ghrel
  4. +16 −3 .pypt/localegen
  5. +3 −3 release
@@ -5,8 +5,8 @@ Python Project Template. INSERT TAGLINE HERE.™
:Author: Chris Warrick <chris@chriswarrick.com>
:Copyright: © 2013-2015, Chris Warrick.
:License: BSD (see /LICENSE or :doc:`Appendix B <LICENSE>`.)
:Date: 2015-01-03
:Version: 1.0.6
:Date: 2015-06-29
:Version: 1.1.1

.. index: README
.. image:: https://travis-ci.org/Kwpolska/python-project-template.png?branch=master
@@ -18,7 +18,7 @@ Requirements
============

* ``zsh`` installed (required by ``/release`` and ``/.pypt/localegen`` scripts)
* Python with ``requests`` (required by ``/.pypt/{commitlog,aursend}``) and ``twine`` (required by ``/release``) installed
* Python with ``requests`` (required by ``/.pypt/{commitlog,ghrel}``) and ``twine`` (required by ``/release``) installed
* `git-flow extensions by nvie <https://github.com/nvie/gitflow>`_ (alternatively yo can manually alter the ``/release`` script, and that is much harder than
installing the extensions)
* A git repository. The PyPT is ready to go if you use GitHub. If you do not
@@ -30,8 +30,6 @@ Recommended possessions
=======================

* Travis CI account (if you do not want Travis CI, remove ``/.travis.yml``)
* AUR account (if you do not want AUR uploads, remove the
``/PKGBUILD{,-2}{,-git}`` files and modify the ``/.pypt/config`` file)

Contents
========
@@ -51,7 +49,7 @@ The template contains the following files to get you started:
* ``__init__.py`` and ``template.py`` files in the Python package directory
* A good-enough ``setup.py`` file
* ``tests.py`` containing some *Is My Python Sane?*-style tests
* A sample ``/usr/bin/`` script
* Entry points configuration ready to be uncommented
* Addons for Qt users
* PKGBUILDs for the Arch Linux User Repository (AUR)
* A state-of-the-art ``release`` script, the operations of which are:
@@ -62,9 +60,8 @@ The template contains the following files to get you started:
* copying over ``/docs/README.rst``, ``/docs/CHANGELOG.rst`` and ``/docs/CONTRIBUTING.rst`` to ``/``
* locale generation (via the ``.pypt/localegen`` script)
* running ``import $project`` and the testsuite
* creating and uploading AUR packages
* committing into git, finishing the ``git flow`` release

* creating a GitHub Releases entry

Getting up to speed in 15 easy steps
====================================
@@ -94,9 +91,6 @@ Getting up to speed in 15 easy steps
way! They are listed in the license, please keep my name there, otherwise
you risk breaking the law.

Also, if ``len(computer_friendly_name) != len('tEmplate')``, you may want to
change the amount of tildes in docstrings of Python files.

4. Rename ``/tEmplate`` to the name used in 4.2.
5. Modify ``/docs/README.rst`` to reflect your project and not the Template
(and make a copy if you are reading it locally from those files)
@@ -106,10 +100,10 @@ Getting up to speed in 15 easy steps
2. ``/docs/CHANGELOG.rst`` to ``/CHANGELOG.rst``

7. Modify ``/.pypt/config``
8. Modify ``/bin/tEmplate`` and rename it OR remove the directory
8. Generate a `GitHub Personal Access Token <https://github.com/settings/tokens>`_ and write it to a ``/.pypt/gh-token`` file
9. Customize ``/setup.py`` to your liking. You should pay attention to the
classifiers and the commented parts.
10. Customize requirements.txt.
10. Customize ``requirements.txt``.
11. If you are using PyQt4 or PySide, make sure to put your UI code in a ``ui``
submodule. Copy over the ``/QT-ADDONS/resources.py`` file to that
submodule, even if you are not using resources now.
@@ -129,11 +123,11 @@ Getting up to speed in 15 easy steps
PS. GNU GPL is not a good idea. You can use it, but the world would be
much happier if you did not.

15. Remove ``/.git``, and run the following commands, replacing stuff with ``$``
in front::
15. Remove ``/.git``, and run the following commands::

source .pypt/config
git init
git remote add origin git@github.com:$GITUSERNAME/$GITREPO
git remote add origin git@github.com:$GITUSER/$GITREPO
git flow init #(change version tag prefix to `v`)
git add *
git checkout develop
@@ -151,8 +145,8 @@ commercial (a.k.a. proprietary) license, you must contact me first.

**However, the following files must remain under the BSD license:**

* /.pypt/aursend
* /.pypt/commitlog
* /.pypt/ghrel
* /.pypt/localegen
* /.pypt/README.PyPT
* /.pypt/LICENSE.PyPT
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
# Kw’s Release Tools/Python Project Template
# Commit and Changelog Parser
@@ -36,12 +36,25 @@
# Arguments:
# FILE BASEDIR NEWVERSION

"""
Parse commits and changelogs for PyPT.
Usage: .pypt/commitlog FILE BASEDIR NEWVERSION, where
FILE is the path to the CMFN file to parse,
BASEDIR is the project directory,
NEWVERSION is the new version number.
All paths should be absolute.
"""


import re
from os.path import join as pjoin
from sys import argv
from textwrap import indent

with open(argv[1]) as fh:
_script, FILE, BASEDIR, NEWVERSION = argv

with open(FILE) as fh:
e = re.findall('#~ C(.*?) MESSAGE START ~#\n(.*?)\n#~ C(.*?) MESSAGE '
'END ~#', fh.read(), flags=re.S)

@@ -53,17 +66,17 @@ for i in e:
else:
i[0] = 'C' + i[0] # regexp hack
if i[0] == 'COMMIT':
with open(argv[1] + 'commit', 'w') as fh:
with open(FILE + '-commit', 'w') as fh:
fh.write(i[1])
elif i[0] == 'CHANGELOG':
with open(pjoin(argv[2], 'docs', 'CHANGELOG.rst')) as fh:
with open(pjoin(BASEDIR, 'docs', 'CHANGELOG.rst')) as fh:
currentfile = fh.read()

# A bit fragile...
currentver = re.search(':Version: (.*)', currentfile).groups()[0]
clog = indent(i[1], 4 * ' ')

with open(pjoin(argv[2], 'docs', 'CHANGELOG.rst'), 'w') as fh:
fh.write(currentfile.replace('\n' + currentver,
'\n{0}\n{1}\n\n{2}'.format(
argv[3], clog, currentver)))
with open(pjoin(BASEDIR, 'docs', 'CHANGELOG.rst'), 'w') as fh:
fh.write(currentfile.replace(
'\n' + currentver,
'\n{0}\n{1}\n\n{2}'.format(NEWVERSION, clog, currentver)))
@@ -84,7 +84,7 @@ r = requests.post(
headers=HEADERS)

if r.status_code == 201:
print("GitHub Release created: {0}".format(r.json()['url']))
print("GitHub Release created: {0}".format(r.json()['html_url']))
else:
print("GitHub Release failed: {0}".format(r.text))
exit(1)
@@ -34,7 +34,7 @@
. .pypt/config

case "$LOCALETYPE" in
'gettext')
'gettext' | 'gettext-tx')
version=$(cat setup.py | grep 'version=' | sed -e 's/.*version=.//g' -e 's/.,$//g')
date=$(date '+%Y-%m-%d')
datel=$(date '+%Y-%m-%d %H:%M%z')
@@ -69,6 +69,11 @@ case "$LOCALETYPE" in
sed "s/#version/$version/g" messages.pot -i
sed "s/#datel/$datel/g" messages.pot -i

if [[ "$LOCALETYPE" == "gettext-tx" ]]; then
tx push -s
tx pull
fi

for i in ./locale/*; do
language=$(basename $i)

@@ -89,8 +94,12 @@ case "$LOCALETYPE" in
msgfmt -o $podir/$PROJECTLC.mo $popath
done
;;
'pyqt4')
'pyqt4' | 'pyqt4-tx')
pylupdate4 -verbose $PROJECTLC.pro
if [[ "$LOCALETYPE" == "pyqt4-tx" ]]; then
tx push -s
tx pull
fi
for i in ./locale/*.ts; do
# pylupdate4 is dumb and mangles encodings
sed -i -e 's|filename="|filename="../|g' -e \
@@ -103,8 +112,12 @@ case "$LOCALETYPE" in
pyrcc4 -py2 $PROJECTLC.qrc -o $PROJECTLC/ui/resources2.py
pyrcc4 -py3 $PROJECTLC.qrc -o $PROJECTLC/ui/resources3.py
;;
'pyside')
'pyside' | 'pyside-tx')
pyside-lupdate -verbose $PROJECTLC.pro
if [[ "$LOCALETYPE" == "pyside-tx" ]]; then
tx push -s
tx pull
fi
for i in ./locale/*.ts; do
# pyside may be dumb, too
sed -i -e 's|filename="|filename="../|g' -e \
@@ -51,7 +51,7 @@ function cleanup {

function cleanup_cmfn {
[[ -e $cmfn ]] && rm $cmfn
[[ -e $cmfn"-commit" ]] && mv $cmfn"-commit" $cmfn2
[[ -e $cmfn2 ]] && rm $cmfn2
}

status '*** Kw’s Release Scripts'
@@ -103,7 +103,7 @@ datel=$(date '+%Y-%m-%d %H:%M%z')
dates=$(date '+%s')

cmfn=$PWD/.git/kwrs-$dates
cmfn2=/tmp/kwrs-commit-$dates
cmfn2=$cmfn"-commit"

cleanup
cleanup_cmfn
@@ -193,7 +193,7 @@ cleanup

git add -A --ignore-errors .

git commit -asF $cmfn"-commit"
git commit -asF $cmfn2

git flow release finish $version
git push

0 comments on commit a0892ec

Please sign in to comment.
You can’t perform that action at this time.