| 1 | #!/usr/bin/env python |
|---|
| 2 | # -*- coding: utf-8 -*- |
|---|
| 3 | # |
|---|
| 4 | # Copyright (C) 2005-2010 Lele Gaifax <lele@metapensiero.it> |
|---|
| 5 | # |
|---|
| 6 | # This software is licensed as described in the file COPYING, which |
|---|
| 7 | # you should have received as part of this distribution. The terms |
|---|
| 8 | # are also available at http://trac.edgewall.com/license.html. |
|---|
| 9 | # |
|---|
| 10 | # This software consists of voluntary contributions made by many |
|---|
| 11 | # individuals. For the exact contribution history, see the revision |
|---|
| 12 | # history and logs, available at http://projects.edgewall.com/trac/. |
|---|
| 13 | # |
|---|
| 14 | # Author: Lele Gaifax <lele@metapensiero.it> |
|---|
| 15 | |
|---|
| 16 | import re, sys |
|---|
| 17 | from os.path import join, dirname |
|---|
| 18 | |
|---|
| 19 | from setuptools import setup |
|---|
| 20 | |
|---|
| 21 | initpy = open(join(dirname(__file__), 'tracdarcs', '__init__.py')).read() |
|---|
| 22 | try: |
|---|
| 23 | VERSION = re.compile(r".*__version__ = '(.*?)'", re.S).match(initpy).group(1) |
|---|
| 24 | except: |
|---|
| 25 | print "Cannot recognize a valid version in tracdarcs/__init__.py!" |
|---|
| 26 | sys.exit(1) |
|---|
| 27 | |
|---|
| 28 | setup_requires=[] |
|---|
| 29 | # darcsver is needed only if you want "./setup.py darcsver" to write a new |
|---|
| 30 | # version stamp in tracdarcs/_version.py, with a version number derived from |
|---|
| 31 | # darcs history. http://pypi.python.org/pypi/darcsver |
|---|
| 32 | if "darcsver" in sys.argv[1:]: |
|---|
| 33 | setup_requires.append('darcsver >= 1.0.0') |
|---|
| 34 | |
|---|
| 35 | VERSIONFILE = join(dirname(__file__), 'tracdarcs', '_version.py') |
|---|
| 36 | verstr = VERSION |
|---|
| 37 | try: |
|---|
| 38 | verstrline = open(VERSIONFILE, "rt").read() |
|---|
| 39 | except EnvironmentError: |
|---|
| 40 | pass # Okay, there is no version file. |
|---|
| 41 | else: |
|---|
| 42 | VSRE = r"^verstr = ['\"]([^'\"]*)['\"]" |
|---|
| 43 | mo = re.search(VSRE, verstrline, re.M) |
|---|
| 44 | if mo: |
|---|
| 45 | verstr = mo.group(1) |
|---|
| 46 | else: |
|---|
| 47 | print "unable to find version in %s" % (VERSIONFILE,) |
|---|
| 48 | raise RuntimeError("if %s.py exists, it is required to be well-formed" % (VERSIONFILE,)) |
|---|
| 49 | |
|---|
| 50 | setup(name='TracDarcs', |
|---|
| 51 | description='Darcs plugin for Trac', |
|---|
| 52 | keywords='trac scm plugin darcs', |
|---|
| 53 | version=verstr, |
|---|
| 54 | setup_requires=setup_requires, |
|---|
| 55 | url='http://darcs.arstecnica.it/trac-darcs', |
|---|
| 56 | license='http://trac.edgewall.com/license.html', |
|---|
| 57 | author='Lele Gaifax', |
|---|
| 58 | author_email='lele@metapensiero.it', |
|---|
| 59 | long_description=open('README.rst').read(), |
|---|
| 60 | packages=['tracdarcs'], |
|---|
| 61 | entry_points={'trac.plugins': 'darcs = tracdarcs'}, |
|---|
| 62 | zip_safe=False |
|---|
| 63 | ) |
|---|