Skip to content

Commit

Permalink
Added some setup.py niceties pinched from django-rest-framework.
Browse files Browse the repository at this point in the history
  • Loading branch information
rolo committed Sep 11, 2015
1 parent d85c240 commit 6dff42f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
33 changes: 33 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import os
import re
import shutil
import sys
from setuptools import setup, find_packages

with open(os.path.join(os.path.dirname(__file__), 'README.md')) as readme:
Expand All @@ -7,6 +10,35 @@
# allow setup.py to be run from any path
os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir)))


def get_version(package):
"""
Return package version as listed in `__version__` in `init.py`.
"""
init_py = open(os.path.join(package, '__init__.py')).read()
return re.search('__version__ = [\'"]([^\'"]+)[\'"]', init_py).group(1)


version = get_version('star_ratings')

if sys.argv[-1] == 'publish':
if os.system('pip freeze | grep wheel'):
print('wheel not installed.\nUse `pip install wheel`.\nExiting.')
sys.exit()
if os.system('pip freeze | grep twine'):
print('twine not installed.\nUse `pip install twine`.\nExiting.')
sys.exit()
os.system('python setup.py sdist bdist_wheel')
os.system('twine upload dist/*')
print('You probably want to also tag the version now:')
print(' git tag -a {} -m \'version {}\''.format(version, version))
print(' git push --tags')
shutil.rmtree('dist')
shutil.rmtree('build')
shutil.rmtree('django_star_ratings.egg-info')
sys.exit()


setup(
name='django-star-ratings',
version='0.1.0',
Expand All @@ -25,6 +57,7 @@
'django-braces'
],
classifiers=[
'Development Status :: 4 - Beta',
'Environment :: Web Environment',
'Framework :: Django',
'License :: OSI Approved :: BSD License'
Expand Down
1 change: 1 addition & 0 deletions star_ratings/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = '0.1.0'

0 comments on commit 6dff42f

Please sign in to comment.