Source

repoman / setup.py

# Copyright 2009-2012 Edlund A/S
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.

import sys
import re
import os
from distutils.core import setup
import py2exe

import mercurial.ui
import mercurial.hg
from mercurial.node import short

RUN_EPYDOC = False
RUN_PYLINT = False
SKIP_SETUP = False
NOSE_ARGS = []

def parse_args():
    global RUN_EPYDOC, RUN_PYLINT, SKIP_SETUP, NOSE_ARGS

    args = sys.argv[1:]
    for arg in args:
        if arg == '--run-epydoc':
            RUN_EPYDOC = True
            sys.argv.remove(arg)
        elif arg == '--run-pylint':
            RUN_PYLINT = True
            sys.argv.remove(arg)
        elif arg.startswith('--nose-'):
            NOSE_ARGS.append(arg[6:])
            sys.argv.remove(arg)
        elif arg == '--skip-setup':
            SKIP_SETUP = True
            sys.argv.remove(arg)

parse_args()

if RUN_EPYDOC:
    rargs = sys.argv
    sys.argv = [rargs[0], 'repo', 'repoman', 'repoext']
    from epydoc.cli import cli
    cli()
    sys.argv = rargs

if RUN_PYLINT:
    ostderr = sys.stderr
    sys.stderr = open(os.devnull, 'w')
    from pylint import lint
    try:
        lint.Run(['repo', 'repoman', 'repoext'])
    except SystemExit, error:
        print 'pylint returned with error code:', error
    sys.stderr = ostderr

path = sys.path[0]
if sys.argv[1] == 'clean' and path:
    import shutil
    try: shutil.rmtree(os.path.join(path, 'dist'))
    except: pass
    try: shutil.rmtree(os.path.join(path, 'Output'))
    except: pass

includes = ['repoext']
if 'py2exe' in sys.argv:

    # Help py2exe to find win32com.shell
    try:
        import modulefinder
        import win32com
        for p in win32com.__path__[1:]: # Take the path to win32comext
            modulefinder.AddPackagePath("win32com", p)
        pn = "win32com.shell"
        __import__(pn)
        m = sys.modules[pn]
        for p in m.__path__[1:]:
            modulefinder.AddPackagePath(pn, p)
    except ImportError:
        pass

    # Include Mercurial extensions
    import hgext
    hgextdir = os.path.dirname(hgext.__file__)
    hgextmods = set(["hgext." + os.path.splitext(f)[0]
                     for f in os.listdir(hgextdir)])

    if 'hgext.highlight' in hgextmods:
        includes += ['pygments.*', 'pygments.lexers.*', 'pygments.formatters.*',
                     'pygments.filters.*', 'pygments.styles.*']
    if 'hgext.patchbomb' in hgextmods:
        includes += ['email.*', 'email.mime.*']
    includes += list(hgextmods)

if not SKIP_SETUP:
    ui = mercurial.ui.ui()
    repo = mercurial.hg.repository(ui)
    ctx = repo['.']
    tags = [tag for tag in ctx.tags() if tag not in ['tip', 'qbase', 'qparent', 'qtip']]
    if tags:
        ver = tags[-1]
    else:
        ver = short(ctx.node())
    with open(os.path.join('repoman', '__version__.py'), 'w') as fh:
        fh.write('# this file is autogenerated by setup.py\n')
        fh.write('version = "%s"\n' % ver)

    setup(name='RepoMan',
          version='unknown',
          description='Edlund repository manager',
          author='Edlund Mercurial Team',
          author_email='sune.foldager@edlund.dk',
          scripts=['repo'],
          console=['repo'],
          packages=['repoman', 'repoext'],
          options={
              'py2exe': {
                  'includes': includes,
                  'dll_excludes': ['mswsock.dll', 'msimg32.dll'],
              },
          },
         )
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.