From 08537128bbad7c40babf7238da62412368fb3cd1 Mon Sep 17 00:00:00 2001 From: "Elf M. Sternberg" Date: Fri, 30 Sep 2016 11:49:21 -0700 Subject: [PATCH] Updated Makefile and setup to include the man file as part of the install. --- Makefile | 10 +++++++++- docs/arguments.rst | 2 +- docs/git_lint.rst | 24 ++++++++++++++++++++++++ setup.py | 29 ++++++++++++++++++++++++++++- 4 files changed, 62 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 2e3d70d..bdca640 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,7 @@ export BROWSER_PYSCRIPT BROWSER := python -c "$$BROWSER_PYSCRIPT" help: + @echo "all - local build including docs" @echo "clean - remove all build, test, coverage and Python artifacts" @echo "clean-build - remove build artifacts" @echo "clean-pyc - remove Python file artifacts" @@ -21,10 +22,14 @@ help: @echo "test-all - run tests on every Python version with tox" @echo "coverage - check code coverage quickly with the default Python" @echo "docs - generate Sphinx HTML documentation, including API docs" + @echo "docsbrowse - generate Sphinx HTML documentation and start browser" @echo "release - package and upload a release" @echo "dist - package" @echo "install - install the package to the active Python's site-packages" +all: docs + python setup.py build + clean: clean-build clean-pyc clean-test clean-build: @@ -67,6 +72,9 @@ docs: sphinx-apidoc -o docs/ git_lint $(MAKE) -C docs clean $(MAKE) -C docs html + $(MAKE) -C docs man + +docbrowse: docs $(BROWSER) docs/_build/html/index.html servedocs: docs @@ -82,4 +90,4 @@ dist: clean ls -l dist install: clean - python setup.py install + python setup.py install --prefix=/usr/local diff --git a/docs/arguments.rst b/docs/arguments.rst index 1a32dca..be0ee88 100644 --- a/docs/arguments.rst +++ b/docs/arguments.rst @@ -14,7 +14,7 @@ Scan the workspace [default] **-s, --staging** Scan the staging area (useful for pre-commit). -**-c** , --config**= Path to config file +**-c , --config**= Path to config file **-d, --dryrun** Report what git-lint would do, but don't actually do anything. **-q, --quiet** diff --git a/docs/git_lint.rst b/docs/git_lint.rst index e1d243f..126fcac 100644 --- a/docs/git_lint.rst +++ b/docs/git_lint.rst @@ -12,6 +12,30 @@ git_lint.git_lint module :undoc-members: :show-inheritance: +git_lint.option_handler module +------------------------------ + +.. automodule:: git_lint.option_handler + :members: + :undoc-members: + :show-inheritance: + +git_lint.options module +----------------------- + +.. automodule:: git_lint.options + :members: + :undoc-members: + :show-inheritance: + +git_lint.reporters module +------------------------- + +.. automodule:: git_lint.reporters + :members: + :undoc-members: + :show-inheritance: + Module contents --------------- diff --git a/setup.py b/setup.py index abd7d31..59efae3 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,30 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- +import re +import sys +import argparse +import os.path +def _resolve_prefix(prefix, type): + osx_system_prefix = r'^/System/Library/Frameworks/Python.framework/Versions' + matches = {'man': [(r'^/usr$', '/usr/share'), + (r'^/usr/local$', '/usr/local/share'), + (osx_system_prefix, '/usr/share')]} + + match = [i[1] for i in matches.get(type, []) if re.match(i[0], prefix)] + if not len(match): + raise ValueError("not supported type: {}".format(type)) + return match.pop() + + +def get_data_files(prefix): + return [(os.path.join(_resolve_prefix(prefix, 'man'), 'man/man1'), ['docs/_build/man/git-lint.1'])] + + +parser = argparse.ArgumentParser() +parser.add_argument('--prefix', default='', + help='prefix to install data files') +opts, _ = parser.parse_known_args(sys.argv) +prefix = opts.prefix or '/usr' try: from setuptools import setup @@ -22,6 +46,8 @@ test_requirements = [ # TODO: put package test requirements here ] +print get_data_files(prefix) + setup( name='git_linter', version='0.0.4', @@ -36,6 +62,7 @@ setup( package_dir={'git_lint': 'git_lint'}, include_package_data=True, + data_files = get_data_files(prefix), install_requires=requirements, license="MIT", zip_safe=False,