#!/usr/bin/env python3 import sys, os, re, subprocess as sp try: from setuptools import setup except ImportError: from distutils.core import setup if sys.version_info < (3,): sys.exit("Python 2.x is not supported; Python 3.x is required.") ######################################## # Based on this recipe, adapted for Python 3, Git 2.8.x, and PEP-440 version identifiers # http://blogs.nopcode.org/brainstorm/2013/05/20/pragmatic-python-versioning-via-setuptools-and-git-tags/ # https://www.python.org/dev/peps/pep-0440/#version-scheme # Fetch version from git tags, and write to version.py. # Also, when git is not available (PyPI package), use stored version.py. version_py = os.path.join(os.path.dirname(__file__), 'version.py') try: version_git = sp.check_output(["git", "describe", "--tags"]).strip().decode('ascii') final, dev, blob = re.match(r'v?((?:\d+\.)*\d+)(?:-(\d+)-(g[a-z0-9]+))?', version_git).groups() version_pep = final+('.dev%s+%s'%(dev,blob) if dev else '') except (sp.CalledProcessError, OSError): with open(version_py, 'r') as fh: version_pep = open(version_py).read().strip().split('=')[-1][1:-1] else: with open(version_py, 'w') as fh: print("# Do not edit this file, wp2git versioning is governed by git tags", file=fh) print('__version__="%s"\n' % version_pep, file=fh) ######################################## setup(name="wp2git", version=version_pep, description=("Downloads and imports Wikipedia page histories to a git repository"), long_description=open('README.md').read(), author=open('AUTHORS').read(), author_email="dlenski@gmail.com", install_requires=open('requirements.txt').readlines(), license=open('LICENSE').read(), url="https://github.com/dlenski/wp2git", packages=["wp2git"], entry_points={ 'console_scripts': [ 'wp2git=wp2git.wp2git:main' ] } )