Skip to content

Commit

Permalink
Add initial Python package structure
Browse files Browse the repository at this point in the history
Update Camayoc's Python package structure.

* Add documentation directory.
* Update setup.py to install the development packages.
* Add MANIFEST.in file and make it include LICENSE file when building
  the package.
* Add Makefile and targets to help building the documentation,
  installing camayoc and development packages, running linters, running
  tests and managing/building the camayoc package.
* Create some python packages camayoc (for framework modules),
  camayoc.tests (for RHO's functional tests) and tests (for camayocs
  unit tests).

Closes #1
  • Loading branch information
elyezer committed Jul 31, 2017
1 parent 7625d4c commit 708ee93
Show file tree
Hide file tree
Showing 9 changed files with 202 additions and 3 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include LICENSE
49 changes: 49 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
help:
@echo "Please use \`make <target>' where <target> is one of:"
@echo " help to show this message"
@echo " all to to execute test-coverage and lint"
@echo " docs-clean to remove documentation"
@echo " docs-html to generate HTML documentation"
@echo " install to install in editable mode"
@echo " install-dev to install in editable modeplus the dev packages"
@echo " lint to run flake8"
@echo " package to generate installable Python packages"
@echo " package-clean to remove generated Python packages"
@echo " package-upload to upload dist/* to PyPI"
@echo " test to run unit tests"
@echo " test-coverage to run unit tests and measure test coverage"

all: test-coverage lint

docs-clean:
@cd docs; $(MAKE) clean

docs-html:
@cd docs; $(MAKE) html

install:
pip install -e .

install-dev:
pip install -e .[dev]

lint:
flake8 .

package: package-clean
python setup.py --quiet sdist bdist_wheel

package-clean:
rm -rf build dist camayoc.egg-info

package-upload: package
twine upload dist/*

test:
py.test tests

test-coverage:
py.test --verbose --cov-report term --cov=camayoc tests

.PHONY: all docs-clean docs-html install install-dev lint package \
package-clean package-upload test test-coverage
2 changes: 2 additions & 0 deletions camayoc/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# coding=utf-8
"""A Python library that facilitates functional testing of quipucords."""
8 changes: 8 additions & 0 deletions camayoc/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# coding=utf-8
"""Tests for RHO.
This package and its sub-packages contain functional tests for RHO. These tests
should be run against RHO installations. These tests run RHO remotely (trhough
a SSH connection) or locally. These tests are entirely different from the unit
tests in :mod:`tests`.
"""
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = python -msphinx
SPHINXPROJ = Camayoc
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
76 changes: 76 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# coding=utf-8
"""Sphinx documentation generator configuration file.
The full set of configuration options is listed on the Sphinx website:
http://sphinx-doc.org/config.html
"""

import os
import sys

# Add the project root directory to the system path. This allows references
# such as :mod:`camayoc.whatever` to be processed correctly.
ROOT_DIR = os.path.abspath(os.path.join(
os.path.dirname(__file__),
os.path.pardir
))
sys.path.insert(0, ROOT_DIR)

# Project information ---------------------------------------------------------

project = 'Camayoc'
author = 'Quipucords Team'
copyright = '2017, {}'.format(author)

# The short X.Y version.
version = ''
# The full version, including alpha/beta/rc tags.
release = ''


# General configuration -------------------------------------------------------

exclude_patterns = ['_build']
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.viewcode',
]
language = None
master_doc = 'index'
pygments_style = 'sphinx'
source_suffix = '.rst'
templates_path = ['_templates']
todo_include_todos = False


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

html_theme = 'alabaster'

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options see:
# http://alabaster.readthedocs.io/en/latest/customization.html#theme-options
html_theme_options = {
'github_user': 'quipucords',
'github_repo': 'camayoc',
'travis_button': True,
}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']

# Custom sidebar templates, must be a dictionary that maps document names to
# template names.
#
# See: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars
html_sidebars = {
'**': [
'about.html',
'navigation.html',
'relations.html', # needs 'show_related': True theme option to display
'searchbox.html',
'donate.html',
]
}
20 changes: 20 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.. Camayoc documentation master file, created by
sphinx-quickstart on Fri Jul 28 15:31:27 2017.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to Camayoc's documentation!
===================================

.. toctree::
:maxdepth: 2
:caption: Contents:



Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
23 changes: 20 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# coding=utf-8
"""A setuptools-based script for installing camayoc."""
import os
from setuptools import setup
from setuptools import find_packages, setup

_project_root = os.path.abspath(os.path.dirname(__file__))

Expand Down Expand Up @@ -30,9 +30,26 @@
'A GPL-licensed Python library that facilitates functional testing of '
'quipucords.'
),
include_package_data=True,
extras_require={
'dev': [
# For `make docs`
'sphinx',
# For `make lint`
'flake8',
'flake8-docstrings',
'flake8-quotes',
# For `make package`
'wheel',
# For `make package-upload`
'twine',
# For `make test`
'pytest',
# For `make test-coverage`
'pytest-cov',
],
},
license='GPLv3',
long_description=long_description,
package_data={'': ['LICENSE']},
packages=find_packages(include=['camayoc*']),
url='https://github.com/quipucords/camayoc',
)
6 changes: 6 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# coding=utf-8
"""Unit tests for Camayoc.
This package and its sub-packages contain tests for Camayoc. These tests verify
that Camayoc's internal functions and libraries function correctly.
"""

0 comments on commit 708ee93

Please sign in to comment.