Skip to content

Commit

Permalink
Closes #2 add inv tasks for PyPi deploy and test automation
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewrankin committed Aug 7, 2014
1 parent f0e0896 commit b5668ac
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 10 deletions.
13 changes: 13 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Changelog

### develop (unreleased)

### v0.1 (August 7, 2014)

#### Enhancements

- Add Travis-CI testing [#1][]
- Create invoke tasks to automate PyPi deploy [#2][]

[#1]: https://github.com/questrail/sdfascii/issues/1
[#2]: https://github.com/questrail/sdfascii/issues/2
15 changes: 7 additions & 8 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
distribute==0.6.31
git-remote-helpers==0.1.0
numpy==1.7.0
stevedore==0.7.2
virtualenv==1.8.4
virtualenv-clone==0.2.4
virtualenvwrapper==3.6
wsgiref==0.1.2
flake8==2.2.2
invoke==0.8.2
mccabe==0.2.1
nose==1.3.3
numpy==1.8.1
pep8==1.5.7
pyflakes==0.8.1
7 changes: 7 additions & 0 deletions sdfascii.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,15 @@
# Data analysis related imports
import numpy as np

__version__ = '0.1'


def _strip_nonprintable(input_string):
'''
(str) -> str
Return input_string without nonprintable characters
'''
return input_string.split('\x00', 1)[0]


Expand Down
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[metadata]
description-file = README.md
44 changes: 42 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,53 @@
from distutils.core import setup
import codecs
import os
import re

from setuptools import setup

here = os.path.abspath(os.path.dirname(__file__))


def read(*parts):
"""Read parts of a file
Taken from pip's setup.py
intentionally *not* adding an encoding option to open
see: https://github.com/pypa/virtualenv/issues/201#issuecomment-3145690
"""
return codecs.open(os.path.join(here, *parts), 'r').read()


def find_version(*file_paths):
"""Find version in source file
Read the version number from a source file.
Code taken from pip's setup.py
"""
version_file = read(*file_paths)
# The version line must have the form:
# __version__ = 'ver'
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
version_file, re.M)
if version_match:
return version_match.group(1)
raise RuntimeError("Unable to find version string.")

try:
import pypandoc
long_description = pypandoc.convert('README.md', 'rst')
except(IOError, ImportError):
long_description = open('README.md').read()

setup(
name='sdfascii',
version='0.1.0',
version=find_version('sdfascii.py'),
author='Matthew Rankin',
author_email='[email protected]',
py_modules=['sdfascii'],
url='http://github.com/questrail/sdfascii',
license='LICENSE.txt',
description='Read HP SDF binary and ASCII files',
long_description=long_description,
requires=['numpy (>=1.6.0)'],
classifiers=[
'Programming Language :: Python',
Expand Down
43 changes: 43 additions & 0 deletions tasks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from invoke import run, task

TESTPYPI = "https://testpypi.python.org/pypi"


@task
def lint():
"""Run flake8 to lint code"""
run("python setup.py flake8")


@task(lint)
def test():
"""Lint, unit test, and check setup.py"""
run("nosetests")
run("python setup.py check")


@task()
def release(deploy=False, test=False, version=''):
"""Tag release, run Travis-CI, and deploy to PyPI
"""
if test:
run("python setup.py check")
run("python setup.py register sdist upload --dry-run")

if deploy:
run("python setup.py check")
if version:
run("git checkout master")
run("git tag -a v{ver} -m 'v{ver}'".format(ver=version))
run("git push")
run("git push origin --tags")
run("python setup.py register sdist upload")
else:
print("* Have you updated the version in taffmat.py?")
print("* Have you updated CHANGES.md?")
print("* Have you fixed any last minute bugs?")
print("If you answered yes to all of the above questions,")
print("then run `invoke release --deploy -vX.YY` to:")
print("- Checkout master")
print("- Tag the git release with provided vX.YY version")
print("- Push the master branch and tags to repo")

0 comments on commit b5668ac

Please sign in to comment.