From a7955a560ea8f8c10694ecdd57a6b189086f1e9c Mon Sep 17 00:00:00 2001 From: Jason Carver Date: Wed, 24 Jan 2018 16:00:28 -0800 Subject: [PATCH] init --- .bumpversion.cfg | 23 ++++ .gitignore | 107 ++++++++++++++++ .travis.yml | 31 +++++ LICENSE | 21 ++++ Makefile | 54 ++++++++ README.md | 84 +++++++++++++ docs/conf.py | 274 +++++++++++++++++++++++++++++++++++++++++ docs/releases.rst | 7 ++ fill_template_vars.sh | 35 ++++++ pytest.ini | 7 ++ setup.py | 64 ++++++++++ tests/core/conftest.py | 0 tox.ini | 35 ++++++ 13 files changed, 742 insertions(+) create mode 100644 .bumpversion.cfg create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100644 LICENSE create mode 100644 Makefile create mode 100644 README.md create mode 100644 docs/conf.py create mode 100644 docs/releases.rst create mode 100755 fill_template_vars.sh create mode 100644 pytest.ini create mode 100644 setup.py create mode 100644 tests/core/conftest.py create mode 100644 tox.ini diff --git a/.bumpversion.cfg b/.bumpversion.cfg new file mode 100644 index 0000000..eefe4ad --- /dev/null +++ b/.bumpversion.cfg @@ -0,0 +1,23 @@ +[bumpversion] +current_version = 0.1.0-alpha.0 +commit = True +tag = True +parse = (?P\d+)\.(?P\d+)\.(?P\d+)(-(?P[^.]*)\.(?P\d+))? +serialize = + {major}.{minor}.{patch}-{stage}.{devnum} + {major}.{minor}.{patch} + +[bumpversion:part:stage] +optional_value = stable +first_value = stable +values = + alpha + beta + stable + +[bumpversion:part:devnum] + +[bumpversion:file:setup.py] +search = version='{current_version}', +replace = version='{new_version}', + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c380203 --- /dev/null +++ b/.gitignore @@ -0,0 +1,107 @@ +*.py[cod] + +# C extensions +*.so + +# Packages +*.egg +*.egg-info +dist +build +eggs +.eggs +parts +bin +var +sdist +develop-eggs +.installed.cfg +lib +lib64 +venv* + +# Installer logs +pip-log.txt + +# Unit test / coverage reports +.coverage +.tox +nosetests.xml + +# Translations +*.mo + +# Mr Developer +.mr.developer.cfg +.project +.pydevproject + +# Complexity +output/*.html +output/*/index.html + +# Sphinx +docs/_build +docs/modules.rst +docs/web3.* + +# Blockchain +chains + +# Hypothese Property base testing +.hypothesis + +# tox/pytest cache +.cache + +# Test output logs +logs +### JetBrains template +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff: +.idea/workspace.xml +.idea/tasks.xml +.idea/dictionaries +.idea/vcs.xml +.idea/jsLibraryMappings.xml + +# Sensitive or high-churn files: +.idea/dataSources.ids +.idea/dataSources.xml +.idea/dataSources.local.xml +.idea/sqlDataSources.xml +.idea/dynamic.xml +.idea/uiDesigner.xml + +# Gradle: +.idea/gradle.xml +.idea/libraries + +# Mongo Explorer plugin: +.idea/mongoSettings.xml + +# VIM temp files +*.swp + +## File-based project format: +*.iws + +## Plugin-specific files: + +# IntelliJ +/out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..72be81d --- /dev/null +++ b/.travis.yml @@ -0,0 +1,31 @@ +sudo: false +language: python +dist: trusty +matrix: + include: + # + # Python 3.5 testing + # + # lint + - python: "3.5" + env: TOX_POSARGS="-e lint" + # core + - python: "3.5" + env: TOX_POSARGS="-e py35-core" + # + # Python 3.6 testing + # + # core + - python: "3.6" + env: TOX_POSARGS="-e py36-core" +cache: + - pip: true +install: + - travis_retry pip install pip setuptools --upgrade + - travis_retry pip install tox +before_script: + - python --version + - pip --version + - pip freeze +script: + - tox $TOX_POSARGS diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..1b7a2b5 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2018 Jason Carver + +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/Makefile b/Makefile new file mode 100644 index 0000000..b842465 --- /dev/null +++ b/Makefile @@ -0,0 +1,54 @@ +.PHONY: clean-pyc clean-build docs + +help: + @echo "clean-build - remove build artifacts" + @echo "clean-pyc - remove Python file artifacts" + @echo "lint - check style with flake8" + @echo "test - run tests quickly with the default Python" + @echo "testall - run tests on every Python version with tox" + @echo "release - package and upload a release" + @echo "dist - package" + +clean: clean-build clean-pyc + +clean-build: + rm -fr build/ + rm -fr dist/ + rm -fr *.egg-info + +clean-pyc: + find . -name '*.pyc' -exec rm -f {} + + find . -name '*.pyo' -exec rm -f {} + + find . -name '*~' -exec rm -f {} + + +lint: + tox -elint + +test: + py.test tests + +test-all: + tox + +build-docs: + sphinx-apidoc -o docs/ . setup.py "*conftest*" + $(MAKE) -C docs clean + $(MAKE) -C docs html + +docs: build-docs + open docs/_build/html/index.html + +linux-docs: build-docs + xdg-open docs/_build/html/index.html + +release: clean + CURRENT_SIGN_SETTING=$(git config commit.gpgSign) + git config commit.gpgSign true + bumpversion $(bump) + git push && git push --tags + python setup.py sdist bdist_wheel upload + git config commit.gpgSign "$(CURRENT_SIGN_SETTING)" + +dist: clean + python setup.py sdist bdist_wheel + ls -l dist diff --git a/README.md b/README.md new file mode 100644 index 0000000..e29c4d9 --- /dev/null +++ b/README.md @@ -0,0 +1,84 @@ +# + +[![Join the chat at https://gitter.im/ethereum/](https://badges.gitter.im/ethereum/.svg)](https://gitter.im/ethereum/?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + +[![Build Status](https://travis-ci.org/ethereum/.png)](https://travis-ci.org/ethereum/) + + + + +* Python 3.5+ support + +Read more in the [documentation on ReadTheDocs](http://.readthedocs.io/). [View the change log on Github](docs/releases.rst). + +## Quickstart + +```sh +pip install +``` + +## Developer setup + +If you would like to hack on , set up your dev environment with: + +```sh + +git clone git@github.com:ethereum/.git +cd +virtualenv -p python3 venv +. venv/bin/activate +pip install -e .[dev] +``` + +### Testing Setup + +During development, you might like to have tests run on every file save. + +Show flake8 errors on file change: + +```sh +# Test flake8 +when-changed -v -s -r -1 / tests/ -c "clear; flake8 tests && echo 'flake8 success' || echo 'error'" +``` + +Run multi-process tests in one command, but without color: + +```sh +# in the project root: +pytest --numprocesses=4 --looponfail --maxfail=1 +# the same thing, succinctly: +pytest -n 4 -f --maxfail=1 +``` + +Run in one thread, with color and desktop notifications: + +```sh +cd venv +ptw --onfail "notify-send -t 5000 'Test failure ⚠⚠⚠⚠⚠' 'python 3 test on failed'" ../tests ../ +``` + +### Release setup + +For Debian-like systems: +``` +apt install pandoc +``` + +To release a new version: + +```sh +make release bump=$$VERSION_PART_TO_BUMP$$ +``` + +#### How to bumpversion + +The version format for this repo is `{major}.{minor}.{patch}` for stable, and +`{major}.{minor}.{patch}-{stage}.{devnum}` for unstable (`stage` can be alpha or beta). + +To issue the next version in line, specify which part to bump, +like `make release bump=minor` or `make release bump=devnum`. + +If you are in a beta version, `make release bump=stage` will switch to a stable. + +To issue an unstable version when the current version is stable, specify the +new version explicitly, like `make release bump="--new-version 4.0.0-alpha.1 devnum"` diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000..77bcb7e --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,274 @@ +# -*- coding: utf-8 -*- +# +# documentation build configuration file, created by +# sphinx-quickstart on Thu Oct 16 20:43:24 2014. +# +# 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. +#sys.path.insert(0, os.path.abspath('.')) + +import os + +DIR = os.path.dirname('__file__') +with open (os.path.join(DIR, '../setup.py'), 'r') as f: + for line in f: + if 'version=' in line: + setup_version = line.split('\'')[1] + break + +# -- 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.intersphinx'] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix of source filenames. +source_suffix = '.rst' + +# The encoding of source files. +#source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = '' +copyright = '2018, Jason Carver, Piper Merriam' + +__version__ = setup_version +# 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 = '.'.join(__version__.split('.')[:2]) +# The full version, including alpha/beta/rc tags. +release = __version__ + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +#language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = [ + '_build', + '.rst', + 'modules.rst', +] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +#modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +#keep_warnings = 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 = 'sphinx_rtd_theme' + +# 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 themes here, relative to this directory. + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +#html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +#html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# 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'] + +# Add any extra paths that contain custom files (such as robots.txt or +# .htaccess) here, relative to this directory. These files are copied +# directly to the root of the documentation. +#html_extra_path = [] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +#html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +#html_domain_indices = True + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +#html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +#html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +#html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = None + +# Output file base name for HTML help builder. +htmlhelp_basename = 'doc' + + +# -- 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': '', +} + +# 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 = [ + ('index', '.tex', ' Documentation', + 'Jason Carver', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# If true, show page references after internal links. +#latex_show_pagerefs = False + +# If true, show URL addresses after external links. +#latex_show_urls = False + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_domain_indices = True + + +# -- Options for manual page output --------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ('index', '', ' Documentation', + ['Jason Carver'], 1) +] + +# If true, show URL addresses after external links. +#man_show_urls = False + + +# -- 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 = [ + ('index', '', ' Documentation', + 'Jason Carver', '', '', + 'Miscellaneous'), +] + +# Documents to append as an appendix to all manuals. +#texinfo_appendices = [] + +# If false, no module index is generated. +#texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +#texinfo_show_urls = 'footnote' + +# If true, do not generate a @detailmenu in the "Top" node's menu. +#texinfo_no_detailmenu = False + +# -- Intersphinx configuration ------------------------------------------------ + +intersphinx_mapping = { + 'python': ('https://docs.python.org/3.5', None), +} diff --git a/docs/releases.rst b/docs/releases.rst new file mode 100644 index 0000000..ec4804d --- /dev/null +++ b/docs/releases.rst @@ -0,0 +1,7 @@ +Release Notes +============= + +v0.1.0-alpha.1 +------------- + +- Launched repository, claimed names for pip, RTD, github, etc diff --git a/fill_template_vars.sh b/fill_template_vars.sh new file mode 100755 index 0000000..ecbdcb0 --- /dev/null +++ b/fill_template_vars.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +set -o errexit +set -o nounset +set -o pipefail + +# List of all non-executable files +TEMPLATE_FILES=$(find . ! -perm -u=x -type f) + +echo "What is your python module name?" +read MODULE_NAME + +echo "What is your pypi package name? (default: $MODULE_NAME)" +read PYPI_INPUT +PYPI_NAME=${PYPI_INPUT:-$MODULE_NAME} + +echo "What is your github project name? (default: $PYPI_NAME)" +read REPO_INPUT +REPO_NAME=${REPO_INPUT:-$PYPI_NAME} + +echo "What is your readthedocs.org project name? (default: $PYPI_NAME)" +read RTD_INPUT +RTD_NAME=${RTD_INPUT:-$PYPI_NAME} + +echo "What is your project name (ex: at the top of the README)? (default: $REPO_NAME)" +read PROJECT_INPUT +PROJECT_NAME=${PROJECT_INPUT:-$REPO_NAME} + +echo "What is a one-liner describing the project?" +read SHORT_DESCRIPTION + +sed -i "s//$MODULE_NAME/g" $TEMPLATE_FILES +sed -i "s//$PYPI_NAME/g" $TEMPLATE_FILES +sed -i "s//$REPO_NAME/g" $TEMPLATE_FILES +sed -i "s//$SHORT_DESCRIPTION/g" $TEMPLATE_FILES diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..d53de3a --- /dev/null +++ b/pytest.ini @@ -0,0 +1,7 @@ +[pytest] +addopts= -v --showlocals --durations 10 +python_paths= . +xfail_strict=true + +[pytest-watch] +runner= py.test --failed-first --maxfail=1 --no-success-flaky-report diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..4882a64 --- /dev/null +++ b/setup.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +from setuptools import ( + setup, + find_packages, +) + +extras_require={ + 'test': [ + "pytest==3.3.2", + "tox>=2.9.1,<3", + ], + 'lint': [ + "flake8==3.4.1", + "isort>=4.2.15,<5", + ], + 'document': [ + "Sphinx>=1.6.5,<2", + "sphinx_rtd_theme>=0.1.9", + ], + 'dev': [ + "bumpversion>=0.5.3,<1", + "pytest-xdist", + "wheel", + ], +} + +extras_require['dev'] = ( + extras_require['dev'] + + extras_require['test'] + + extras_require['lint'] + + extras_require['document'] +) + +setup( + name='', + # *IMPORTANT*: Don't manually change the version here. Use `make bump`, as described in readme + version='0.1.0-alpha.1', + description=""": """, + long_description_markdown_filename='README.md', + author='Jason Carver', + author_email='ethcalibur+pip@gmail.com', + url='https://github.com/ethereum/', + include_package_data=True, + install_requires=[ + "eth-utils>=0.7.4,<1.0.0", + ], + setup_requires=['setuptools-markdown'], + extras_require=extras_require, + py_modules=[''], + license="MIT", + zip_safe=False, + keywords='ethereum', + packages=find_packages(exclude=["tests", "tests.*"]), + classifiers=[ + 'Development Status :: 3 - Alpha', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: MIT License', + 'Natural Language :: English', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + ], +) diff --git a/tests/core/conftest.py b/tests/core/conftest.py new file mode 100644 index 0000000..e69de29 diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..0277275 --- /dev/null +++ b/tox.ini @@ -0,0 +1,35 @@ +[tox] +envlist= + py{35,36}-core + lint + +[isort] +combine_as_imports=True +force_sort_within_sections=True +include_trailing_comma=True +known_standard_library=pytest +known_first_party= +line_length=21 +multi_line_output=3 +use_parentheses=True + +[flake8] +max-line-length= 100 +exclude= venv*,.tox,docs,build +ignore= + +[testenv] +usedevelop=True +commands= + core: py.test {posargs:tests/core} +basepython = + py35: python3.5 + py36: python3.6 +extras=test + +[testenv:lint] +basepython=python +extras=lint +commands= + flake8 {toxinidir}/ {toxinidir}/tests + isort --recursive --check-only --diff {toxinidir}/ {toxinidir}/tests