diff --git a/.bumpversion.cfg b/.bumpversion.cfg new file mode 100644 index 0000000..1823462 --- /dev/null +++ b/.bumpversion.cfg @@ -0,0 +1,28 @@ +[bumpversion] +current_version = 0.0.1 +commit = True +tag = True + +[bumpversion:file:setup.py] +search = version="{current_version}" +replace = version="{new_version}" + +[bumpversion:file (badge):README.rst] +search = /v{current_version}.svg +replace = /v{new_version}.svg + +[bumpversion:file (link):README.rst] +search = /v{current_version}...main +replace = /v{new_version}...main + +[bumpversion:file:docs/conf.py] +search = version = release = "{current_version}" +replace = version = release = "{new_version}" + +[bumpversion:file:src/laser_cholera/__init__.py] +search = __version__ = "{current_version}" +replace = __version__ = "{new_version}" + +[bumpversion:file:.cookiecutterrc] +search = version: {current_version} +replace = version: {new_version} diff --git a/.cookiecutterrc b/.cookiecutterrc new file mode 100644 index 0000000..2af9e00 --- /dev/null +++ b/.cookiecutterrc @@ -0,0 +1,61 @@ +# 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 laser-cholera +# +# See: +# https://pypi.org/project/cookiepatcher +# +# Alternatively, you can run: +# +# cookiecutter --overwrite-if-exists --config-file=laser-cholera/.cookiecutterrc gh:ionelmc/cookiecutter-pylibrary + +default_context: + c_extension_optional: "yes" + c_extension_support: "yes" + codacy: "no" + codacy_projectid: "__codacy_projectid__" + codeclimate: "no" + codecov: "yes" + command_line_interface: "click" + command_line_interface_bin_name: "laser-cholera" + coveralls: "no" + distribution_name: "laser-cholera" + email: "christopher.lorton@gatesfoundation.org" + formatter_quote_style: "double" + full_name: "Christopher Lorton" + function_name: "compute" + github_actions: "yes" + github_actions_osx: "yes" + github_actions_windows: "yes" + license: "MIT license" + module_name: "core" + package_name: "laser_cholera" + pre_commit: "yes" + project_name: "LASER Cholera" + project_short_description: "LASIK - LASER based SImulation of Kolera" + pypi_badge: "yes" + pypi_disable_upload: "no" + release_date: "today" + repo_hosting: "github.com" + repo_hosting_domain: "github.com" + repo_main_branch: "main" + repo_name: "laser-cholera" + repo_username: "InstituteforDiseaseModeling" + scrutinizer: "no" + setup_py_uses_setuptools_scm: "no" + sphinx_docs: "yes" + sphinx_docs_hosting: "https://laser-cholera.readthedocs.io/" + sphinx_doctest: "yes" + sphinx_theme: "furo" + test_matrix_separate_coverage: "no" + tests_inside_package: "no" + version: "0.0.1" + version_manager: "bump2version" + website: "https://www.idmod.org" + year_from: "2024" + year_to: "2024" diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..ecac2f2 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,16 @@ +[paths] +source = + src + */site-packages + +[run] +branch = true +source = + laser_cholera + tests +parallel = true + +[report] +show_missing = true +precision = 2 +omit = *migrations* diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..586c736 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,20 @@ +# see https://editorconfig.org/ +root = true + +[*] +# Use Unix-style newlines for most files (except Windows files, see below). +end_of_line = lf +trim_trailing_whitespace = true +indent_style = space +insert_final_newline = true +indent_size = 4 +charset = utf-8 + +[*.{bat,cmd,ps1}] +end_of_line = crlf + +[*.{yml,yaml}] +indent_size = 2 + +[*.tsv] +indent_style = tab diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml new file mode 100644 index 0000000..768a0ad --- /dev/null +++ b/.github/workflows/github-actions.yml @@ -0,0 +1,277 @@ +name: build +on: [push, pull_request, workflow_dispatch] +jobs: + test: + name: ${{ matrix.name }} + runs-on: ${{ matrix.os }} + timeout-minutes: 30 + strategy: + fail-fast: false + matrix: + include: + - name: 'check' + python: '3.11' + toxpython: 'python3.11' + tox_env: 'check' + os: 'ubuntu-latest' + - name: 'docs' + python: '3.11' + toxpython: 'python3.11' + tox_env: 'docs' + os: 'ubuntu-latest' + - name: 'py38 (ubuntu/x86_64)' + python: '3.8' + toxpython: 'python3.8' + python_arch: 'x64' + tox_env: 'py38' + cibw_arch: 'x86_64' + cibw_build: false + os: 'ubuntu-latest' + - name: 'py38 (windows/AMD64)' + python: '3.8' + toxpython: 'python3.8' + python_arch: 'x64' + tox_env: 'py38' + cibw_arch: 'AMD64' + cibw_build: false + os: 'windows-latest' + - name: 'py38 (macos/x86_64)' + python: '3.8' + toxpython: 'python3.8' + python_arch: 'x64' + tox_env: 'py38' + cibw_arch: 'x86_64' + cibw_build: false + os: 'macos-latest' + - name: 'py39 (ubuntu/x86_64)' + python: '3.9' + toxpython: 'python3.9' + python_arch: 'x64' + tox_env: 'py39' + cibw_arch: 'x86_64' + cibw_build: false + os: 'ubuntu-latest' + - name: 'py39 (windows/AMD64)' + python: '3.9' + toxpython: 'python3.9' + python_arch: 'x64' + tox_env: 'py39' + cibw_arch: 'AMD64' + cibw_build: false + os: 'windows-latest' + - name: 'py39 (macos/x86_64)' + python: '3.9' + toxpython: 'python3.9' + python_arch: 'x64' + tox_env: 'py39' + cibw_arch: 'x86_64' + cibw_build: false + os: 'macos-latest' + - name: 'py310 (ubuntu/x86_64)' + python: '3.10' + toxpython: 'python3.10' + python_arch: 'x64' + tox_env: 'py310' + cibw_arch: 'x86_64' + cibw_build: false + os: 'ubuntu-latest' + - name: 'py310 (windows/AMD64)' + python: '3.10' + toxpython: 'python3.10' + python_arch: 'x64' + tox_env: 'py310' + cibw_arch: 'AMD64' + cibw_build: false + os: 'windows-latest' + - name: 'py310 (macos/x86_64)' + python: '3.10' + toxpython: 'python3.10' + python_arch: 'x64' + tox_env: 'py310' + cibw_arch: 'x86_64' + cibw_build: false + os: 'macos-latest' + - name: 'py311 (ubuntu/x86_64)' + python: '3.11' + toxpython: 'python3.11' + python_arch: 'x64' + tox_env: 'py311' + cibw_arch: 'x86_64' + cibw_build: false + os: 'ubuntu-latest' + - name: 'py311 (windows/AMD64)' + python: '3.11' + toxpython: 'python3.11' + python_arch: 'x64' + tox_env: 'py311' + cibw_arch: 'AMD64' + cibw_build: false + os: 'windows-latest' + - name: 'py311 (macos/x86_64)' + python: '3.11' + toxpython: 'python3.11' + python_arch: 'x64' + tox_env: 'py311' + cibw_arch: 'x86_64' + cibw_build: false + os: 'macos-latest' + - name: 'py312 (ubuntu/x86_64)' + python: '3.12' + toxpython: 'python3.12' + python_arch: 'x64' + tox_env: 'py312' + cibw_arch: 'x86_64' + cibw_build: false + os: 'ubuntu-latest' + - name: 'py312 (windows/AMD64)' + python: '3.12' + toxpython: 'python3.12' + python_arch: 'x64' + tox_env: 'py312' + cibw_arch: 'AMD64' + cibw_build: false + os: 'windows-latest' + - name: 'py312 (macos/x86_64)' + python: '3.12' + toxpython: 'python3.12' + python_arch: 'x64' + tox_env: 'py312' + cibw_arch: 'x86_64' + cibw_build: false + os: 'macos-latest' + - name: 'pypy38 (ubuntu/x86_64)' + python: 'pypy-3.8' + toxpython: 'pypy3.8' + python_arch: 'x64' + tox_env: 'pypy38' + cibw_arch: 'x86_64' + cibw_build: false + os: 'ubuntu-latest' + - name: 'pypy38 (windows/AMD64)' + python: 'pypy-3.8' + toxpython: 'pypy3.8' + python_arch: 'x64' + tox_env: 'pypy38' + cibw_arch: 'AMD64' + cibw_build: false + os: 'windows-latest' + - name: 'pypy38 (macos/x86_64)' + python: 'pypy-3.8' + toxpython: 'pypy3.8' + python_arch: 'x64' + tox_env: 'pypy38' + cibw_arch: 'x86_64' + cibw_build: false + os: 'macos-latest' + - name: 'pypy39 (ubuntu/x86_64)' + python: 'pypy-3.9' + toxpython: 'pypy3.9' + python_arch: 'x64' + tox_env: 'pypy39' + cibw_arch: 'x86_64' + cibw_build: false + os: 'ubuntu-latest' + - name: 'pypy39 (windows/AMD64)' + python: 'pypy-3.9' + toxpython: 'pypy3.9' + python_arch: 'x64' + tox_env: 'pypy39' + cibw_arch: 'AMD64' + cibw_build: false + os: 'windows-latest' + - name: 'pypy39 (macos/x86_64)' + python: 'pypy-3.9' + toxpython: 'pypy3.9' + python_arch: 'x64' + tox_env: 'pypy39' + cibw_arch: 'x86_64' + cibw_build: false + os: 'macos-latest' + - name: 'pypy310 (ubuntu/x86_64)' + python: 'pypy-3.10' + toxpython: 'pypy3.10' + python_arch: 'x64' + tox_env: 'pypy310' + cibw_arch: 'x86_64' + cibw_build: false + os: 'ubuntu-latest' + - name: 'pypy310 (windows/AMD64)' + python: 'pypy-3.10' + toxpython: 'pypy3.10' + python_arch: 'x64' + tox_env: 'pypy310' + cibw_arch: 'AMD64' + cibw_build: false + os: 'windows-latest' + - name: 'pypy310 (macos/x86_64)' + python: 'pypy-3.10' + toxpython: 'pypy3.10' + python_arch: 'x64' + tox_env: 'pypy310' + cibw_arch: 'x86_64' + cibw_build: false + os: 'macos-latest' + steps: + - uses: docker/setup-qemu-action@v3 + if: matrix.cibw_arch == 'aarch64' + with: + platforms: arm64 + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python }} + architecture: ${{ matrix.python_arch }} + - name: install dependencies + run: | + python -mpip install --progress-bar=off cibuildwheel -r ci/requirements.txt + virtualenv --version + pip --version + tox --version + pip list --format=freeze + - name: cibw build and test + if: matrix.cibw_build + run: cibuildwheel + env: + TOXPYTHON: '${{ matrix.toxpython }}' + CIBW_ARCHS: '${{ matrix.cibw_arch }}' + CIBW_BUILD: '${{ matrix.cibw_build }}' + CIBW_BUILD_VERBOSITY: '3' + CIBW_TEST_REQUIRES: > + tox + tox-direct + CIBW_TEST_COMMAND: > + cd {project} && + tox --skip-pkg-install --direct-yolo -e ${{ matrix.tox_env }} -v + CIBW_TEST_COMMAND_WINDOWS: > + cd /d {project} && + tox --skip-pkg-install --direct-yolo -e ${{ matrix.tox_env }} -v + - name: regular build and test + env: + TOXPYTHON: '${{ matrix.toxpython }}' + if: > + !matrix.cibw_build + run: > + tox -e ${{ matrix.tox_env }} -v + - uses: codecov/codecov-action@v3 + if: matrix.cover + with: + verbose: true + flags: ${{ matrix.tox_env }} + - name: check wheel + if: matrix.cibw_build + run: twine check wheelhouse/*.whl + - name: upload wheel + uses: actions/upload-artifact@v3 + if: matrix.cibw_build + with: + path: wheelhouse/*.whl + finish: + needs: test + if: ${{ always() }} + runs-on: ubuntu-latest + steps: + - uses: codecov/codecov-action@v3 + with: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..77973dd --- /dev/null +++ b/.gitignore @@ -0,0 +1,74 @@ +*.py[cod] +__pycache__ + +# Temp files +.*.sw[po] +*~ +*.bak +.DS_Store + +# C extensions +*.so + +# Build and package files +*.egg +*.egg-info +.bootstrap +.build +.cache +.eggs +.env +.installed.cfg +.ve +bin +build +develop-eggs +dist +eggs +lib +lib64 +parts +pip-wheel-metadata/ +pyvenv*/ +sdist +var +venv*/ +wheelhouse + +# Installer logs +pip-log.txt + +# Unit test / coverage reports +.benchmarks +.coverage +.coverage.* +.pytest +.pytest_cache/ +.tox +coverage.xml +htmlcov +nosetests.xml + +# Translations +*.mo + +# Buildout +.mr.developer.cfg + +# IDE project files +*.iml +*.komodoproject +.idea +.project +.pydevproject +.vscode + +# Complexity +output/*.html +output/*/index.html + +# Sphinx +docs/_build + +# Mypy Cache +.mypy_cache/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..0da324c --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,19 @@ +# To install the git pre-commit hooks run: +# pre-commit install --install-hooks +# To update the versions: +# pre-commit autoupdate +exclude: '^(\.tox|ci/templates|\.bumpversion\.cfg)(/|$)' +# Note the order is intentional to avoid multiple passes of the hooks +repos: + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: main + hooks: + - id: ruff + args: [--fix, --exit-non-zero-on-fix, --show-fixes] + - id: ruff-format + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: main + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: debug-statements diff --git a/.readthedocs.yml b/.readthedocs.yml new file mode 100644 index 0000000..009a913 --- /dev/null +++ b/.readthedocs.yml @@ -0,0 +1,14 @@ +# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details +version: 2 +sphinx: + configuration: docs/conf.py +formats: all +build: + os: ubuntu-22.04 + tools: + python: "3" +python: + install: + - requirements: docs/requirements.txt + - method: pip + path: . diff --git a/AUTHORS.rst b/AUTHORS.rst new file mode 100644 index 0000000..53ca547 --- /dev/null +++ b/AUTHORS.rst @@ -0,0 +1,5 @@ + +Authors +======= + +* Christopher Lorton - https://www.idmod.org diff --git a/CHANGELOG.rst b/CHANGELOG.rst new file mode 100644 index 0000000..632c47f --- /dev/null +++ b/CHANGELOG.rst @@ -0,0 +1,8 @@ + +Changelog +========= + +0.0.1 (2024-09-30) +------------------ + +* First release on PyPI. diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst new file mode 100644 index 0000000..454eba7 --- /dev/null +++ b/CONTRIBUTING.rst @@ -0,0 +1,85 @@ +============ +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 `_ 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 +========================== + +LASER Cholera could always use more documentation, whether as part of the +official LASER Cholera 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/InstituteforDiseaseModeling/laser-cholera/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 `laser-cholera` for local development: + +1. Fork `laser-cholera `_ + (look for the "Fork" button). +2. Clone your fork locally:: + + git clone git@github.com:YOURGITHUBNAME/laser-cholera.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 and docs builder with 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``). +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``. + +Tips +---- + +To run a subset of tests:: + + tox -e envname -- pytest -k test_myfeature + +To run all the test environments in *parallel*:: + + tox -p auto diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..351554c --- /dev/null +++ b/LICENSE @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) 2024, Christopher Lorton + +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 (including the next paragraph) 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. \ No newline at end of file diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..d0dac9c --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,22 @@ +graft docs +graft src +graft ci +graft tests + +include .bumpversion.cfg +include .cookiecutterrc +include .coveragerc +include .editorconfig +include .github/workflows/github-actions.yml +include .pre-commit-config.yaml +include .readthedocs.yml +include pytest.ini +include tox.ini + +include AUTHORS.rst +include CHANGELOG.rst +include CONTRIBUTING.rst +include LICENSE +include README.rst + +global-exclude *.py[cod] __pycache__/* *.so *.dylib diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..3571e63 --- /dev/null +++ b/README.rst @@ -0,0 +1,97 @@ +======== +Overview +======== + +.. start-badges + +.. list-table:: + :stub-columns: 1 + + * - docs + - |docs| + * - tests + - |github-actions| |codecov| + * - package + - |version| |wheel| |supported-versions| |supported-implementations| |commits-since| +.. |docs| image:: https://readthedocs.org/projects/laser-cholera/badge/?style=flat + :target: https://readthedocs.org/projects/laser-cholera/ + :alt: Documentation Status + +.. |github-actions| image:: https://github.com/InstituteforDiseaseModeling/laser-cholera/actions/workflows/github-actions.yml/badge.svg + :alt: GitHub Actions Build Status + :target: https://github.com/InstituteforDiseaseModeling/laser-cholera/actions + +.. |codecov| image:: https://codecov.io/gh/InstituteforDiseaseModeling/laser-cholera/branch/main/graphs/badge.svg?branch=main + :alt: Coverage Status + :target: https://app.codecov.io/github/InstituteforDiseaseModeling/laser-cholera + +.. |version| image:: https://img.shields.io/pypi/v/laser-cholera.svg + :alt: PyPI Package latest release + :target: https://pypi.org/project/laser-cholera + +.. |wheel| image:: https://img.shields.io/pypi/wheel/laser-cholera.svg + :alt: PyPI Wheel + :target: https://pypi.org/project/laser-cholera + +.. |supported-versions| image:: https://img.shields.io/pypi/pyversions/laser-cholera.svg + :alt: Supported versions + :target: https://pypi.org/project/laser-cholera + +.. |supported-implementations| image:: https://img.shields.io/pypi/implementation/laser-cholera.svg + :alt: Supported implementations + :target: https://pypi.org/project/laser-cholera + +.. |commits-since| image:: https://img.shields.io/github/commits-since/InstituteforDiseaseModeling/laser-cholera/v0.0.1.svg + :alt: Commits since latest release + :target: https://github.com/InstituteforDiseaseModeling/laser-cholera/compare/v0.0.1...main + + + +.. end-badges + +LASIK - LASER based SImulation of Kolera + +* Free software: MIT license + +Installation +============ + +:: + + pip install laser-cholera + +You can also install the in-development version with:: + + pip install https://github.com/InstituteforDiseaseModeling/laser-cholera/archive/main.zip + + +Documentation +============= + + +https://laser-cholera.readthedocs.io/ + + +Development +=========== + +To run all the 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 diff --git a/ci/bootstrap.py b/ci/bootstrap.py new file mode 100755 index 0000000..6b72c2f --- /dev/null +++ b/ci/bootstrap.py @@ -0,0 +1,83 @@ +#!/usr/bin/env python +import os +import pathlib +import subprocess +import sys + +base_path: pathlib.Path = pathlib.Path(__file__).resolve().parent.parent +templates_path = base_path / "ci" / "templates" + + +def check_call(args): + print("+", *args) + subprocess.check_call(args) + + +def exec_in_env(): + env_path = base_path / ".tox" / "bootstrap" + if sys.platform == "win32": + bin_path = env_path / "Scripts" + else: + bin_path = env_path / "bin" + if not env_path.exists(): + import subprocess + + print(f"Making bootstrap env in: {env_path} ...") + try: + check_call([sys.executable, "-m", "venv", env_path]) + except subprocess.CalledProcessError: + try: + check_call([sys.executable, "-m", "virtualenv", env_path]) + except subprocess.CalledProcessError: + check_call(["virtualenv", env_path]) + print("Installing `jinja2` into bootstrap environment...") + check_call([bin_path / "pip", "install", "jinja2", "tox"]) + python_executable = bin_path / "python" + if not python_executable.exists(): + python_executable = python_executable.with_suffix(".exe") + + print(f"Re-executing with: {python_executable}") + print("+ exec", python_executable, __file__, "--no-env") + os.execv(python_executable, [python_executable, __file__, "--no-env"]) + + +def main(): + import jinja2 + + print(f"Project path: {base_path}") + + jinja = jinja2.Environment( + loader=jinja2.FileSystemLoader(str(templates_path)), + trim_blocks=True, + lstrip_blocks=True, + keep_trailing_newline=True, + ) + tox_environments = [ + line.strip() + # 'tox' need not be installed globally, but must be importable + # by the Python that is running this script. + # This uses sys.executable the same way that the call in + # cookiecutter-pylibrary/hooks/post_gen_project.py + # invokes this bootstrap.py itself. + for line in subprocess.check_output([sys.executable, "-m", "tox", "--listenvs"], universal_newlines=True).splitlines() + ] + tox_environments = [line for line in tox_environments if line.startswith("py")] + for template in templates_path.rglob("*"): + if template.is_file(): + template_path = template.relative_to(templates_path).as_posix() + destination = base_path / template_path + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_text(jinja.get_template(template_path).render(tox_environments=tox_environments)) + print(f"Wrote {template_path}") + print("DONE.") + + +if __name__ == "__main__": + args = sys.argv[1:] + if args == ["--no-env"]: + main() + elif not args: + exec_in_env() + else: + print(f"Unexpected arguments: {args}", file=sys.stderr) + sys.exit(1) diff --git a/ci/requirements.txt b/ci/requirements.txt new file mode 100644 index 0000000..a1708f4 --- /dev/null +++ b/ci/requirements.txt @@ -0,0 +1,6 @@ +virtualenv>=16.6.0 +pip>=19.1.1 +setuptools>=18.0.1 +six>=1.14.0 +tox +twine diff --git a/ci/templates/.github/workflows/github-actions.yml b/ci/templates/.github/workflows/github-actions.yml new file mode 100644 index 0000000..6495523 --- /dev/null +++ b/ci/templates/.github/workflows/github-actions.yml @@ -0,0 +1,126 @@ +name: build +on: [push, pull_request, workflow_dispatch] +jobs: + test: + name: {{ '${{ matrix.name }}' }} + runs-on: {{ '${{ matrix.os }}' }} + timeout-minutes: 30 + strategy: + fail-fast: false + matrix: + include: + - name: 'check' + python: '3.11' + toxpython: 'python3.11' + tox_env: 'check' + os: 'ubuntu-latest' + - name: 'docs' + python: '3.11' + toxpython: 'python3.11' + tox_env: 'docs' + os: 'ubuntu-latest' +{% for env in tox_environments %} +{% set prefix = env.split('-')[0] -%} +{% if prefix.startswith('pypy') %} +{% set python %}pypy-{{ prefix[4] }}.{{ prefix[5:] }}{% endset %} +{% set cpython %}pp{{ prefix[4:5] }}{% endset %} +{% set toxpython %}pypy{{ prefix[4] }}.{{ prefix[5:] }}{% endset %} +{% else %} +{% set python %}{{ prefix[2] }}.{{ prefix[3:] }}{% endset %} +{% set cpython %}cp{{ prefix[2:] }}{% endset %} +{% set toxpython %}python{{ prefix[2] }}.{{ prefix[3:] }}{% endset %} +{% endif %} +{% for os, python_arch, cibw_arch, wheel_arch, include_cover in [ + ['ubuntu', 'x64', 'x86_64', '*manylinux*', True], + ['ubuntu', 'x64', 'x86_64', '*musllinux*', False], + ['ubuntu', 'x64', 'aarch64', '*manylinux*', False], + ['ubuntu', 'x64', 'aarch64', '*musllinux*', False], + ['windows', 'x64', 'AMD64', '*', True], + ['windows', 'x86', 'x86', '*', False], + ['macos', 'x64', 'x86_64', '*', True], +] %} +{% if include_cover or ('nocov' in env and not prefix.startswith('pypy')) %} +{% set wheel_suffix = 'nocov' in env and wheel_arch.strip('*') %} +{% set name_suffix = '/' + wheel_suffix if wheel_suffix else '' %} + - name: '{{ env }} ({{ os }}/{{ cibw_arch }}{{ name_suffix }})' + python: '{{ python }}' + toxpython: '{{ toxpython }}' + python_arch: '{{ python_arch }}' + tox_env: '{{ env }}' +{% if 'cover' in env %} + cover: true +{% endif %} + cibw_arch: '{{ cibw_arch }}' +{% if 'nocov' in env and not prefix.startswith('pypy') %} + cibw_build: '{{ cpython }}-{{ wheel_arch }}' +{% else %} + cibw_build: false +{% endif %} + os: '{{ os }}-latest' +{% endif %} +{% endfor %} +{% endfor %} + steps: + - uses: docker/setup-qemu-action@v3 + if: matrix.cibw_arch == 'aarch64' + with: + platforms: arm64 + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-python@v5 + with: + python-version: {{ '${{ matrix.python }}' }} + architecture: {{ '${{ matrix.python_arch }}' }} + - name: install dependencies + run: | + python -mpip install --progress-bar=off cibuildwheel -r ci/requirements.txt + virtualenv --version + pip --version + tox --version + pip list --format=freeze + - name: cibw build and test + if: matrix.cibw_build + run: cibuildwheel + env: + TOXPYTHON: '{{ '${{ matrix.toxpython }}' }}' + CIBW_ARCHS: '{{ '${{ matrix.cibw_arch }}' }}' + CIBW_BUILD: '{{ '${{ matrix.cibw_build }}' }}' + CIBW_BUILD_VERBOSITY: '3' + CIBW_TEST_REQUIRES: > + tox + tox-direct + CIBW_TEST_COMMAND: > + cd {project} && + tox --skip-pkg-install --direct-yolo -e {{ '${{ matrix.tox_env }}' }} -v + CIBW_TEST_COMMAND_WINDOWS: > + cd /d {project} && + tox --skip-pkg-install --direct-yolo -e {{ '${{ matrix.tox_env }}' }} -v + - name: regular build and test + env: + TOXPYTHON: '{{ '${{ matrix.toxpython }}' }}' + if: > + !matrix.cibw_build + run: > + tox -e {{ '${{ matrix.tox_env }}' }} -v + - uses: codecov/codecov-action@v3 + if: matrix.cover + with: + verbose: true + flags: {{ '${{ matrix.tox_env }}' }} + - name: check wheel + if: matrix.cibw_build + run: twine check wheelhouse/*.whl + - name: upload wheel + uses: actions/upload-artifact@v3 + if: matrix.cibw_build + with: + path: wheelhouse/*.whl + finish: + needs: test + if: {{ '${{ always() }}' }} + runs-on: ubuntu-latest + steps: + - uses: codecov/codecov-action@v3 + with: + CODECOV_TOKEN: {% raw %}${{ secrets.CODECOV_TOKEN }}{% endraw %} diff --git a/docs/authors.rst b/docs/authors.rst new file mode 100644 index 0000000..e122f91 --- /dev/null +++ b/docs/authors.rst @@ -0,0 +1 @@ +.. include:: ../AUTHORS.rst diff --git a/docs/changelog.rst b/docs/changelog.rst new file mode 100644 index 0000000..565b052 --- /dev/null +++ b/docs/changelog.rst @@ -0,0 +1 @@ +.. include:: ../CHANGELOG.rst diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000..914d33b --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,39 @@ +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", +] +source_suffix = ".rst" +master_doc = "index" +project = "LASER Cholera" +year = "2024" +author = "Christopher Lorton" +copyright = f"{year}, {author}" +version = release = "0.0.1" + +pygments_style = "trac" +templates_path = ["."] +extlinks = { + "issue": ("https://github.com/InstituteforDiseaseModeling/laser-cholera/issues/%s", "#%s"), + "pr": ("https://github.com/InstituteforDiseaseModeling/laser-cholera/pull/%s", "PR #%s"), +} + +html_theme = "furo" +html_theme_options = { + "githuburl": "https://github.com/InstituteforDiseaseModeling/laser-cholera/", +} + +html_use_smartypants = True +html_last_updated_fmt = "%b %d, %Y" +html_split_index = False +html_short_title = f"{project}-{version}" + +napoleon_use_ivar = True +napoleon_use_rtype = False +napoleon_use_param = False diff --git a/docs/contributing.rst b/docs/contributing.rst new file mode 100644 index 0000000..e582053 --- /dev/null +++ b/docs/contributing.rst @@ -0,0 +1 @@ +.. include:: ../CONTRIBUTING.rst diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..ad842d5 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,21 @@ +======== +Contents +======== + +.. toctree:: + :maxdepth: 2 + + readme + installation + usage + reference/index + contributing + authors + changelog + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/docs/installation.rst b/docs/installation.rst new file mode 100644 index 0000000..dcb1042 --- /dev/null +++ b/docs/installation.rst @@ -0,0 +1,7 @@ +============ +Installation +============ + +At the command line:: + + pip install laser-cholera diff --git a/docs/readme.rst b/docs/readme.rst new file mode 100644 index 0000000..72a3355 --- /dev/null +++ b/docs/readme.rst @@ -0,0 +1 @@ +.. include:: ../README.rst diff --git a/docs/reference/index.rst b/docs/reference/index.rst new file mode 100644 index 0000000..e78e0e9 --- /dev/null +++ b/docs/reference/index.rst @@ -0,0 +1,7 @@ +Reference +========= + +.. toctree:: + :glob: + + laser_cholera* diff --git a/docs/reference/laser_cholera.rst b/docs/reference/laser_cholera.rst new file mode 100644 index 0000000..e9225bf --- /dev/null +++ b/docs/reference/laser_cholera.rst @@ -0,0 +1,11 @@ +laser_cholera +============= + +.. testsetup:: + + from laser_cholera import * + +.. automodule:: laser_cholera + :members: + :undoc-members: + :special-members: __init__, __len__ diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 0000000..c03e307 --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1,2 @@ +sphinx>=1.3 +furo diff --git a/docs/spelling_wordlist.txt b/docs/spelling_wordlist.txt new file mode 100644 index 0000000..f95eb78 --- /dev/null +++ b/docs/spelling_wordlist.txt @@ -0,0 +1,11 @@ +builtin +builtins +classmethod +staticmethod +classmethods +staticmethods +args +kwargs +callstack +Changelog +Indices diff --git a/docs/usage.rst b/docs/usage.rst new file mode 100644 index 0000000..c176945 --- /dev/null +++ b/docs/usage.rst @@ -0,0 +1,10 @@ +===== +Usage +===== + +To use the project: + +.. code-block:: python + + import laser_cholera + laser_cholera.compute(...) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..491e87e --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,54 @@ +[build-system] +requires = [ + "setuptools>=30.3.0", +] + +[tool.ruff] +extend-exclude = ["static", "ci/templates"] +line-length = 140 +src = ["src", "tests"] +target-version = "py38" + +[tool.ruff.lint.per-file-ignores] +"ci/*" = ["S"] + +[tool.ruff.lint] +ignore = [ + "RUF001", # ruff-specific rules ambiguous-unicode-character-string + "S101", # flake8-bandit assert + "S308", # flake8-bandit suspicious-mark-safe-usage + "S603", # flake8-bandit subprocess-without-shell-equals-true + "S607", # flake8-bandit start-process-with-partial-path + "E501", # pycodestyle line-too-long +] +select = [ + "B", # flake8-bugbear + "C4", # flake8-comprehensions + "DTZ", # flake8-datetimez + "E", # pycodestyle errors + "EXE", # flake8-executable + "F", # pyflakes + "I", # isort + "INT", # flake8-gettext + "PIE", # flake8-pie + "PLC", # pylint convention + "PLE", # pylint errors + "PT", # flake8-pytest-style + "PTH", # flake8-use-pathlib + "RSE", # flake8-raise + "RUF", # ruff-specific rules + "S", # flake8-bandit + "UP", # pyupgrade + "W", # pycodestyle warnings +] + +[tool.ruff.lint.flake8-pytest-style] +fixture-parentheses = false +mark-parentheses = false + +[tool.ruff.lint.isort] +forced-separate = ["conftest"] +force-single-line = true + +[tool.ruff.format] +quote-style = "double" diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..062e349 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,30 @@ +[pytest] +# If a pytest section is found in one of the possible config files +# (pytest.ini, tox.ini or setup.cfg), then pytest will not look for any others, +# so if you add a pytest config section elsewhere, +# you will need to delete this section from setup.cfg. +norecursedirs = + migrations + +python_files = + test_*.py + *_test.py + tests.py +addopts = + -ra + --strict-markers + --doctest-modules + --doctest-glob=\*.rst + --tb=short +testpaths = + tests +# If you want to switch back to tests outside package just remove --pyargs +# and edit testpaths to have "tests/" instead of "laser_cholera". + +# Idea from: https://til.simonwillison.net/pytest/treat-warnings-as-errors +filterwarnings = + error +# You can add exclusions, some examples: +# ignore:'laser_cholera' defines default_app_config:PendingDeprecationWarning:: +# ignore:The {{% if::: +# ignore:Coverage disabled via --no-cov switch! diff --git a/setup.py b/setup.py new file mode 100755 index 0000000..dbd32f0 --- /dev/null +++ b/setup.py @@ -0,0 +1,145 @@ +#!/usr/bin/env python +import os +import platform +import re +from pathlib import Path + +from setuptools import Extension +from setuptools import find_packages +from setuptools import setup +from setuptools.command.build_ext import build_ext +from setuptools.dist import Distribution + +# Enable code coverage for C code: we cannot use CFLAGS=-coverage in tox.ini, since that may mess with compiling +# dependencies (e.g. numpy). Therefore, we set SETUPPY_CFLAGS=-coverage in tox.ini and copy it to CFLAGS here (after +# deps have been safely installed). +if "TOX_ENV_NAME" in os.environ and os.environ.get("SETUPPY_EXT_COVERAGE") == "yes" and platform.system() == "Linux": + CFLAGS = os.environ["CFLAGS"] = "-fprofile-arcs -ftest-coverage" + LFLAGS = os.environ["LFLAGS"] = "-lgcov" +else: + CFLAGS = "" + LFLAGS = "" + + +class OptionalBuildExt(build_ext): + """ + Allow the building of C extensions to fail. + """ + + def run(self): + try: + if os.environ.get("SETUPPY_FORCE_PURE"): + raise Exception("C extensions disabled (SETUPPY_FORCE_PURE)!") + super().run() + except Exception as e: + self._unavailable(e) + self.extensions = [] # avoid copying missing files (it would fail). + + def _unavailable(self, e): + print("*" * 80) + print( + """WARNING: + + An optional code optimization (C extension) could not be compiled. + + Optimizations for this package will not be available! + """ + ) + + print("CAUSE:") + print("") + print(" " + repr(e)) + print("*" * 80) + + +class BinaryDistribution(Distribution): + """ + Distribution which almost always forces a binary package with platform name + """ + + def has_ext_modules(self): + return super().has_ext_modules() or not os.environ.get("SETUPPY_ALLOW_PURE") + + +def read(*names, **kwargs): + with Path(__file__).parent.joinpath(*names).open(encoding=kwargs.get("encoding", "utf8")) as fh: + return fh.read() + + +setup( + name="laser-cholera", + version="0.0.1", + license="MIT", + description="LASIK - LASER based SImulation of Kolera", + long_description="{}\n{}".format( + re.compile("^.. start-badges.*^.. end-badges", re.M | re.S).sub("", read("README.rst")), + re.sub(":[a-z]+:`~?(.*?)`", r"``\1``", read("CHANGELOG.rst")), + ), + author="Christopher Lorton", + author_email="christopher.lorton@gatesfoundation.org", + url="https://github.com/InstituteforDiseaseModeling/laser-cholera", + packages=find_packages("src"), + package_dir={"": "src"}, + py_modules=[path.stem for path in Path("src").glob("*.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 :: MIT License", + "Operating System :: Unix", + "Operating System :: POSIX", + "Operating System :: Microsoft :: Windows", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "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", + ], + project_urls={ + "Documentation": "https://laser-cholera.readthedocs.io/", + "Changelog": "https://laser-cholera.readthedocs.io/en/latest/changelog.html", + "Issue Tracker": "https://github.com/InstituteforDiseaseModeling/laser-cholera/issues", + }, + keywords=[ + # eg: "keyword1", "keyword2", "keyword3", + ], + python_requires=">=3.8", + install_requires=[ + "click", + # eg: "aspectlib==1.1.1", "six>=1.7", + ], + extras_require={ + # eg: + # "rst": ["docutils>=0.11"], + # ":python_version=='3.8'": ["backports.zoneinfo"], + }, + entry_points={ + "console_scripts": [ + "laser-cholera = laser_cholera.cli:run", + ] + }, + cmdclass={"build_ext": OptionalBuildExt}, + ext_modules=[ + Extension( + str(path.relative_to("src").with_suffix("")).replace(os.sep, "."), + sources=[str(path)], + extra_compile_args=CFLAGS.split(), + extra_link_args=LFLAGS.split(), + include_dirs=[str(path.parent)], + ) + for path in Path("src").glob("**/*.c") + ], + distclass=BinaryDistribution, +) diff --git a/src/laser_cholera/__init__.py b/src/laser_cholera/__init__.py new file mode 100644 index 0000000..323c6a9 --- /dev/null +++ b/src/laser_cholera/__init__.py @@ -0,0 +1,7 @@ +__version__ = "0.0.1" + +from .core import compute + +__all__ = [ + "compute", +] diff --git a/src/laser_cholera/__main__.py b/src/laser_cholera/__main__.py new file mode 100644 index 0000000..46e3394 --- /dev/null +++ b/src/laser_cholera/__main__.py @@ -0,0 +1,15 @@ +""" +Entrypoint module, in case you use `python -mlaser_cholera`. + + +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 laser_cholera.cli import run + +if __name__ == "__main__": + run() diff --git a/src/laser_cholera/_core.c b/src/laser_cholera/_core.c new file mode 100644 index 0000000..2d5813b --- /dev/null +++ b/src/laser_cholera/_core.c @@ -0,0 +1,82 @@ +#include "Python.h" + +static PyObject* compute(PyObject *self, PyObject *value) { + PyObject *module; + PyObject *module_dict; + PyObject *len; + PyObject *max; + PyObject *args; + PyObject *kwargs; + PyObject *result; + module = PyImport_ImportModule("builtins"); + if (!module) + return NULL; + + module_dict = PyModule_GetDict(module); + len = PyDict_GetItemString(module_dict, "len"); + if (!len) { + Py_DECREF(module); + return NULL; + } + max = PyDict_GetItemString(module_dict, "max"); + if (!max) { + Py_DECREF(module); + return NULL; + } + Py_DECREF(module); + + args = PyTuple_New(1); + if (!args) { + return NULL; + } + Py_INCREF(value); + PyTuple_SetItem(args, 0, value); + + kwargs = PyDict_New(); + if (!kwargs) { + Py_DECREF(args); + return NULL; + } + PyDict_SetItemString(kwargs, "key", len); + + result = PyObject_Call(max, args, kwargs); + + Py_DECREF(args); + Py_DECREF(kwargs); + + return result; +} + +PyDoc_STRVAR(compute_doc, "Docstring for compute function."); + +static struct PyMethodDef module_functions[] = { + {"compute", compute, METH_O, compute_doc}, + {NULL, NULL} +}; + +static struct PyModuleDef moduledef = { + PyModuleDef_HEAD_INIT, + "laser_cholera._core", /* m_name */ + NULL, /* m_doc */ + -1, /* m_size */ + module_functions, /* m_methods */ + NULL, /* m_reload */ + NULL, /* m_traverse */ + NULL, /* m_clear */ + NULL, /* m_free */ +}; + +static PyObject* moduleinit(void) { + PyObject *module; + + module = PyModule_Create(&moduledef); + + if (module == NULL) + return NULL; + + return module; +} + +PyMODINIT_FUNC PyInit__core(void) { + return moduleinit(); +} diff --git a/src/laser_cholera/cli.py b/src/laser_cholera/cli.py new file mode 100644 index 0000000..095153f --- /dev/null +++ b/src/laser_cholera/cli.py @@ -0,0 +1,26 @@ +""" +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 -mlaser_cholera` python will execute + ``__main__.py`` as a script. That means there will not be any + ``laser_cholera.__main__`` in ``sys.modules``. + - When you import __main__ it will get executed again (as a module) because + there"s no ``laser_cholera.__main__`` in ``sys.modules``. + + Also see (1) from http://click.pocoo.org/5/setuptools/#setuptools-integration +""" + +import click + +from .core import compute + + +@click.command() +@click.argument("names", nargs=-1) +def run(names): + click.echo(compute(names)) diff --git a/src/laser_cholera/core.py b/src/laser_cholera/core.py new file mode 100644 index 0000000..6354cc2 --- /dev/null +++ b/src/laser_cholera/core.py @@ -0,0 +1,6 @@ +try: + from ._core import compute +except ImportError: + + def compute(args): + return max(args, key=len) diff --git a/tests/test_cli.py b/tests/test_cli.py new file mode 100644 index 0000000..387dc0f --- /dev/null +++ b/tests/test_cli.py @@ -0,0 +1,5 @@ +import subprocess + + +def test_main(): + assert subprocess.check_output(["laser-cholera", "foo", "foobar"], text=True) == "foobar\n" diff --git a/tests/test_core.py b/tests/test_core.py new file mode 100644 index 0000000..e239ece --- /dev/null +++ b/tests/test_core.py @@ -0,0 +1,5 @@ +from laser_cholera import compute + + +def test_compute(): + assert compute(["a", "bc", "abc"]) == "abc" diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..9cbf432 --- /dev/null +++ b/tox.ini @@ -0,0 +1,84 @@ +[testenv:bootstrap] +deps = + jinja2 + tox +skip_install = true +commands = + python ci/bootstrap.py --no-env +passenv = + * + +; a generative tox configuration, see: https://tox.wiki/en/latest/user_guide.html#generative-environments +[tox] +envlist = + clean, + check, + docs, + {py38,py39,py310,py311,py312,pypy38,pypy39,pypy310}, + report +ignore_basepython_conflict = true + +[testenv] +basepython = + pypy38: {env:TOXPYTHON:pypy3.8} + pypy39: {env:TOXPYTHON:pypy3.9} + pypy310: {env:TOXPYTHON:pypy3.10} + py38: {env:TOXPYTHON:python3.8} + py39: {env:TOXPYTHON:python3.9} + py310: {env:TOXPYTHON:python3.10} + py311: {env:TOXPYTHON:python3.11} + py312: {env:TOXPYTHON:python3.12} + {bootstrap,clean,check,report,docs,codecov}: {env:TOXPYTHON:python3} +setenv = + PYTHONPATH={toxinidir}/tests + PYTHONUNBUFFERED=yes + cover: SETUPPY_EXT_COVERAGE=yes +passenv = + * +usedevelop = false +deps = + pytest + pytest-cov + setuptools +commands = + {posargs:pytest --cov --cov-report=term-missing --cov-report=xml -vv tests} + +[testenv:check] +deps = + docutils + check-manifest + pre-commit + readme-renderer + pygments + isort +skip_install = true +commands = + python setup.py check --strict --metadata --restructuredtext + check-manifest . + pre-commit run --all-files --show-diff-on-failure + +[testenv:docs] +usedevelop = true +deps = + -r{toxinidir}/docs/requirements.txt +commands = + sphinx-build {posargs:-E} -b doctest docs dist/docs + sphinx-build {posargs:-E} -b html docs dist/docs + sphinx-build -b linkcheck docs dist/docs + +[testenv:report] +deps = + coverage +skip_install = true +commands = + coverage report + coverage html + +[testenv:clean] +commands = + python setup.py clean + coverage erase +skip_install = true +deps = + setuptools + coverage