make into a proper distutils package, with wp2git as CLI entry point, and call it version 1.0
This commit is contained in:
parent
33040a6c56
commit
6e7a19ce60
|
@ -1 +1,3 @@
|
|||
*.exe
|
||||
*.py[co]
|
||||
*~
|
||||
|
|
51
README.md
51
README.md
|
@ -1,23 +1,28 @@
|
|||
wp2git
|
||||
======
|
||||
|
||||
This program allows you to download and convert any Wikipedia article's history to a `git` repository, for easy browsing and blaming.
|
||||
|
||||
### Usage
|
||||
|
||||
$ wp2git.py [--bare] article_name
|
||||
|
||||
`wp2git` will create a directory, in which a new `git` repository will be created.
|
||||
The repository will contain a single file named `article_name.mw`, along with its entire edit history.
|
||||
|
||||
Run `wp2git --help` for more options.
|
||||
|
||||
### Requirements
|
||||
|
||||
`git` should be accessible from `PATH`.
|
||||
|
||||
The [`mwclient` package](http://github.com/mwclient/mwclient) must be installed (use `pip install mwclient`).
|
||||
|
||||
### Entirely based on
|
||||
|
||||
[CyberShadow's version](http://github.com/CyberShadow/wp2git) written in the D language.
|
||||
wp2git
|
||||
======
|
||||
|
||||
This program allows you to download and convert any Wikipedia article's history to a `git` repository, for easy browsing and blaming.
|
||||
|
||||
### Quick installation
|
||||
|
||||
```
|
||||
pip install https://github.com/dlenski/wp2git/archive/v1.0.zip
|
||||
```
|
||||
|
||||
### Usage
|
||||
|
||||
$ wp2git [--bare] article_name
|
||||
|
||||
`wp2git` will create a directory, in which a new `git` repository will be created.
|
||||
The repository will contain a single file named `article_name.mw`, along with its entire edit history.
|
||||
|
||||
Run `wp2git --help` for more options.
|
||||
|
||||
### Requirements
|
||||
|
||||
`git` should be accessible from `PATH`. The [`mwclient` package](http://github.com/mwclient/mwclient)
|
||||
is required.
|
||||
|
||||
### Entirely based on
|
||||
|
||||
[CyberShadow's version](http://github.com/CyberShadow/wp2git) written in the D language.
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
import sys, os, re, subprocess as sp
|
||||
from distutils.core import setup
|
||||
|
||||
########################################
|
||||
|
||||
# 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=[ 'mwclient>=0.8' ],
|
||||
license=open('LICENSE').read(),
|
||||
url="https://github.com/dlenski/wp2git",
|
||||
packages=["wp2git"],
|
||||
entry_points={ 'console_scripts': [ 'wp2git=wp2git.wp2git:main' ] }
|
||||
)
|
|
@ -0,0 +1 @@
|
|||
wp2git/version.py
|
|
@ -0,0 +1,3 @@
|
|||
# Do not edit this file, wp2git versioning is governed by git tags
|
||||
__version__="1.0"
|
||||
|
|
@ -7,6 +7,7 @@ import mwclient
|
|||
import subprocess as sp
|
||||
import urlparse
|
||||
import os, locale, time
|
||||
from .version import __version__
|
||||
|
||||
lang = locale.getdefaultlocale()[0].split('_')[0] or ''
|
||||
|
||||
|
@ -18,6 +19,7 @@ def sanitize(s):
|
|||
|
||||
def parse_args():
|
||||
p = argparse.ArgumentParser(description='Create a git repository with the history of the specified Wikipedia article.')
|
||||
p.add_argument('--version', action='version', version=__version__)
|
||||
p.add_argument('article_name')
|
||||
g2 = p.add_argument_group('Output options')
|
||||
g=g2.add_mutually_exclusive_group()
|
Loading…
Reference in New Issue