Project skeleton with cookiecutter-pylibrary.

master
Harshad Sharma 7 years ago
commit 905da70079

@ -0,0 +1,13 @@
[bumpversion]
current_version = 0.1.0
commit = True
tag = True
[bumpversion:file:setup.py]
[bumpversion:file:README.rst]
[bumpversion:file:docs/conf.py]
[bumpversion:file:src/qutescript/__init__.py]

@ -0,0 +1,49 @@
# This file exists so you can easily regenerate your project.
#
# `cookiepatcher` is a convenient shim around `cookiecutter`
# for regenerating projects (it will generate a .cookiecutterrc
# automatically for any template). To use it:
#
# pip install cookiepatcher
# cookiepatcher gh:ionelmc/cookiecutter-pylibrary project-path
#
# See:
# https://pypi.python.org/pypi/cookiepatcher
#
# Alternatively, you can run:
#
# cookiecutter --overwrite-if-exists --config-file=project-path/.cookiecutterrc gh:ionelmc/cookiecutter-pylibrary
default_context:
appveyor: 'no'
c_extension_cython: 'no'
c_extension_optional: 'no'
c_extension_support: 'no'
codacy: 'no'
codeclimate: 'no'
codecov: 'no'
command_line_interface: 'argparse'
command_line_interface_bin_name: 'qutescript'
coveralls: 'no'
distribution_name: 'qutescript'
email: 'harshad@sharma.io'
full_name: 'Harshad Sharma'
github_username: 'hiway'
landscape: 'no'
package_name: 'qutescript'
project_name: 'qutescript'
project_short_description: 'Painless userscripts for qutebrowser.'
release_date: 'today'
repo_name: 'python-qutescript'
requiresio: 'no'
scrutinizer: 'no'
sphinx_doctest: 'no'
sphinx_theme: 'sphinx-rtd-theme'
test_matrix_configurator: 'no'
test_matrix_separate_coverage: 'no'
test_runner: 'pytest'
travis: 'yes'
version: '0.1.0'
website: 'https://github.com/hiway/'
year: 'now'

@ -0,0 +1,16 @@
[paths]
source =
src/qutescript
*/site-packages/qutescript
[run]
branch = true
source =
qutescript
tests
parallel = true
[report]
show_missing = true
precision = 2
omit = *migrations*

@ -0,0 +1,13 @@
# see http://editorconfig.org
root = true
[*]
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 4
charset = utf-8
[*.{bat,cmd,ps1}]
end_of_line = crlf

64
.gitignore vendored

@ -0,0 +1,64 @@
*.py[cod]
# C extensions
*.so
# Packages
*.egg
*.egg-info
dist
build
eggs
.eggs
parts
bin
var
sdist
wheelhouse
develop-eggs
.installed.cfg
lib
lib64
venv*/
pyvenv*/
# Installer logs
pip-log.txt
# Unit test / coverage reports
.coverage
.tox
.coverage.*
nosetests.xml
coverage.xml
htmlcov
# Translations
*.mo
# Mr Developer
.mr.developer.cfg
.project
.pydevproject
.idea
*.iml
*.komodoproject
# Complexity
output/*.html
output/*/index.html
# Sphinx
docs/_build
.DS_Store
*~
.*.sw[po]
.build
.ve
.env
.cache
.pytest
.bootstrap
.appveyor.token
*.bak

@ -0,0 +1,49 @@
language: python
sudo: false
cache: pip
env:
global:
- LD_PRELOAD=/lib/x86_64-linux-gnu/libSegFault.so
- SEGFAULT_SIGNALS=all
matrix:
- TOXENV=check
- TOXENV=docs
matrix:
include:
- python: '2.7'
env:
- TOXENV=py27,report
- python: '3.3'
env:
- TOXENV=py33,report
- python: '3.4'
env:
- TOXENV=py34,report
- python: '3.5'
env:
- TOXENV=py35,report
- python: '3.6'
env:
- TOXENV=py36,report
- python: 'pypy-5.4'
env:
- TOXENV=pypy,report
before_install:
- python --version
- uname -a
- lsb_release -a
install:
- pip install tox
- virtualenv --version
- easy_install --version
- pip --version
- tox --version
script:
- tox -v
after_failure:
- more .tox/log/* | cat
- more .tox/*/log/* | cat
notifications:
email:
on_success: never
on_failure: always

@ -0,0 +1,5 @@
Authors
=======
* Harshad Sharma - https://github.com/hiway/

@ -0,0 +1,8 @@
Changelog
=========
0.1.0 (2017-06-16)
------------------
* First release on PyPI.

@ -0,0 +1,90 @@
============
Contributing
============
Contributions are welcome, and they are greatly appreciated! Every
little bit helps, and credit will always be given.
Bug reports
===========
When `reporting a bug <https://github.com/hiway/python-qutescript/issues>`_ 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.
Documentation improvements
==========================
qutescript could always use more documentation, whether as part of the
official qutescript docs, in docstrings, or even on the web in blog posts,
articles, and such.
Feature requests and feedback
=============================
The best way to send feedback is to file an issue at https://github.com/hiway/python-qutescript/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 code contributions are welcome :)
Development
===========
To set up `python-qutescript` for local development:
1. Fork `python-qutescript <https://github.com/hiway/python-qutescript>`_
(look for the "Fork" button).
2. Clone your fork locally::
git clone git@github.com:your_name_here/python-qutescript.git
3. Create a branch for local development::
git checkout -b name-of-your-bugfix-or-feature
Now you can make your changes locally.
4. When you're done making changes, run all the checks, doc builder and spell checker with `tox <http://tox.readthedocs.io/en/latest/install.html>`_ one command::
tox
5. 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
6. Submit a pull request through the GitHub website.
Pull Request Guidelines
-----------------------
If you need some code review or feedback while you're developing the code just make the pull request.
For merging, you should:
1. Include passing tests (run ``tox``) [1]_.
2. Update documentation when there's new API, functionality etc.
3. Add a note to ``CHANGELOG.rst`` about the changes.
4. Add yourself to ``AUTHORS.rst``.
.. [1] If you don't have all the necessary python versions available locally you can rely on Travis - it will
`run the tests <https://travis-ci.org/hiway/python-qutescript/pull_requests>`_ for each change you add in the pull request.
It will be slower though ...
Tips
----
To run a subset of tests::
tox -e envname -- py.test -k test_myfeature
To run all the test environments in *parallel* (you need to ``pip install detox``)::
detox

@ -0,0 +1,19 @@
Copyright (c) 2017, Harshad Sharma
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

@ -0,0 +1,21 @@
graft docs
graft examples
graft src
graft ci
graft tests
include .bumpversion.cfg
include .coveragerc
include .cookiecutterrc
include .editorconfig
include .isort.cfg
include AUTHORS.rst
include CHANGELOG.rst
include CONTRIBUTING.rst
include LICENSE
include README.rst
include tox.ini .travis.yml appveyor.yml
global-exclude *.py[cod] __pycache__ *.so *.dylib

@ -0,0 +1,88 @@
========
Overview
========
.. start-badges
.. list-table::
:stub-columns: 1
* - docs
- |docs|
* - tests
- | |travis|
|
* - package
- | |version| |wheel| |supported-versions| |supported-implementations|
| |commits-since|
.. |docs| image:: https://readthedocs.org/projects/python-qutescript/badge/?style=flat
:target: https://readthedocs.org/projects/python-qutescript
:alt: Documentation Status
.. |travis| image:: https://travis-ci.org/hiway/python-qutescript.svg?branch=master
:alt: Travis-CI Build Status
:target: https://travis-ci.org/hiway/python-qutescript
.. |version| image:: https://img.shields.io/pypi/v/qutescript.svg
:alt: PyPI Package latest release
:target: https://pypi.python.org/pypi/qutescript
.. |commits-since| image:: https://img.shields.io/github/commits-since/hiway/python-qutescript/v0.1.0.svg
:alt: Commits since latest release
:target: https://github.com/hiway/python-qutescript/compare/v0.1.0...master
.. |wheel| image:: https://img.shields.io/pypi/wheel/qutescript.svg
:alt: PyPI Wheel
:target: https://pypi.python.org/pypi/qutescript
.. |supported-versions| image:: https://img.shields.io/pypi/pyversions/qutescript.svg
:alt: Supported versions
:target: https://pypi.python.org/pypi/qutescript
.. |supported-implementations| image:: https://img.shields.io/pypi/implementation/qutescript.svg
:alt: Supported implementations
:target: https://pypi.python.org/pypi/qutescript
.. end-badges
Painless userscripts for qutebrowser.
* Free software: BSD license
Installation
============
::
pip install qutescript
Documentation
=============
https://python-qutescript.readthedocs.io/
Development
===========
To run the all tests run::
tox
Note, to combine the coverage data from all the tox environments run:
.. list-table::
:widths: 10 90
:stub-columns: 1
- - Windows
- ::
set PYTEST_ADDOPTS=--cov-append
tox
- - Other
- ::
PYTEST_ADDOPTS=--cov-append tox

@ -0,0 +1,57 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals
import os
import sys
from os.path import abspath
from os.path import dirname
from os.path import exists
from os.path import join
if __name__ == "__main__":
base_path = dirname(dirname(abspath(__file__)))
print("Project path: {0}".format(base_path))
env_path = join(base_path, ".tox", "bootstrap")
if sys.platform == "win32":
bin_path = join(env_path, "Scripts")
else:
bin_path = join(env_path, "bin")
if not exists(env_path):
import subprocess
print("Making bootstrap env in: {0} ...".format(env_path))
try:
subprocess.check_call(["virtualenv", env_path])
except subprocess.CalledProcessError:
subprocess.check_call([sys.executable, "-m", "virtualenv", env_path])
print("Installing `jinja2` into bootstrap environment...")
subprocess.check_call([join(bin_path, "pip"), "install", "jinja2"])
activate = join(bin_path, "activate_this.py")
# noinspection PyCompatibility
exec(compile(open(activate, "rb").read(), activate, "exec"), dict(__file__=activate))
import jinja2
import subprocess
jinja = jinja2.Environment(
loader=jinja2.FileSystemLoader(join(base_path, "ci", "templates")),
trim_blocks=True,
lstrip_blocks=True,
keep_trailing_newline=True
)
tox_environments = [
line.strip()
# WARNING: 'tox' must be installed globally or in the project's virtualenv
for line in subprocess.check_output(['tox', '--listenvs'], universal_newlines=True).splitlines()
]
tox_environments = [line for line in tox_environments if line not in ['clean', 'report', 'docs', 'check']]
for name in os.listdir(join("ci", "templates")):
with open(join(base_path, name), "w") as fh:
fh.write(jinja.get_template(name).render(tox_environments=tox_environments))
print("Wrote {}".format(name))
print("DONE.")

@ -0,0 +1,36 @@
language: python
sudo: false
cache: pip
env:
global:
- LD_PRELOAD=/lib/x86_64-linux-gnu/libSegFault.so
- SEGFAULT_SIGNALS=all
matrix:
- TOXENV=check
- TOXENV=docs
matrix:
include:
{%- for env in tox_environments %}{{ '' }}
- python: '{{ '{0[0]}-5.4'.format(env.split('-')) if env.startswith('pypy') else '{0[2]}.{0[3]}'.format(env) }}'
env:
- TOXENV={{ env }},report
{%- endfor %}{{ '' }}
before_install:
- python --version
- uname -a
- lsb_release -a
install:
- pip install tox
- virtualenv --version
- easy_install --version
- pip --version
- tox --version
script:
- tox -v
after_failure:
- more .tox/log/* | cat
- more .tox/*/log/* | cat
notifications:
email:
on_success: never
on_failure: always

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

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

@ -0,0 +1,53 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import os
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.coverage',
'sphinx.ext.doctest',
'sphinx.ext.extlinks',
'sphinx.ext.ifconfig',
'sphinx.ext.napoleon',
'sphinx.ext.todo',
'sphinx.ext.viewcode',
]
if os.getenv('SPELLCHECK'):
extensions += 'sphinxcontrib.spelling',
spelling_show_suggestions = True
spelling_lang = 'en_US'
source_suffix = '.rst'
master_doc = 'index'
project = 'qutescript'
year = '2017'
author = 'Harshad Sharma'
copyright = '{0}, {1}'.format(year, author)
version = release = '0.1.0'
pygments_style = 'trac'
templates_path = ['.']
extlinks = {
'issue': ('https://github.com/hiway/python-qutescript/issues/%s', '#'),
'pr': ('https://github.com/hiway/python-qutescript/pull/%s', 'PR #'),
}
# on_rtd is whether we are on readthedocs.org
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
if not on_rtd: # only set the theme if we're building docs locally
html_theme = 'sphinx_rtd_theme'
html_use_smartypants = True
html_last_updated_fmt = '%b %d, %Y'
html_split_index = False
html_sidebars = {
'**': ['searchbox.html', 'globaltoc.html', 'sourcelink.html'],
}
html_short_title = '%s-%s' % (project, version)
napoleon_use_ivar = True
napoleon_use_rtype = False
napoleon_use_param = False

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

@ -0,0 +1,22 @@
========
Contents
========
.. toctree::
:maxdepth: 2
readme
installation
usage
reference/index
contributing
authors
changelog
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

@ -0,0 +1,7 @@
============
Installation
============
At the command line::
pip install qutescript

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

@ -0,0 +1,7 @@
Reference
=========
.. toctree::
:glob:
qutescript*

@ -0,0 +1,9 @@
qutescript
==========
.. testsetup::
from qutescript import *
.. automodule:: qutescript
:members:

@ -0,0 +1,3 @@
sphinx>=1.3
sphinx-rtd-theme
-e .

@ -0,0 +1,11 @@
builtin
builtins
classmethod
staticmethod
classmethods
staticmethods
args
kwargs
callstack
Changelog
Indices

@ -0,0 +1,7 @@
=====
Usage
=====
To use qutescript in a project::
import qutescript

@ -0,0 +1,35 @@
[bdist_wheel]
universal = 1
[flake8]
max-line-length = 140
exclude = tests/*,*/migrations/*,*/south_migrations/*
[tool:pytest]
norecursedirs =
.git
.tox
.env
dist
build
south_migrations
migrations
python_files =
test_*.py
*_test.py
tests.py
addopts =
-rxEfsw
--strict
--doctest-modules
--doctest-glob=\*.rst
--tb=short
[isort]
force_single_line = True
line_length = 120
known_first_party = qutescript
default_section = THIRDPARTY
forced_separate = test_qutescript
not_skip = __init__.py
skip = migrations, south_migrations

@ -0,0 +1,81 @@
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
from __future__ import absolute_import
from __future__ import print_function
import io
import re
from glob import glob
from os.path import basename
from os.path import dirname
from os.path import join
from os.path import splitext
from setuptools import find_packages
from setuptools import setup
def read(*names, **kwargs):
return io.open(
join(dirname(__file__), *names),
encoding=kwargs.get('encoding', 'utf8')
).read()
setup(
name='qutescript',
version='0.1.0',
license='BSD',
description='Painless userscripts for qutebrowser.',
long_description='%s\n%s' % (
re.compile('^.. start-badges.*^.. end-badges', re.M | re.S).sub('', read('README.rst')),
re.sub(':[a-z]+:`~?(.*?)`', r'``\1``', read('CHANGELOG.rst'))
),
author='Harshad Sharma',
author_email='harshad@sharma.io',
url='https://github.com/hiway/python-qutescript',
packages=find_packages('src'),
package_dir={'': 'src'},
py_modules=[splitext(basename(path))[0] for path in glob('src/*.py')],
include_package_data=True,
zip_safe=False,
classifiers=[
# complete classifier list: http://pypi.python.org/pypi?%3Aaction=list_classifiers
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: Unix',
'Operating System :: POSIX',
'Operating System :: Microsoft :: Windows',
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
# uncomment if you test on these interpreters:
# 'Programming Language :: Python :: Implementation :: IronPython',
# 'Programming Language :: Python :: Implementation :: Jython',
# 'Programming Language :: Python :: Implementation :: Stackless',
'Topic :: Utilities',
],
keywords=[
# eg: 'keyword1', 'keyword2', 'keyword3',
],
install_requires=[
# eg: 'aspectlib==1.1.1', 'six>=1.7',
],
extras_require={
# eg:
# 'rst': ['docutils>=0.11'],
# ':python_version=="2.6"': ['argparse'],
},
entry_points={
'console_scripts': [
'qutescript = qutescript.cli:main',
]
},
)

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

@ -0,0 +1,14 @@
"""
Entrypoint module, in case you use `python -mqutescript`.
Why does this file exist, and why __main__? For more info, read:
- https://www.python.org/dev/peps/pep-0338/
- https://docs.python.org/2/using/cmdline.html#cmdoption-m
- https://docs.python.org/3/using/cmdline.html#cmdoption-m
"""
from qutescript.cli import main
if __name__ == "__main__":
main()

@ -0,0 +1,27 @@
"""
Module that contains the command line app.
Why does this file exist, and why not put this in __main__?
You might be tempted to import things from __main__ later, but that will cause
problems: the code will get executed twice:
- When you run `python -mqutescript` python will execute
``__main__.py`` as a script. That means there won't be any
``qutescript.__main__`` in ``sys.modules``.
- When you import __main__ it will get executed again (as a module) because
there's no ``qutescript.__main__`` in ``sys.modules``.
Also see (1) from http://click.pocoo.org/5/setuptools/#setuptools-integration
"""
import argparse
parser = argparse.ArgumentParser(description='Command description.')
parser.add_argument('names', metavar='NAME', nargs=argparse.ZERO_OR_MORE,
help="A name of something.")
def main(args=None):
args = parser.parse_args(args=args)
print(args.names)

@ -0,0 +1,6 @@
from qutescript.cli import main
def test_main():
main([])

@ -0,0 +1,104 @@
; a generative tox configuration, see: https://testrun.org/tox/latest/config.html#generative-envlist
[tox]
envlist =
clean,
check,
{py27,py33,py34,py35,py36,pypy},
report,
docs
[testenv]
basepython =
pypy: {env:TOXPYTHON:pypy}
{py27,docs,spell}: {env:TOXPYTHON:python2.7}
py33: {env:TOXPYTHON:python3.3}
py34: {env:TOXPYTHON:python3.4}
py35: {env:TOXPYTHON:python3.5}
py36: {env:TOXPYTHON:python3.6}
{bootstrap,clean,check,report,coveralls,codecov}: {env:TOXPYTHON:python3}
setenv =
PYTHONPATH={toxinidir}/tests
PYTHONUNBUFFERED=yes
passenv =
*
usedevelop = false
deps =
pytest
pytest-travis-fold
pytest-cov
commands =
{posargs:py.test --cov --cov-report=term-missing -vv tests}
[testenv:bootstrap]
deps =
jinja2
matrix
skip_install = true
commands =
python ci/bootstrap.py
passenv =
*
[testenv:spell]
setenv =
SPELLCHECK=1
commands =
sphinx-build -b spelling docs dist/docs
skip_install = true
deps =
-r{toxinidir}/docs/requirements.txt
sphinxcontrib-spelling
pyenchant
[testenv:docs]
deps =
-r{toxinidir}/docs/requirements.txt
commands =
sphinx-build {posargs:-E} -b html docs dist/docs
sphinx-build -b linkcheck docs dist/docs
[testenv:check]
deps =
docutils
check-manifest
flake8
readme-renderer
pygments
isort
skip_install = true
commands =
python setup.py check --strict --metadata --restructuredtext
check-manifest {toxinidir}
flake8 src tests setup.py
isort --verbose --check-only --diff --recursive src tests setup.py
[testenv:coveralls]
deps =
coveralls
skip_install = true
commands =
coveralls []
[testenv:codecov]
deps =
codecov
skip_install = true
commands =
coverage xml --ignore-errors
codecov []
[testenv:report]
deps = coverage
skip_install = true
commands =
coverage combine --append
coverage report
coverage html
[testenv:clean]
commands = coverage erase
skip_install = true
deps = coverage
Loading…
Cancel
Save