Commit 2ab7f8c4 authored by dboe's avatar dboe
Browse files

Update template

parent 6ca109c4
...@@ -14,6 +14,7 @@ cache: ...@@ -14,6 +14,7 @@ cache:
paths: paths:
- .cache/pip - .cache/pip
- venv/ - venv/
- .cache/apt
stages: stages:
- build - build
...@@ -28,6 +29,10 @@ before_script: ...@@ -28,6 +29,10 @@ before_script:
dist: dist:
stage: build stage: build
script: script:
- mkdir -p .cache/apt
- apt-get update -yqq
- apt-get install -y gfortran libopenblas-dev liblapack-dev
- apt-get -o dir::cache::archives=".cache/apt" install -y -qq gfortran liblapack-dev libgmp-dev
- python setup.py bdist_wheel - python setup.py bdist_wheel
# an alternative approach is to install and run: # an alternative approach is to install and run:
- pip install dist/* - pip install dist/*
......
default_language_version:
python: python3
repos: repos:
- repo: https://github.com/ambv/black - repo: https://github.com/ambv/black
rev: stable rev: 21.6b0
hooks: hooks:
- id: black - id: black
language_version: python3.6
- repo: https://gitlab.com/pycqa/flake8 - repo: https://gitlab.com/pycqa/flake8
rev: 3.8.3 rev: 3.9.2
hooks: hooks:
- id: flake8 - id: flake8
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.1.0 rev: v4.0.1
hooks: hooks:
- id: check-json - id: check-json
- id: pretty-format-json - id: pretty-format-json
...@@ -21,6 +22,6 @@ repos: ...@@ -21,6 +22,6 @@ repos:
- id: detect-private-key - id: detect-private-key
- id: end-of-file-fixer - id: end-of-file-fixer
- repo: https://github.com/asottile/blacken-docs - repo: https://github.com/asottile/blacken-docs
rev: v1.7.0 rev: v1.10.0
hooks: hooks:
- id: blacken-docs - id: blacken-docs
...@@ -19,7 +19,6 @@ sphinx: ...@@ -19,7 +19,6 @@ sphinx:
python: python:
version: 3.7 version: 3.7
install: install:
- requirements: docs/requirements.txt
- method: pip - method: pip
path: . path: .
extra_requirements: extra_requirements:
......
MIT License MIT License
Copyright (c) 2020, Daniel Böckenhoff Copyright (c) 2021, Daniel Böckenhoff
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
...@@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ...@@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
...@@ -13,6 +13,7 @@ part ?= patch ...@@ -13,6 +13,7 @@ part ?= patch
test: FORCE test: FORCE
flake8 rna tests flake8 rna tests
pylint rna tests
py.test py.test
coverage: coverage:
...@@ -47,7 +48,7 @@ untag: ...@@ -47,7 +48,7 @@ untag:
requirements: setup.cfg requirements: setup.cfg
# We have all the information in the setup.cfg file. For some reasons (e.g. bug in setuptools or limitations to use setup.cfg in readthedocs) we still need a requirements file # We have all the information in the setup.cfg file. For some reasons (e.g. bug in setuptools or limitations to use setup.cfg in readthedocs) we still need a requirements file
python -c "import configparser; import os; config = configparser.ConfigParser(); config.read('setup.cfg'); deps = config['metadata']['install_requires'].split('\n'); deps = [x for x in deps if x]; head = '# Autogenerated by Makefile from setup.cfg install_requies section. Remove this line if you want to fix this file.'; path = 'requirements.txt'; f = open(path, 'r') if os.path.exists(path) else None; line = f.readline() if f else ''; quit('User defined requirements already existing.') if f and not line.startswith(head[:20]) else None; f = open('requirements.txt', 'w'); f.write('\n'.join([head] + deps))" python -c "import configparser; import os; config = configparser.ConfigParser(); config.read('setup.cfg'); deps = config['options']['install_requires'].split('\n'); deps = [x for x in deps if x]; head = '# Autogenerated by Makefile from setup.cfg install_requies section. Remove this line if you want to fix this file.'; path = 'requirements.txt'; f = open(path, 'r') if os.path.exists(path) else None; line = f.readline() if f else ''; quit('User defined requirements already existing.') if f and not line.startswith(head[:20]) else None; f = open('requirements.txt', 'w'); f.write('\n'.join([head] + deps))"
doc: Makefile $(SOURCES) $(DOCUMENTATION) docs/conf.py docs/apidoc-template/* doc: Makefile $(SOURCES) $(DOCUMENTATION) docs/conf.py docs/apidoc-template/*
# link apidoc to source and build html documentation with sphinx # link apidoc to source and build html documentation with sphinx
......
...@@ -8,4 +8,3 @@ API Documentation ...@@ -8,4 +8,3 @@ API Documentation
{% for docname in docnames %} {% for docname in docnames %}
{{ docname }} {{ docname }}
{%- endfor %} {%- endfor %}
...@@ -16,3 +16,4 @@ ...@@ -16,3 +16,4 @@
"remote_username": "dboe", "remote_username": "dboe",
"summary": "Basic and essential code building blocks of all pythons" "summary": "Basic and essential code building blocks of all pythons"
} }
...@@ -23,6 +23,7 @@ you through the process. ...@@ -23,6 +23,7 @@ you through the process.
.. _Python installation guide: http://docs.python-guide.org/en/latest/starting/installation/ .. _Python installation guide: http://docs.python-guide.org/en/latest/starting/installation/
From sources From sources
------------ ------------
......
...@@ -4,4 +4,4 @@ Usage ...@@ -4,4 +4,4 @@ Usage
To use rna in a project:: To use rna in a project::
>>> import rna >>> import rna
\ No newline at end of file
...@@ -8,49 +8,64 @@ import rna ...@@ -8,49 +8,64 @@ import rna
class SomeAction(argparse.Action): class SomeAction(argparse.Action):
"""Some actions."""
def __init__(self, option_strings, dest, nargs=None, **kwargs): def __init__(self, option_strings, dest, nargs=None, **kwargs):
if nargs is not None: if nargs is not None:
raise ValueError("nargs not allowed") raise ValueError("nargs not allowed")
super().__init__(option_strings, dest, **kwargs) super().__init__(option_strings, dest, **kwargs)
def __call__(self, parser, namespace, values, option_string=None): def __call__(self, parser, namespace, values, option_string=None):
print("Example action invoked by manage in namespace: %r with values %r" print(
" and option string %r" % (namespace, values, option_string)) "Example action invoked by manage in namespace: %r with values %r"
" and option string %r" % (namespace, values, option_string)
)
setattr(namespace, self.dest, values) setattr(namespace, self.dest, values)
def showcase_dummy(self):
"""
You can define a method to expose functionality of the class
"""
print(self)
def manage(args): def manage(args_):
"""Example function."""
print("Managing!") print("Managing!")
print(args.x * args.y) print(args_.x * args_.y)
def parse_args(args): def parse_args(args_):
"""Parse args."""
# create the top-level parser # create the top-level parser
parser = argparse.ArgumentParser(prog='rna app') parser = argparse.ArgumentParser(prog="rna app")
parser.add_argument('--version', action='version', parser.add_argument(
version='v' + rna.__version__, "--version",
help="Show program's version number and exit") action="version",
parser = argparse.ArgumentParser(prog='rna app') version="v" + rna.__version__,
help="Show program's version number and exit",
)
parser = argparse.ArgumentParser(prog="rna app")
# subparsers # subparsers
subparsers = parser.add_subparsers(help='sub-command help') subparsers = parser.add_subparsers(help="sub-command help")
# create the parser for the "test" command # create the parser for the "test" command
example_sub_parser = subparsers.add_parser('manage', help='manage something') example_sub_parser = subparsers.add_parser("manage", help="manage something")
example_sub_parser.add_argument('-x', type=int, default=1) example_sub_parser.add_argument("-x", type=int, default=1)
example_sub_parser.add_argument('-y', type=float, default=42.) example_sub_parser.add_argument("-y", type=float, default=42.0)
example_sub_parser.set_defaults(func=manage) example_sub_parser.set_defaults(func=manage)
# If no arguments were used, print base-level help with possible commands. # If no arguments were used, print base-level help with possible commands.
if len(args) == 0: if len(args_) == 0:
parser.print_help(file=sys.stderr) parser.print_help(file=sys.stderr)
sys.exit(1) sys.exit(1)
args = parser.parse_args(args) args_ = parser.parse_args(args_)
# let argparse do the job of calling the appropriate function after # let argparse do the job of calling the appropriate function after
# argument parsing is complete # argument parsing is complete
args.func(args) return args_.func(args_)
if __name__ == '__main__': if __name__ == "__main__":
args = parse_args(sys.argv[1:]) _ = parse_args(sys.argv[1:])
...@@ -8,9 +8,16 @@ message = release-v{new_version} ...@@ -8,9 +8,16 @@ message = release-v{new_version}
search = __version__ = '{current_version}' search = __version__ = '{current_version}'
replace = {new_version} replace = {new_version}
[bumpversion:file:setup.py]
search = version='{current_version}'
replace = {new_version}
[bumpversion:file:docs/cookiecutter_input.json]
search = 'package_version': '{current_version}'
replace = {new_version}
[metadata] [metadata]
name = rna name = rna
version = attr: rna.__version__
url = https://gitlab.mpcdf.mpg.de/dboe/rna url = https://gitlab.mpcdf.mpg.de/dboe/rna
author = Daniel Böckenhoff author = Daniel Böckenhoff
author_email = dboe@ipp.mpg.de author_email = dboe@ipp.mpg.de
...@@ -30,18 +37,18 @@ description = Basic and essential code building blocks of all pythons ...@@ -30,18 +37,18 @@ description = Basic and essential code building blocks of all pythons
long_description = file: README.rst, LICENSE.rst long_description = file: README.rst, LICENSE.rst
long_description_content_type = text/x-rst long_description_content_type = text/x-rst
keywords = plotting, matplotlib, pyqtgraph, backend, logging, path, argparse keywords = plotting, matplotlib, pyqtgraph, backend, logging, path, argparse
install_requires =
pathlib
project_urls = project_urls =
Documentation = https://rna.readthedocs.io Documentation = https://rna.readthedocs.io
Source = https://gitlab.mpcdf.mpg.de/dboe/rna Source = https://gitlab.mpcdf.mpg.de/dboe/rna
tests_require =
doctest
unittest
python_requires = >=3.0
[options] [options]
python_requires = >=3.0
packages = find: packages = find:
install_requires =
pathlib
tests_require =
doctest
unittest
[options.packages.find] [options.packages.find]
exclude = exclude =
...@@ -64,6 +71,7 @@ docs = ...@@ -64,6 +71,7 @@ docs =
sphinx_rtd_theme>=0.4.3 sphinx_rtd_theme>=0.4.3
test = test =
flake8 flake8
pylint
pytest pytest
pytest-cov pytest-cov
coverage coverage
...@@ -81,14 +89,16 @@ exclude_lines = ...@@ -81,14 +89,16 @@ exclude_lines =
pragma: no cover pragma: no cover
if False if False
[coverage:run]
omit =
rna/plotting/*.py
[flake8] [flake8]
max-line-length = 99 max-line-length = 99
doctests = True doctests = True
exclude = .git, .eggs, __pycache__, docs, dist, venv, .tox exclude = .git, .eggs, __pycache__, docs, dist, venv, .tox
ignore = E203 W503 W504 # wrong flake defaults: see https://github.com/psf/black/issues/315, https://github.com/psf/black/issues/43
per-file-ignores =
__init__.py: F401
[pylint.]
ignore = setup.py
[build_sphinx] [build_sphinx]
builder = html,man builder = html,man
...@@ -106,6 +116,7 @@ skip_missing_interpreters = true ...@@ -106,6 +116,7 @@ skip_missing_interpreters = true
envlist = envlist =
py{35,36,37,38} py{35,36,37,38}
recreate = true recreate = true
usedevelop = true
[gh-actions] [gh-actions]
python = python =
...@@ -117,14 +128,13 @@ python = ...@@ -117,14 +128,13 @@ python =
[testenv] [testenv]
description = run test suite under {basepython} description = run test suite under {basepython}
deps = deps =
{[metadata]install_requires} {[options]install_requires}
{[options.extras_require]test} {[options.extras_require]test}
extras = test extras = test
commands = commands =
pytest \ pytest \
--cov={[metadata]name} \ --cov={[metadata]name} \
--ignore=docs \ --ignore=docs \
--ignore=rna/plotting \
--junitxml=report/junit.xml --junitxml=report/junit.xml
[testenv:flake8] [testenv:flake8]
......
...@@ -3,9 +3,10 @@ ...@@ -3,9 +3,10 @@
"""Tests for `rna` package.""" """Tests for `rna` package."""
import unittest import unittest
import rna
class Test_rna(unittest.TestCase): class TestPackage(unittest.TestCase):
"""Tests for `rna` package.""" """Tests for `rna` package."""
def setUp(self): def setUp(self):
...@@ -16,5 +17,5 @@ class Test_rna(unittest.TestCase): ...@@ -16,5 +17,5 @@ class Test_rna(unittest.TestCase):
def test_version_type(self): def test_version_type(self):
"""Assure that version type is str.""" """Assure that version type is str."""
import rna
self.assertIsInstance(rna.__version__, str) self.assertIsInstance(rna.__version__, str)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment