Skip to content

Commit

Permalink
Build and install dg.1 manpage
Browse files Browse the repository at this point in the history
  • Loading branch information
praiskup committed Sep 26, 2017
1 parent a2e6bf3 commit a83d723
Show file tree
Hide file tree
Showing 10 changed files with 157 additions and 110 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
*.py[oc]
*.egg-info
build
dist
man
MANIFEST
docs/_build
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "build_manpages"]
path = build_manpages
url = https://github.com/praiskup/build_manpages
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
language: python

before_script:
- git submodule update --init

python:
- "2.7"
- "3.5"
Expand All @@ -8,6 +12,6 @@ install:
- "pip install -r requirements.txt"
- "pip install pytest pytest-cov coveralls"

script: "make PYTHON=python${TRAVIS_PYTHON_VERSION} COVERAGE=true check"
script: "make PYTHON=python${TRAVIS_PYTHON_VERSION} COVERAGE=true check && python$TRAVIS_PYTHON_VERSION setup.py install --root $PWD/i"

after_success: "coveralls"
5 changes: 5 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Main contributors (alphabetical)
--------------------------------
Pavel Raiskup <[email protected]> (original author)
Slávek Kabrda <[email protected]> (current maintainer)
Tomáš Tomeček <[email protected]>
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
include AUTHORS
include dg
include requirements.txt
include LICENSE
Expand All @@ -8,5 +9,6 @@ include distconf/*.yaml
include docs/*.rst
include docs/conf.py
include docs/Makefile
recursive-include build_manpages *.py
recursive-include tests *.exp *.py *.tpl *.yaml distros container dg-opts
recursive-include tests/unittests/fixtures *
213 changes: 107 additions & 106 deletions bin/dg
Original file line number Diff line number Diff line change
Expand Up @@ -20,119 +20,120 @@ def die(msg):

description = \
"""
Generate script using predefined metadata about distribution and templates.
Generate script using predefined metadata about distribution and
templates.
As an example of 'dg' usage, to generate _Dockerfile_ for Fedora 21 64-bit
system, you may use command(s):
As an example of 'dg' usage, to generate _Dockerfile_ for Fedora
21 64-bit system, you may use command(s):
$ cd project/directory
$ dg --spec docker-data.yaml \\
--template docker.tpl \\
--distro fedora-21-x86_64.yaml
"""

def parse_args():
parser = ArgumentParser(
description=description,
formatter_class=RawDescriptionHelpFormatter,
)
parser.add_argument(
'--projectdir',
metavar='PROJECTDIR',
type=str,
help='Directory with project (defaults to CWD)',
default="."
)

parser.add_argument(
'--distro',
metavar='DIST',
type=str,
help='Use distribution metadata specified by DIST yaml file',
default="fedora-21-x86_64.yaml",
)

parser.add_argument(
'--multispec',
metavar='MULTISPEC',
type=str,
help='Use MULTISPEC yaml file to fill the TEMPLATE file',
)

parser.add_argument(
'--multispec-selector',
metavar='MULTISPEC_SELECTOR',
type=str,
help='Selectors for the multispec file',
action='append',
default=[],
)

parser.add_argument(
'--spec',
metavar='SPEC',
type=str,
help='Use SPEC yaml file to fill the TEMPLATE file',
action='append',
)

parser.add_argument(
'--output',
metavar='OUTPUT',
type=str,
help='Write result to OUTPUT file instead of stdout',
)

parser.add_argument(
'--macros-from',
metavar='PROJECTDIR',
type=str,
action='append',
help='Load variables from PROJECTDIR',
)

parser.add_argument(
'--container',
metavar='CONTAINER_TYPE',
type=str,
help='Container type, e.g. \'docker\'',
default=False,
)

parser.add_argument(
'--macro',
metavar='MACRO',
type=str,
action='append',
help='Define distgen\'s macro',
)

parser.add_argument(
'--max-passes',
metavar='PASSES',
type=int,
default=1,
help='Maximum number of rendering passes, defaults to 1 (== no re-rendering)',
)

tpl_or_combinations = parser.add_mutually_exclusive_group(required=True)

tpl_or_combinations.add_argument(
'--template',
metavar='TEMPLATE',
type=str,
help='Use TEMPLATE file, e.g. docker.tpl or a template string, '
'e.g. "{{ config.docker.from }}"'
)

tpl_or_combinations.add_argument(
'--multispec-combinations',
action='store_true',
help='Print available multispec combinations',
)

return parser.parse_args()

parser = ArgumentParser(
description=description,
formatter_class=RawDescriptionHelpFormatter,
)

# Solely for the purpose of manpage generator
parser.man_short_description = "templating system/generator for distributions"

parser.add_argument(
'--projectdir',
metavar='PROJECTDIR',
type=str,
help='Directory with project (defaults to CWD)',
default="."
)

parser.add_argument(
'--distro',
metavar='DIST',
type=str,
help='Use distribution metadata specified by DIST yaml file',
default="fedora-21-x86_64.yaml",
)

parser.add_argument(
'--multispec',
metavar='MULTISPEC',
type=str,
help='Use MULTISPEC yaml file to fill the TEMPLATE file',
)

parser.add_argument(
'--multispec-selector',
metavar='MULTISPEC_SELECTOR',
type=str,
help='Selectors for the multispec file',
action='append',
default=[],
)

parser.add_argument(
'--spec',
metavar='SPEC',
type=str,
help='Use SPEC yaml file to fill the TEMPLATE file',
action='append',
)

parser.add_argument(
'--output',
metavar='OUTPUT',
type=str,
help='Write result to OUTPUT file instead of stdout',
)

parser.add_argument(
'--macros-from',
metavar='PROJECTDIR',
type=str,
action='append',
help='Load variables from PROJECTDIR',
)

parser.add_argument(
'--container',
metavar='CONTAINER_TYPE',
type=str,
help='Container type, e.g. \'docker\'',
default=False,
)

parser.add_argument(
'--macro',
metavar='MACRO',
type=str,
action='append',
help='Define distgen\'s macro',
)

parser.add_argument(
'--max-passes',
metavar='PASSES',
type=int,
default=1,
help='Maximum number of rendering passes, defaults to 1 (== no re-rendering)',
)

tpl_or_combinations = parser.add_mutually_exclusive_group(required=True)

tpl_or_combinations.add_argument(
'--template',
metavar='TEMPLATE',
type=str,
help='Use TEMPLATE file, e.g. docker.tpl or a template string, '
'e.g. "{{ config.docker.from }}"'
)

tpl_or_combinations.add_argument(
'--multispec-combinations',
action='store_true',
help='Print available multispec combinations',
)

def print_multispec_combinations(args):
ms = Multispec.from_path(args.projectdir, args.multispec)
Expand Down Expand Up @@ -188,7 +189,7 @@ def render_template(args):


def main():
args = parse_args()
args = parser.parse_args()
if args.multispec_combinations:
print_multispec_combinations(args)
else:
Expand Down
1 change: 1 addition & 0 deletions build_manpages
Submodule build_manpages added at 5c16e8
7 changes: 6 additions & 1 deletion rpm/distgen.spec
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Name: distgen
Summary: Templating system/generator for distributions
Version: 0.17%{?postrel:.%{postrel}%{posttag}}
Release: 1%{?dist}
Release: 2%{?dist}
Group: Applications/Communications
License: GPLv2+
URL: https://github.com/devexp-db/distgen
Expand Down Expand Up @@ -49,14 +49,19 @@ make PYTHON=%{pybin} check

%files
%license LICENSE
%doc AUTHORS
%doc docs/
%{_bindir}/dg
%{pylib}/distgen
%{pylib}/%{name}-*.egg-info
%{_datadir}/%{name}
%{_mandir}/man1/*


%changelog
* Tue Sep 26 2017 Pavel Raiskup <[email protected]> - 0.17.dev1-2
- package manual page and AUTHORS file

* Mon Sep 18 2017 Slavek Kabrda <[email protected]> - 0.17.dev1-1
- update to 0.17.dev1

Expand Down
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build_manpages]
manpages =
man/dg.1:object=parser:pyfile=bin/dg
25 changes: 23 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
import sys
from setuptools import setup
from distgen.version import dg_version
from os import listdir, path
from os import listdir, path, getcwd

project = "distgen"
datadir = "share"
pkgdatadir = datadir + "/" + project
tpldir = pkgdatadir + "/templates"
distconfdir = pkgdatadir + "/distconf"

from setuptools.command.build_py import build_py
from setuptools.command.install import install
try:
sys.path = [path.join(getcwd(), 'build_manpages')] + sys.path
from build_manpages.build_manpages \
import build_manpages, get_build_py_cmd, get_install_cmd
except:
print("=======================================")
print("Use 'git submodule update --init' first")
print("=======================================")
raise

def dynamic_data_files():
dynamic_list = []
for dcdir in ["distconf", "distconf/lib"]:
Expand All @@ -26,7 +39,10 @@ def get_requirements():
name='distgen',
version=dg_version,
description='Templating system/generator for distributions',
author='[email protected]',
author='Pavel Raiskup (see AUTHORS)',
author_email='[email protected]',
maintainer='Bohuslav Kabrda',
maintainer_email='[email protected]',
license='GPLv2+',
url='https://github.com/devexp-db/distgen',
platforms=['any'],
Expand All @@ -44,4 +60,9 @@ def get_requirements():
] + dynamic_data_files(),
scripts=['bin/dg'],
install_requires=get_requirements(),
cmdclass={
'build_manpages': build_manpages,
'build_py': get_build_py_cmd(build_py),
'install': get_install_cmd(install),
},
)

0 comments on commit a83d723

Please sign in to comment.