Skip to content

Commit

Permalink
vcspull: update package to conventions used in tony/cookiecutter-pypa…
Browse files Browse the repository at this point in the history
…ckage.
  • Loading branch information
tony committed Feb 5, 2014
1 parent 414fb42 commit 989a494
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 45 deletions.
2 changes: 2 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dev

- Use werkzeug/flask style unit test suites.
- [docs] Fix section headings.
- [internals] use conventions from `tony/cookiecutter-pypackage`_

0.0.7
-----
Expand Down Expand Up @@ -131,5 +132,6 @@ https://github.com/tony/pullv/compare/a96e723269...a5be723de5
.. _pep8: http://www.python.org/dev/peps/pep-0008/
.. _sphinx-argparse: https://github.com/tony/sphinx-argparse
.. _argcomplete: https://github.com/kislyuk/argcomplete
.. _tony/cookiecutter-pypackage: https://github.com/tony/cookiecutter-pypackage.

.. todo:: vim: set filetype=rst:
46 changes: 25 additions & 21 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@

import sys, os

sys.path.append(os.path.abspath('.'))
sys.path.append(os.path.abspath('..'))

# Get the project root dir, which is the parent dir of this
cwd = os.getcwd()
project_root = os.path.dirname(cwd)

sys.path.insert(0, project_root)
from ..package_metadata import p

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
Expand Down Expand Up @@ -48,8 +53,8 @@
master_doc = 'index'

# General information about the project.
project = u'vcspull'
copyright = u'2013, Tony Narlock'
project = p.title
copyright = p.copyright

rst_prolog = """
.. note::
Expand All @@ -60,15 +65,14 @@
.. _Issue tracker: https://github.com/tony/vcspull/issues
"""


# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '0.1'
version = '%s' % ('.'.join(p.version.split('.'))[:2])
# The full version, including alpha/beta/rc tags.
release = '0.1'
release = '%s' % (p.version)

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down Expand Up @@ -104,24 +108,23 @@
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []

# If true, keep warnings as "system message" paragraphs in the built documents.
#keep_warnings = False


# -- Options for HTML output ---------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
if on_rtd:
html_theme = 'default'
else:
html_theme = 'pyramid'
html_theme = 'default'

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}

# Add any paths that contain custom themes here, relative to this directory.
html_theme_path = ['_themes']
#html_theme_path = []

# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
Expand Down Expand Up @@ -186,7 +189,7 @@
#html_file_suffix = None

# Output file base name for HTML help builder.
htmlhelp_basename = 'vcspulldoc'
htmlhelp_basename = '%sdoc' % p.title


# -- Options for LaTeX output --------------------------------------------------
Expand All @@ -205,8 +208,8 @@
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'vcspull.tex', u'vcspull Documentation',
u'Tony Narlock', 'manual'),
('index', '{0}.tex'.format(p.package_name), '{0} Documentation'.format(p.title),
p.author, 'manual'),
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -235,8 +238,8 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'vcspull', u'vcspull Documentation',
[u'Tony Narlock'], 1)
('index', p.package_name, '{0} Documentation'.format(p.title),
p.author, 1),
]

# If true, show URL addresses after external links.
Expand All @@ -249,9 +252,8 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'vcspull', u'vcspull Documentation',
u'Tony Narlock', 'vcspull', 'One line description of project.',
'Miscellaneous'),
('index', '{0}'.format(p.package_name), '{0} Documentation'.format(p.title),
p.author, p.package_name, p.description, 'Miscellaneous'),
]

# Documents to append as an appendix to all manuals.
Expand All @@ -263,6 +265,8 @@
# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'

# If true, do not generate a @detailmenu in the "Top" node's menu.
#texinfo_no_detailmenu = False

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'http://docs.python.org/': None, 'pip': ('http://sphinx.readthedocs.org/en/latest/', None)}
61 changes: 61 additions & 0 deletions package_metadata.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import absolute_import, division, print_function, \
with_statement, unicode_literals

import os
import sys
import re

package_file = os.path.join(os.path.dirname(__file__), "vcspull/__init__.py")
file_content = open(package_file, "rt").read()


class Package_Metadata(dict):
__getattr__ = dict.__getitem__
__setattr__ = dict.__setitem__

attributes = [
'title', 'package_name', 'author', 'description', 'email',
'version', 'license', 'copyright'
]

@staticmethod
def get_attribute(attr, file_content):
regex_expression = r"^__{0}__ = ['\"]([^'\"]*)['\"]".format(attr)
mo = re.search(regex_expression, file_content, re.M)
if mo:
return mo.group(1)
else:
raise RuntimeError("Unable to find version string in %s." % (package_file,))

def refresh(self, attributes):

file_content = open(self.package_file, "rt").read()

for k in attributes:
attr_val = self.get_attribute(k, file_content)
if attr_val:
self[k] = attr_val

def __init__(self, package_file, attributes=None):

if attributes:
self.attributes = attributes

self.package_file = package_file

self.refresh(self.attributes)


p = Package_Metadata(package_file)


def print_metadata():
for k, v in p.items():
print('%s: %s' % (k, v))

if __name__ == '__main__':
print_metadata()
sys.exit()
39 changes: 15 additions & 24 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""vcspull lives at <https://github.com/tony/vcspull>.
"""vcspull lives at <https://github.com/tony/vcspull>."""

vcspull
-------
Mass update git, hg and svn repos simultaneously from YAML / JSON file.
"""
import sys
import os
from setuptools import setup

sys.path.insert(0, os.getcwd()) # we want to grab this:
from package_metadata import p

with open('requirements.pip') as f:
install_reqs = [line for line in f.read().split('\n') if line]
tests_reqs = []
Expand All @@ -19,32 +17,25 @@
install_reqs += ['argparse']
tests_reqs += ['unittest2']

import re
VERSIONFILE = "vcspull/__init__.py"
verstrline = open(VERSIONFILE, "rt").read()
VSRE = r"^__version__ = ['\"]([^'\"]*)['\"]"
mo = re.search(VSRE, verstrline, re.M)
if mo:
__version__ = mo.group(1)
else:
raise RuntimeError("Unable to find version string in %s." % (VERSIONFILE,))
readme = open('README.rst').read()
history = open('CHANGES').read().replace('.. :changelog:', '')

setup(
name='vcspull',
version=__version__,
name=p.title,
version=p.version,
url='http://github.com/tony/vcspull/',
download_url='https://pypi.python.org/pypi/vcspull',
license='BSD',
author='Tony Narlock',
author_email='tony@git-pull.com',
description='Mass update git, hg and svn repos simultaneously from '
'YAML / JSON file.',
long_description=open('README.rst').read(),
license=p.license,
author=p.author,
author_email=p.email,
description=p.description,
long_description=readme + '\n\n' + history,
include_package_data=True,
install_requires=install_reqs,
tests_require=tests_reqs,
test_suite='vcspull.testsuite',
zip_safe=False,
keywords=p.title,
packages=['vcspull', 'vcspull.testsuite', 'vcspull.repo', 'vcspull._vendor', 'vcspull._vendor.colorama'],
scripts=['pkg/vcspull.bash', 'pkg/vcspull.zsh', 'pkg/vcspull.tcsh'],
entry_points=dict(console_scripts=['vcspull=vcspull:cli.main']),
Expand Down
3 changes: 3 additions & 0 deletions vcspull/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@
with_statement, unicode_literals

__title__ = 'vcspull'
__package_name__ = 'vcspull'
__description__ = 'Mass update git, hg and svn repos simultaneously from YAML / JSON file.'
__version__ = '0.0.7'
__author__ = 'Tony Narlock'
__email__ = 'tony@git-pull.com'
__license__ = 'BSD'
__copyright__ = 'Copyright 2013 Tony Narlock'

Expand Down

0 comments on commit 989a494

Please sign in to comment.