setup.py
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
Sat, 04 Mar 2017 01:21:43 +0100
changeset 2041 3b6550261614
parent 2036 2d9e7b936ee1
child 2049 b81d3775006b
permissions -rw-r--r--
exthelper: extract into its own submodule That code is fairly independant, we extract it into its own extensions to clarify the code

import os
from distutils.core import setup
from os.path import dirname, join

def get_version(relpath):
    '''Read version info from a file without importing it'''
    for line in open(join(dirname(__file__), relpath), 'rb'):
        # Decode to a fail-safe string for PY3
        # (gives unicode object in PY2)
        line = line.decode('utf8')
        if '__version__' in line:
            if "'" in line:
                return line.split("'")[1]

def min_hg_version(relpath):
    '''Read version info from a file without importing it'''
    for line in open(join(dirname(__file__), relpath), 'rb'):
        # Decode to a fail-safe string for PY3
        # (gives unicode object in PY2)
        line = line.decode('utf8')
        if 'testedwith' in line:
            if "'" in line:
                return min(line.split("'")[1].split())

py_modules = [
    'hgext3rd.evolve.serveronly',
]
py_packages = [
    'hgext3rd',
    'hgext3rd.topic',
]

if os.environ.get('INCLUDE_INHIBIT'):
    py_modules.append('hgext3rd.evolve.hack.inhibit')
    py_modules.append('hgext3rd.evolve.hack.directaccess')


EVOLVE_PATH = 'hgext3rd/evolve/__init__.py'

requires = []
try:
    import mercurial
    mercurial.__all__
except ImportError:
    requires.append('mercurial>=%s' % min_hg_version(EVOLVE_PATH))

setup(
    name='hg-evolve',
    version=get_version(EVOLVE_PATH),
    author='Pierre-Yves David',
    maintainer='Pierre-Yves David',
    maintainer_email='pierre-yves.david@ens-lyon.org',
    url='https://www.mercurial-scm.org/doc/evolution/',
    description='Flexible evolution of Mercurial history.',
    long_description=open('README').read(),
    keywords='hg mercurial',
    license='GPLv2+',
    py_modules=py_modules,
    packages=py_packages
)