From 1af9c06d5a44054d1814944cf89d60044962d677 Mon Sep 17 00:00:00 2001 From: Luke Murphy Date: Mon, 8 Jul 2019 11:40:40 +0200 Subject: [PATCH] Initialise the new module boilerplate --- .gitignore | 12 ++ .readthedocs.yml | 16 +++ CHANGELOG.rst | 0 CODE_OF_CONDUCT.rst | 111 ++++++++++++++++++ CONTRIBUTING.rst | 67 +++++++++++ LICENSE | 21 ++++ MANIFEST.in | 1 + README.rst | 41 +++++++ changelog/.git-dont-delete-me | 0 documentation/Makefile | 12 ++ documentation/source/_static/.git-dont-delete | 0 .../source/_templates/.git-dont-delete | 0 documentation/source/changelog.rst | 5 + documentation/source/code-of-conduct.rst | 1 + documentation/source/conf.py | 7 ++ documentation/source/contribute.rst | 1 + documentation/source/index.rst | 12 ++ documentation/source/install.rst | 11 ++ merkle-tree-stream/__init__.py | 12 ++ mypy.ini | 4 + pyproject.toml | 54 +++++++++ setup.cfg | 60 ++++++++++ setup.py | 3 + test/__init__.py | 0 test/test_version.py | 9 ++ tox.ini | 86 ++++++++++++++ 26 files changed, 546 insertions(+) create mode 100644 .gitignore create mode 100644 .readthedocs.yml create mode 100644 CHANGELOG.rst create mode 100644 CODE_OF_CONDUCT.rst create mode 100644 CONTRIBUTING.rst create mode 100644 LICENSE create mode 100644 MANIFEST.in create mode 100644 README.rst create mode 100644 changelog/.git-dont-delete-me create mode 100644 documentation/Makefile create mode 100644 documentation/source/_static/.git-dont-delete create mode 100644 documentation/source/_templates/.git-dont-delete create mode 100644 documentation/source/changelog.rst create mode 100644 documentation/source/code-of-conduct.rst create mode 100644 documentation/source/conf.py create mode 100644 documentation/source/contribute.rst create mode 100644 documentation/source/index.rst create mode 100644 documentation/source/install.rst create mode 100644 merkle-tree-stream/__init__.py create mode 100644 mypy.ini create mode 100644 pyproject.toml create mode 100644 setup.cfg create mode 100644 setup.py create mode 100644 test/__init__.py create mode 100644 test/test_version.py create mode 100644 tox.ini diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ca15349 --- /dev/null +++ b/.gitignore @@ -0,0 +1,12 @@ +*.egg-info/ +*.pyc +.coverage +.eggs/ +.mypy_cache/ +.tox/ +.venv/ +__pycache__ +build/ +dist/ +pip-wheel-metadata/ +documentation/build/ diff --git a/.readthedocs.yml b/.readthedocs.yml new file mode 100644 index 0000000..b796095 --- /dev/null +++ b/.readthedocs.yml @@ -0,0 +1,16 @@ +version: 2 + +build: + image: latest + +sphinx: + configuration: documentation/source/conf.py + fail_on_warning: true + +python: + version: 3.7 + install: + - method: pip + path: . + extra_requirements: + - docs diff --git a/CHANGELOG.rst b/CHANGELOG.rst new file mode 100644 index 0000000..e69de29 diff --git a/CODE_OF_CONDUCT.rst b/CODE_OF_CONDUCT.rst new file mode 100644 index 0000000..c211c44 --- /dev/null +++ b/CODE_OF_CONDUCT.rst @@ -0,0 +1,111 @@ +Introduction +------------ + +The DatPy community is committed to providing an inclusive, +safe, and collaborative environment for all participants, regardless of their +gender, gender expression, race, ethnicity, religion, sexual orientation, +sexual characteristics, physical appearance, disability, or age. We encourage +every participant to be themselves, and must respect the rights of others. The +code of conduct is a set of guidelines that establishes shared values and +ensures that behaviors that may harm participants are avoided. + +The values of the DatPy community are focused on developing +both our individual and collective potential, supporting and empowering the +most marginalized, mutual respect, and an anti-violence approach that favors +support and collaboration among participants and the resolution of conflicts. A +code of conduct helps us co-exist in a more positive way and provides +individuals who are victims of negative behaviors with confidence that they +will be supported by the organization and the DatPy +community, who respects and stands behind the code of conduct. + +The DatPy community works towards providing a welcoming +environment where participants are treated with dignity and respect and are +free to be themselves. We encourage all participants to approach the +Librehosters network with an open and positive attitude, engaging +constructively with others at all times. + +Respect for Diversity & Inclusion +--------------------------------- + +We avoid comments, actions or propaganda that encourage discrimination related +to gender, gender expression, race, ethnicity, religion, sexual orientation, +sexual characteristics, physical appearance, disability, or age. + +Respect Freedom of Expression +----------------------------- + +We support an individual's freedom of expression, and will not make fun of +accents or make unsolicited grammatical corrections. We will strive to better +understand each other by not assuming experiences or beliefs, clarifying +meanings, and making an effort to speak clearly, avoiding jargon and acronyms. + +Commitment to Non-Violence +-------------------------- + +We will not engage in any type of violence or aggression, including verbal +threats or complaints, intimidation, stalking or harassment, whether physically +or psychologically. + +Rejection of Sexual Harassment +------------------------------ + +We understand sexual harassment as unwanted physical contact or insinuation of +a sexual nature, as well as displaying images, drawings or visual +representations of any kind that objectify members of any gender or reinforce +oppression. The only exception is if this is part of a session, workshop and/or +educational experience where showing these images is educational in nature. + +Respect for Privacy +------------------- + +We safeguard the privacy of the participants. This includes refraining from +posting or publishing information about attendees (including names and +affiliation) unless given clear permission, and avoid any type of unauthorized +video, audio recording, or photography. + +Facilitate Participation & Collaboration +---------------------------------------- + +We work to create an environment that facilitates participation for all +participants. We will not engage in sustained disruption of discussions or +events, interrupt conversations in a way that negatively impacts collaboration, +or engage in toxic behaviours to attract negative attention to a participant. + +We Care about the Integrity and Health of the Community +------------------------------------------------------- + +We value the health of the community and will not engage in behaviour that can +negatively impact it. This includes contaminating food or drink with drugs, or +inciting or insisting on the consumption of alcohol, psychoactive substances, +etc. + +Support Positive Interactions Among Participants +------------------------------------------------ + +We are committed to engaging constructively with others at all times. We will +not tolerate bullying, including requesting or mobilizing others, either in +person or online, to bully others. + +Enforcement +----------- + +Overseeing the code of conduct +============================== + +The DatPy community, composed of volunteers, oversees the +code of conduct, including addressing all incident reports. Breaking the code +of conduct may result in immediate expulsion from the Librehosters network. + +How to Report an Incident +========================= + +If you witness an incident or are the victim of one: + +1. You can reach out directly via email at lukewm@riseup.net. + +Acknowledgements +---------------- + +This code of conduct is inspired by the [IFF CoC]. + +[IFF CoC]: https://www.internetfreedomfestival.org/wiki/index.php/Code_of_Conduct diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst new file mode 100644 index 0000000..24a7a36 --- /dev/null +++ b/CONTRIBUTING.rst @@ -0,0 +1,67 @@ +Get started +----------- + +Install `Tox`_ with: + +.. _tox: http://tox.readthedocs.io/ + +.. code-block:: bash + + $ pip install --user tox + +Run tests +--------- + +.. code-block:: bash + + tox -e test + +Lint source +----------- + +.. code-block:: bash + + tox -e lint + +Format source +------------- + +.. code-block:: bash + + tox -e format + +Type check source +----------------- + +.. code-block:: bash + + tox -e type + +Release Process +--------------- + +Add a change entry and re-generate the changelog: + +.. code-block:: bash + + $ towncrier + +Make a new release tag: + +.. code-block:: bash + + $ git tag x.x.x + $ git push --tags + +If you have a development install locally, you can verify: + +.. code-block:: bash + + $ merkle-tree-stream --version + +Then run the release process: + +.. code-block:: bash + + $ tox -e metadata-release + $ tox -e release diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..56788e2 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2019 Luke Murphy + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +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. diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..2bc8bb4 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +include LICENSE README.rst CHANGELOG.rst diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..a68f425 --- /dev/null +++ b/README.rst @@ -0,0 +1,41 @@ +.. _header: + +************************ +merkle-tree-stream +************************ + +.. image:: https://img.shields.io/badge/license-GPL-brightgreen.svg + :target: LICENSE + :alt: Repository license + +.. image:: https://badge.fury.io/py/merkle-tree-stream.svg + :target: https://badge.fury.io/py/merkle-tree-stream + :alt: PyPI package + +.. image:: https://readthedocs.org/projects/merkle-tree-stream/badge/?version=latest + :target: https://merkle-tree-stream.readthedocs.io/en/latest/ + :alt: Documentation status + +.. image:: https://img.shields.io/badge/support-maintainers-brightgreen.svg + :target: https://decentral1.se + :alt: Support badge + +.. _introduction: + +A stream that generates a merkle tree based on the incoming data +---------------------------------------------------------------- + +.. _documentation: + +Documentation +************* + +* https://merkle-tree-stream.readthedocs.io/ + +Code of Conduct +*************** + +By participating in the merkle-tree-stream community, you agree on the +following code of conduct. Please see `CODE_OF_CONDUCT`_ for the full text. + +.. _CODE_OF_CONDUCT: ./CODE_OF_CONDUCT diff --git a/changelog/.git-dont-delete-me b/changelog/.git-dont-delete-me new file mode 100644 index 0000000..e69de29 diff --git a/documentation/Makefile b/documentation/Makefile new file mode 100644 index 0000000..a57cab8 --- /dev/null +++ b/documentation/Makefile @@ -0,0 +1,12 @@ +SPHINXOPTS = +SPHINXBUILD = sphinx-build +SOURCEDIR = source +BUILDDIR = build + +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/documentation/source/_static/.git-dont-delete b/documentation/source/_static/.git-dont-delete new file mode 100644 index 0000000..e69de29 diff --git a/documentation/source/_templates/.git-dont-delete b/documentation/source/_templates/.git-dont-delete new file mode 100644 index 0000000..e69de29 diff --git a/documentation/source/changelog.rst b/documentation/source/changelog.rst new file mode 100644 index 0000000..bed14d3 --- /dev/null +++ b/documentation/source/changelog.rst @@ -0,0 +1,5 @@ +********* +Changelog +********* + +.. include:: ../../CHANGELOG.rst diff --git a/documentation/source/code-of-conduct.rst b/documentation/source/code-of-conduct.rst new file mode 100644 index 0000000..2d70708 --- /dev/null +++ b/documentation/source/code-of-conduct.rst @@ -0,0 +1 @@ +.. include:: ../../CODE_OF_CONDUCT.rst diff --git a/documentation/source/conf.py b/documentation/source/conf.py new file mode 100644 index 0000000..15626ba --- /dev/null +++ b/documentation/source/conf.py @@ -0,0 +1,7 @@ +author = 'decentral1se' +copyright = '2019, decentral1se' +html_static_path = ['_static'] +html_theme = 'alabaster' +master_doc = 'index' +project = 'merkle-tree-stream' +templates_path = ['_templates'] diff --git a/documentation/source/contribute.rst b/documentation/source/contribute.rst new file mode 100644 index 0000000..ac7b6bc --- /dev/null +++ b/documentation/source/contribute.rst @@ -0,0 +1 @@ +.. include:: ../../CONTRIBUTING.rst diff --git a/documentation/source/index.rst b/documentation/source/index.rst new file mode 100644 index 0000000..992d356 --- /dev/null +++ b/documentation/source/index.rst @@ -0,0 +1,12 @@ +.. include:: ../../README.rst + :end-before: _documentation + +Contents: +========= + +.. toctree:: + + install + contribute + changelog + code-of-conduct diff --git a/documentation/source/install.rst b/documentation/source/install.rst new file mode 100644 index 0000000..6e7e65a --- /dev/null +++ b/documentation/source/install.rst @@ -0,0 +1,11 @@ +************ +Installation +************ + +.. code-block:: bash + + $ pip install merkle-tree-stream + +.. note:: + + This tool only supports Python >= 3.6. diff --git a/merkle-tree-stream/__init__.py b/merkle-tree-stream/__init__.py new file mode 100644 index 0000000..4d429f8 --- /dev/null +++ b/merkle-tree-stream/__init__.py @@ -0,0 +1,12 @@ +"""merkle-tree-stream module.""" + +try: + import pkg_resources +except ImportError: + pass + + +try: + __version__ = pkg_resources.get_distribution('merkle-tree-stream').version +except Exception: + __version__ = 'unknown' diff --git a/mypy.ini b/mypy.ini new file mode 100644 index 0000000..3580d9a --- /dev/null +++ b/mypy.ini @@ -0,0 +1,4 @@ +[mypy] +python_version = 3.7 +platform = linux +ignore_missing_imports = True diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..343e51d --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,54 @@ +[build-system] +requires = [ + "setuptools>=40.9.0", + "setuptools-scm", + "wheel", +] +build-backend = "setuptools.build_meta" + +[tool.black] +line-length = 80 +target-version = ['py36', 'py37'] +skip-string-normalization = true +include = '\.pyi?$' + +[tool.towncrier] +directory = "changelog/" +filename = "CHANGELOG.rst" +package = "merkle-tree-stream" +package_dir = "merkle-tree-stream" + + [[tool.towncrier.type]] + directory = "removal" + name = "Removals" + showcontent = true + + [[tool.towncrier.type]] + directory = "deprecation" + name = "Deprecations" + showcontent = true + + [[tool.towncrier.type]] + directory = "feature" + name = "Features" + showcontent = true + + [[tool.towncrier.type]] + directory = "bugfix" + name = "Bug Fixes" + showcontent = true + + [[tool.towncrier.type]] + directory = "doc" + name = "Improved Documentation" + showcontent = true + + [[tool.towncrier.type]] + directory = "trivial" + name = "Trivial/Internal Changes" + showcontent = true + + [[tool.towncrier.type]] + directory = "announce" + name = "Project announcements" + showcontent = true diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..7a50782 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,60 @@ +[tool:pytest] +testpaths = test + +[flake8] +max-line-length = 80 + +[isort] +known_first_party = merkle-tree-stream +known_third_party = pytest +line_length = 80 +multi_line_output = 3 +skip = .venv, .tox +include_trailing_comma = True + +[metadata] +name = merkle-tree-stream +author = decentral1se +author_email = lukewm@riseup.net +maintainer = decentral1se +maintainer_email = lukewm@riseup.net +url = https://hack.decentral1.se/datpy/merkle-tree-stream +project_urls = + Source Code = https://hack.decentral1.se/datpy/merkle-tree-stream + Documentation = https://merkle-tree-stream.readthedocs.io/ + Maintainer Support = https://decentral1.se +description = A stream that generates a merkle tree based on the incoming data. +long_description = file: README.rst +license = GPLv3 +license_file = LICENSE +classifiers = + Programming Language :: Python :: 3 + Programming Language :: Python :: 3.6 + Programming Language :: Python :: 3.7 + +[options] +use_scm_version = True +python_requires = !=2.7.*, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.* +setup_requires = + setuptools_scm + setuptools_scm_git_archive +package_dir = + = . +packages = find: +zip_safe = False + +[options.packages.find] +where = . + +[build_sphinx] +all_files = 1 +build-dir = documentation/build +source-dir = documentation/source +warning-is-error = True + +[options.extras_require] +docs = + sphinx + sphinx-autodoc-typehints >= 1.6.0, < 2.0 +changelog = + towncrier <= 19.2.0, < 20.0 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..d5d43d7 --- /dev/null +++ b/setup.py @@ -0,0 +1,3 @@ +from setuptools import setup + +setup(use_scm_version=True) diff --git a/test/__init__.py b/test/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/test/test_version.py b/test/test_version.py new file mode 100644 index 0000000..085ba9a --- /dev/null +++ b/test/test_version.py @@ -0,0 +1,9 @@ +"""Version test module.""" + + +def test_version_fails_gracefully(mocker): + target = 'pkg_resources.get_distribution' + with mocker.patch(target, side_effect=Exception()): + from merkle-tree-stream.__init__ import __version__ + + assert __version__ == 'unknown' diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..216c91a --- /dev/null +++ b/tox.ini @@ -0,0 +1,86 @@ +[tox] +envlist = + {py36,py37}-test + lint + sort + format + type + docs + changelog + metadata-release +skip_missing_interpreters = True +isolated_build = True + +[testenv] +description = run the unit tests +deps = + pytest + pytest-cov + pytest-mock +commands = + pytest test/ --cov={toxinidir}/merkle-tree-stream/ --no-cov-on-fail {posargs} + +[testenv:lint] +description = lint the source +skipdist = True +deps = + flake8 +commands = + flake8 {posargs} merkle-tree-stream/ test/ + +[testenv:sort] +description = sort the source +skipdist = True +deps = + isort +commands = + isort {posargs:-rc -c} -sp setup.cfg merkle-tree-stream/ test/ + +[testenv:format] +description = format the source +skipdist = True +basepython = python3.6 +deps = + black +commands = + black {posargs:--check} merkle-tree-stream/ test/ + +[testenv:type] +description = type check the source +basepython = python3.7 +skipdist = True +deps = + mypy +commands = + mypy merkle-tree-stream/ test/ + +[testenv:docs] +description = build the documentation +skipdist = True +deps = + sphinx +commands = + python -m setup build_sphinx + +[testenv:changelog] +description = draft the changelog +skipdist = True +deps = + towncrier +commands = + towncrier --draft + +[testenv:metadata-release] +description = validate the package metadata +deps = + twine +commands = + twine check .tox/dist/* + +[testenv:release] +description = make a release +deps = + {[testenv:metadata-release]deps} +commands = + python -m setup sdist bdist_wheel + twine upload {toxworkdir}/dist/*