1
0
mirror of https://github.com/ansible/mazer.git synced 2026-02-05 12:45:17 +01:00

bootstrap package setup via cookiecutter (#6)

bootstrap package setup via cookiecutter

Based on template from https://github.com/audreyr/cookiecutter-pypackage

Changes from default template:
* unpin dev requirements for now
* rm 'watchdog' dev requirement and remove use
from Makefile
* sort requirements_dev, unpin and note bumpversion
* Use 'Apache-2.0' spdx.org style licence identifier to match ansible/galaxy/setup.py.
* rm docs from sdist
* mv rst docs to docs/rst
* add .pytest_cache to gitignore
This commit is contained in:
Adrian Likins
2018-04-19 12:33:14 -04:00
committed by GitHub
parent fe42064f6f
commit 0502f70d3e
24 changed files with 675 additions and 1 deletions

5
.gitignore vendored
View File

@@ -25,6 +25,9 @@ wheels/
.installed.cfg
*.egg
# pytest
.pytest_cache/
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
@@ -62,7 +65,7 @@ instance/
.scrapy
# Sphinx documentation
docs/_build/
docs/rst/_build/
# PyBuilder
target/

16
AUTHORS.rst Normal file
View File

@@ -0,0 +1,16 @@
=======
Credits
=======
Development Lead
----------------
* Adrian Likins <@alikins>
* Chris Houseknecht <@chouseknecht>
* Alexander Saprykin <@cutwater>
Based on
--------
ansible-galaxy from `<https://github.com/ansible/ansible>`

128
CONTRIBUTING.rst Normal file
View File

@@ -0,0 +1,128 @@
.. highlight:: shell
============
Contributing
============
Contributions are welcome, and they are greatly appreciated! Every little bit
helps, and credit will always be given.
You can contribute in many ways:
Types of Contributions
----------------------
Report Bugs
~~~~~~~~~~~
Report bugs at https://github.com/ansible/ansible_galaxy_cli/issues.
If you are reporting a bug, please include:
* Your operating system name and version.
* Any details about your local setup that might be helpful in troubleshooting.
* Detailed steps to reproduce the bug.
Fix Bugs
~~~~~~~~
Look through the GitHub issues for bugs. Anything tagged with "bug" and "help
wanted" is open to whoever wants to implement it.
Implement Features
~~~~~~~~~~~~~~~~~~
Look through the GitHub issues for features. Anything tagged with "enhancement"
and "help wanted" is open to whoever wants to implement it.
Write Documentation
~~~~~~~~~~~~~~~~~~~
ansible-galaxy-cli could always use more documentation, whether as part of the
official ansible-galaxy-cli docs, in docstrings, or even on the web in blog posts,
articles, and such.
Submit Feedback
~~~~~~~~~~~~~~~
The best way to send feedback is to file an issue at https://github.com/ansible/ansible_galaxy_cli/issues.
If you are proposing a feature:
* Explain in detail how it would work.
* Keep the scope as narrow as possible, to make it easier to implement.
* Remember that this is a volunteer-driven project, and that contributions
are welcome :)
Get Started!
------------
Ready to contribute? Here's how to set up `ansible_galaxy_cli` for local development.
1. Fork the `ansible_galaxy_cli` repo on GitHub.
2. Clone your fork locally::
$ git clone git@github.com:your_name_here/ansible_galaxy_cli.git
3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development::
$ mkvirtualenv ansible_galaxy_cli
$ cd ansible_galaxy_cli/
$ python setup.py develop
4. Create a branch for local development::
$ git checkout -b name-of-your-bugfix-or-feature
Now you can make your changes locally.
5. When you're done making changes, check that your changes pass flake8 and the
tests, including testing other Python versions with tox::
$ flake8 ansible_galaxy_cli tests
$ python setup.py test or py.test
$ tox
To get flake8 and tox, just pip install them into your virtualenv.
6. Commit your changes and push your branch to GitHub::
$ git add .
$ git commit -m "Your detailed description of your changes."
$ git push origin name-of-your-bugfix-or-feature
7. Submit a pull request through the GitHub website.
Pull Request Guidelines
-----------------------
Before you submit a pull request, check that it meets these guidelines:
1. The pull request should include tests.
2. If the pull request adds functionality, the docs should be updated. Put
your new functionality into a function with a docstring, and add the
feature to the list in README.rst.
3. The pull request should work for Python 2.7, 3.4, 3.5 and 3.6, and for PyPy. Check
https://travis-ci.org/ansible/ansible_galaxy_cli/pull_requests
and make sure that the tests pass for all supported Python versions.
Tips
----
To run a subset of tests::
$ py.test tests.test_ansible_galaxy_cli
Deploying
---------
A reminder for the maintainers on how to deploy.
Make sure all your changes are committed (including an entry in HISTORY.rst).
Then run::
$ bumpversion patch # possible: major / minor / patch
$ git push
$ git push --tags
Travis will then deploy to PyPI if tests pass.

8
HISTORY.rst Normal file
View File

@@ -0,0 +1,8 @@
=======
History
=======
0.1.0 (2018-04-18)
------------------
* First release on PyPI.

10
MANIFEST.in Normal file
View File

@@ -0,0 +1,10 @@
include AUTHORS.rst
include CONTRIBUTING.rst
include HISTORY.rst
include LICENSE
include README.rst
recursive-include tests *
recursive-exclude * __pycache__
recursive-exclude * *.py[co]

58
Makefile Normal file
View File

@@ -0,0 +1,58 @@
RST_DOCS_DIR=docs/rst
.PHONY: clean clean-test clean-pyc clean-build docs help
.DEFAULT_GOAL := help
clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts
clean-build: ## remove build artifacts
rm -fr build/
rm -fr dist/
rm -fr .eggs/
find . -name '*.egg-info' -exec rm -fr {} +
find . -name '*.egg' -exec rm -f {} +
clean-pyc: ## remove Python file artifacts
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
find . -name '__pycache__' -exec rm -fr {} +
clean-test: ## remove test and coverage artifacts
rm -fr .tox/
rm -f .coverage
rm -fr htmlcov/
rm -fr .pytest_cache
lint: ## check style with flake8
flake8 ansible_galaxy_cli tests
test: ## run tests quickly with the default Python
py.test
test-all: ## run tests on every Python version with tox
tox
coverage: ## check code coverage quickly with the default Python
coverage run --source ansible_galaxy_cli -m pytest
coverage report -m
coverage html
docs: ## generate Sphinx HTML documentation, including API docs
rm -f $(RST_DOCS_DIR)/ansible_galaxy_cli.rst
rm -f $(RST_DOCS_DIR)/modules.rst
sphinx-apidoc -o $(RST_DOCS_DIR) ansible_galaxy_cli
$(MAKE) -C $(RST_DOCS_DIR) clean
$(MAKE) -C $(RST_DOCS_DIR) html
release: dist ## package and upload a release
twine upload dist/*
dist: clean ## builds source and wheel package
python setup.py sdist
python setup.py bdist_wheel
ls -l dist
install: clean ## install the package to the active Python's site-packages
python setup.py install

8
README.rst Normal file
View File

@@ -0,0 +1,8 @@
======
README
======
ansible-galaxy-cli
Ansible content manager

View File

@@ -0,0 +1 @@
__version__ = '0.1.0'

20
docs/rst/Makefile Normal file
View File

@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = python -msphinx
SPHINXPROJ = ansible_galaxy_cli
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)

1
docs/rst/authors.rst Normal file
View File

@@ -0,0 +1 @@
.. include:: ../../AUTHORS.rst

163
docs/rst/conf.py Executable file
View File

@@ -0,0 +1,163 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# ansible_galaxy_cli documentation build configuration file, created by
# sphinx-quickstart on Fri Jun 9 13:47:02 2017.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
# 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 documentation root, use os.path.abspath to make it
# absolute, like shown here.
#
import os
import sys
sys.path.insert(0, os.path.abspath('../..'))
import ansible_galaxy_cli
# -- General configuration ---------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode']
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'ansible-galaxy-cli'
copyright = u"2018, Red Hat, Inc."
author = u"Red Hat, Inc."
# 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 = ansible_galaxy_cli.__version__
# The full version, including alpha/beta/rc tags.
release = ansible_galaxy_cli.__version__
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False
# -- Options for HTML output -------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'alabaster'
# 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 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']
# -- Options for HTMLHelp output ---------------------------------------
# Output file base name for HTML help builder.
htmlhelp_basename = 'ansible_galaxy_clidoc'
# -- Options for LaTeX output ------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',
# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass
# [howto, manual, or own class]).
latex_documents = [
(master_doc, 'ansible_galaxy_cli.tex',
u'ansible-galaxy-cli Documentation',
u'Red Hat, Inc.', 'manual'),
]
# -- Options for manual page output ------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'ansible_galaxy_cli',
u'ansible-galaxy-cli Documentation',
[author], 1)
]
# -- Options for Texinfo output ----------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'ansible_galaxy_cli',
u'ansible-galaxy-cli Documentation',
author,
'ansible_galaxy_cli',
'One line description of project.',
'Miscellaneous'),
]

View File

@@ -0,0 +1 @@
.. include:: ../../CONTRIBUTING.rst

1
docs/rst/history.rst Normal file
View File

@@ -0,0 +1 @@
.. include:: ../../HISTORY.rst

20
docs/rst/index.rst Normal file
View File

@@ -0,0 +1,20 @@
Welcome to ansible-galaxy-cli's documentation!
==============================================
.. toctree::
:maxdepth: 2
:caption: Contents:
readme
installation
usage
modules
contributing
authors
history
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

51
docs/rst/installation.rst Normal file
View File

@@ -0,0 +1,51 @@
.. highlight:: shell
============
Installation
============
Stable release
--------------
To install ansible-galaxy-cli, run this command in your terminal:
.. code-block:: console
$ pip install ansible_galaxy_cli
This is the preferred method to install ansible-galaxy-cli, as it will always install the most recent stable release.
If you don't have `pip`_ installed, this `Python installation guide`_ can guide
you through the process.
.. _pip: https://pip.pypa.io
.. _Python installation guide: http://docs.python-guide.org/en/latest/starting/installation/
From sources
------------
The sources for ansible-galaxy-cli can be downloaded from the `Github repo`_.
You can either clone the public repository:
.. code-block:: console
$ git clone git://github.com/ansible/ansible_galaxy_cli
Or download the `tarball`_:
.. code-block:: console
$ curl -OL https://github.com/ansible/ansible_galaxy_cli/tarball/master
Once you have a copy of the source, you can install it with:
.. code-block:: console
$ python setup.py install
.. _Github repo: https://github.com/ansible/ansible_galaxy_cli
.. _tarball: https://github.com/ansible/ansible_galaxy_cli/tarball/master

36
docs/rst/make.bat Normal file
View File

@@ -0,0 +1,36 @@
@ECHO OFF
pushd %~dp0
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=python -msphinx
)
set SOURCEDIR=.
set BUILDDIR=_build
set SPHINXPROJ=ansible_galaxy_cli
if "%1" == "" goto help
%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The Sphinx module was not found. Make sure you have Sphinx installed,
echo.then set the SPHINXBUILD environment variable to point to the full
echo.path of the 'sphinx-build' executable. Alternatively you may add the
echo.Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
goto end
:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
:end
popd

7
docs/rst/modules.rst Normal file
View File

@@ -0,0 +1,7 @@
ansible_galaxy_cli
==================
.. toctree::
:maxdepth: 4
ansible_galaxy_cli

1
docs/rst/readme.rst Normal file
View File

@@ -0,0 +1 @@
.. include:: ../../README.rst

7
docs/rst/usage.rst Normal file
View File

@@ -0,0 +1,7 @@
=====
Usage
=====
To use ansible-galaxy-cli in a project::
import ansible_galaxy_cli

10
requirements_dev.txt Normal file
View File

@@ -0,0 +1,10 @@
# TODO(alikins): remove bumpverion if we dont use it
bumpversion
coverage
flake8
pip
pytest
pytest-runner
Sphinx
tox
wheel

26
setup.cfg Normal file
View File

@@ -0,0 +1,26 @@
[bumpversion]
current_version = 0.1.0
commit = True
tag = True
[bumpversion:file:setup.py]
search = version='{current_version}'
replace = version='{new_version}'
[bumpversion:file:ansible_galaxy_cli/__init__.py]
search = __version__ = '{current_version}'
replace = __version__ = '{new_version}'
[bdist_wheel]
universal = 1
[flake8]
exclude = docs
[aliases]
# Define setup.py command aliases here
test = pytest
[tool:pytest]
collect_ignore = ['setup.py']

49
setup.py Normal file
View File

@@ -0,0 +1,49 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""The setup script."""
from setuptools import setup, find_packages
with open('README.rst') as readme_file:
readme = readme_file.read()
with open('HISTORY.rst') as history_file:
history = history_file.read()
requirements = [ ]
setup_requirements = ['pytest-runner', ]
test_requirements = ['pytest', ]
setup(
author="Red Hat, Inc.",
author_email='info@ansible.com',
classifiers=[
'Development Status :: 2 - Pre-Alpha',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Natural Language :: English',
"Programming Language :: Python :: 2",
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
],
description="Manage Ansible roles and contents from the command line.",
install_requires=requirements,
license="Apache-2.0",
long_description=readme + '\n\n' + history,
include_package_data=True,
keywords='ansible_galaxy_cli',
name='ansible_galaxy_cli',
packages=find_packages(include=['ansible_galaxy_cli']),
setup_requires=setup_requirements,
test_suite='tests',
tests_require=test_requirements,
url='https://github.com/ansible/ansible_galaxy_cli',
version='0.1.0',
zip_safe=False,
)

View File

@@ -0,0 +1,23 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Tests for `ansible_galaxy_cli` package."""
import pytest
@pytest.fixture
def response():
"""Sample pytest fixture.
See more at: http://doc.pytest.org/en/latest/fixture.html
"""
# import requests
# return requests.get('https://github.com/audreyr/cookiecutter-pypackage')
def test_content(response):
"""Sample pytest test function with the pytest fixture as an argument."""
# from bs4 import BeautifulSoup
# assert 'GitHub' in BeautifulSoup(response.content).title.string

26
tox.ini Normal file
View File

@@ -0,0 +1,26 @@
[tox]
envlist = py27, py36, flake8
[travis]
python =
3.6: py36
2.7: py27
[testenv:flake8]
basepython = python
deps = flake8
commands = flake8 ansible_galaxy_cli
[testenv]
setenv =
PYTHONPATH = {toxinidir}
deps =
-r{toxinidir}/requirements_dev.txt
; If you want to make tox run the tests with the same versions, create a
; requirements.txt with the pinned versions and uncomment the following line:
; -r{toxinidir}/requirements.txt
commands =
pip install -U pip
py.test --basetemp={envtmpdir}