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

Update template

parent 6ca109c4
......@@ -14,6 +14,7 @@ cache:
paths:
- .cache/pip
- venv/
- .cache/apt
stages:
- build
......@@ -28,6 +29,10 @@ before_script:
dist:
stage: build
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
# an alternative approach is to install and run:
- pip install dist/*
......
default_language_version:
python: python3
repos:
- repo: https://github.com/ambv/black
rev: stable
rev: 21.6b0
hooks:
- id: black
language_version: python3.6
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.3
rev: 3.9.2
hooks:
- id: flake8
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.1.0
rev: v4.0.1
hooks:
- id: check-json
- id: pretty-format-json
......@@ -21,6 +22,6 @@ repos:
- id: detect-private-key
- id: end-of-file-fixer
- repo: https://github.com/asottile/blacken-docs
rev: v1.7.0
rev: v1.10.0
hooks:
- id: blacken-docs
......@@ -19,7 +19,6 @@ sphinx:
python:
version: 3.7
install:
- requirements: docs/requirements.txt
- method: pip
path: .
extra_requirements:
......
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
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
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
SOFTWARE.
......@@ -13,6 +13,7 @@ part ?= patch
test: FORCE
flake8 rna tests
pylint rna tests
py.test
coverage:
......@@ -47,7 +48,7 @@ untag:
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
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/*
# link apidoc to source and build html documentation with sphinx
......
......@@ -8,4 +8,3 @@ API Documentation
{% for docname in docnames %}
{{ docname }}
{%- endfor %}
......@@ -16,3 +16,4 @@
"remote_username": "dboe",
"summary": "Basic and essential code building blocks of all pythons"
}
......@@ -23,6 +23,7 @@ you through the process.
.. _Python installation guide: http://docs.python-guide.org/en/latest/starting/installation/
From sources
------------
......
......@@ -4,4 +4,4 @@ Usage
To use rna in a project::
>>> import rna
\ No newline at end of file
>>> import rna
......@@ -8,49 +8,64 @@ import rna
class SomeAction(argparse.Action):
"""Some actions."""
def __init__(self, option_strings, dest, nargs=None, **kwargs):
if nargs is not None:
raise ValueError("nargs not allowed")
super().__init__(option_strings, dest, **kwargs)
def __call__(self, parser, namespace, values, option_string=None):
print("Example action invoked by manage in namespace: %r with values %r"
" and option string %r" % (namespace, values, option_string))
print(
"Example action invoked by manage in namespace: %r with values %r"
" and option string %r" % (namespace, values, option_string)
)
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(args.x * args.y)
print(args_.x * args_.y)
def parse_args(args):
def parse_args(args_):
"""Parse args."""
# create the top-level parser
parser = argparse.ArgumentParser(prog='rna app')
parser.add_argument('--version', action='version',
version='v' + rna.__version__,
help="Show program's version number and exit")
parser = argparse.ArgumentParser(prog='rna app')
parser = argparse.ArgumentParser(prog="rna app")
parser.add_argument(
"--version",
action="version",
version="v" + rna.__version__,
help="Show program's version number and exit",
)
parser = argparse.ArgumentParser(prog="rna app")
# subparsers
subparsers = parser.add_subparsers(help='sub-command help')
subparsers = parser.add_subparsers(help="sub-command help")
# create the parser for the "test" command
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('-y', type=float, default=42.)
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("-y", type=float, default=42.0)
example_sub_parser.set_defaults(func=manage)
# 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)
sys.exit(1)
args = parser.parse_args(args)
args_ = parser.parse_args(args_)
# let argparse do the job of calling the appropriate function after
# argument parsing is complete
args.func(args)
return args_.func(args_)
if __name__ == '__main__':
args = parse_args(sys.argv[1:])
if __name__ == "__main__":
_ = parse_args(sys.argv[1:])
......@@ -8,9 +8,16 @@ message = release-v{new_version}
search = __version__ = '{current_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]
name = rna
version = attr: rna.__version__
url = https://gitlab.mpcdf.mpg.de/dboe/rna
author = Daniel Böckenhoff
author_email = dboe@ipp.mpg.de
......@@ -30,18 +37,18 @@ description = Basic and essential code building blocks of all pythons
long_description = file: README.rst, LICENSE.rst
long_description_content_type = text/x-rst
keywords = plotting, matplotlib, pyqtgraph, backend, logging, path, argparse
install_requires =
pathlib
project_urls =
Documentation = https://rna.readthedocs.io
Source = https://gitlab.mpcdf.mpg.de/dboe/rna
tests_require =
doctest
unittest
python_requires = >=3.0
[options]
python_requires = >=3.0
packages = find:
install_requires =
pathlib
tests_require =
doctest
unittest
[options.packages.find]
exclude =
......@@ -64,6 +71,7 @@ docs =
sphinx_rtd_theme>=0.4.3
test =
flake8
pylint
pytest
pytest-cov
coverage
......@@ -81,14 +89,16 @@ exclude_lines =
pragma: no cover
if False
[coverage:run]
omit =
rna/plotting/*.py
[flake8]
max-line-length = 99
doctests = True
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]
builder = html,man
......@@ -106,6 +116,7 @@ skip_missing_interpreters = true
envlist =
py{35,36,37,38}
recreate = true
usedevelop = true
[gh-actions]
python =
......@@ -117,14 +128,13 @@ python =
[testenv]
description = run test suite under {basepython}
deps =
{[metadata]install_requires}
{[options]install_requires}
{[options.extras_require]test}
extras = test
commands =
pytest \
--cov={[metadata]name} \
--ignore=docs \
--ignore=rna/plotting \
--junitxml=report/junit.xml
[testenv:flake8]
......
......@@ -3,9 +3,10 @@
"""Tests for `rna` package."""
import unittest
import rna
class Test_rna(unittest.TestCase):
class TestPackage(unittest.TestCase):
"""Tests for `rna` package."""
def setUp(self):
......@@ -16,5 +17,5 @@ class Test_rna(unittest.TestCase):
def test_version_type(self):
"""Assure that version type is str."""
import rna
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