Permalink
Browse files

Updated the setup.py and version info to use current practices

  • Loading branch information...
coordt committed Jul 20, 2012
1 parent 8c9318d commit 8a59d14d838130a0fc4be26f3f91b1113a6f82ee
Showing with 37 additions and 18 deletions.
  1. +23 −9 setup.py
  2. +14 −9 staff/__init__.py
View
@@ -1,21 +1,35 @@
-from setuptools import setup, find_packages
-import staff
import os
+from setuptools import setup, find_packages
-version = staff.get_version()
def read_file(filename):
- dirname = os.path.abspath(os.path.dirname(__file__))
- return open(os.path.join(dirname, filename)).read()
+ """Read a file into a string"""
+ path = os.path.abspath(os.path.dirname(__file__))
+ filepath = os.path.join(path, filename)
+ try:
+ return open(filepath).read()
+ except IOError:
+ return ''
+
+
+def get_readme():
+ """Return the README file contents. Supports text,rst, and markdown"""
+ for name in ('README', 'README.rst', 'README.md'):
+ if os.path.exists(name):
+ return read_file(name)
+ return ''
+
+# Use the docstring of the __init__ file to be the description
+DESC = " ".join(__import__('staff').__doc__.splitlines()).strip()
setup(name='django-staff',
- description='A basic addition to auth.User that manages additional staff info',
- long_description=read_file('README'),
- version=version,
+ description=DESC,
+ long_description=get_readme(),
+ version=__import__('staff').get_version().replace(' ', '-'),
author='Corey Oordt',
author_email='coordt@washingtontimes.com',
url='http://github.com/washingtontimes/django-staff',
include_package_files=True,
packages=find_packages(),
- classifiers=['Framework :: Django',],
+ classifiers=['Framework :: Django'],
)
View
@@ -1,18 +1,23 @@
+"""
+A basic addition to auth.User that manages additional staff info
+"""
+
__version_info__ = {
- 'major': 0,
- 'minor': 5,
- 'micro': 6,
- 'releaselevel': 'final',
- 'serial': 0
+ 'major': 1,
+ 'minor': 0,
+ 'micro': 0,
+ 'releaselevel': 'beta',
+ 'serial': 1
}
-def get_version():
- vers = ["%(major)i.%(minor)i" % __version_info__, ]
+def get_version(short=False):
+ assert __version_info__['releaselevel'] in ('alpha', 'beta', 'final')
+ vers = ["%(major)i.%(minor)i" % __version_info__, ]
if __version_info__['micro']:
vers.append(".%(micro)i" % __version_info__)
- if __version_info__['releaselevel'] != 'final':
- vers.append('%(releaselevel)s%(serial)i' % __version_info__)
+ if __version_info__['releaselevel'] != 'final' and not short:
+ vers.append('%s%i' % (__version_info__['releaselevel'][0], __version_info__['serial']))
return ''.join(vers)
__version__ = get_version()

0 comments on commit 8a59d14

Please sign in to comment.