from invoke import task
import sys

PYTHON = sys.executable


@task
def full_check(ctx):
    """
    Run all tests, including code style, type check and other QA metrics.
    """
    return ctx.run(
        (
            f"{PYTHON} -m pytest --cov --cov-report=html"
            f" && {PYTHON} -m flake8 easymunk"
            f" && {PYTHON} -m black . --check"
            f" && {PYTHON} -m mypy easymunk"
            f" && {PYTHON} -m readme_renderer README.rst"
        ),
        pty=True,
    )


@task
def build_docs(ctx):
    ctx.run("sphinx-build docs/src build/docs", pty=True)


@task
def run_examples(ctx, start_from=0):
    examples = [
        # Reviewed implementation and follow best practices
        "logo.py",
        # Works nicely
        "arrows.py",
        "autogeometry.py",
        "balls_and_lines.py",
        "basic_test.py",
        "bouncing_balls.py",
        "box2d_pyramid.py",
        "box2d_vertical_stack.py",
        "constraints.py",
        "contact_and_no_flipy.py",
        "contact_with_friction.py",
        "damped_rotary_spring_pointer.py",
        "deformable.py",
        "flipper.py",
        "kivy_pymunk_demo/main.py",
        "matplotlib_util_demo.py",
        "newtons_cradle.py",
        "platformer.py",
        "playground.py",
        "point_query.py",
        "pygame_demo.py",
        "pyglet_demo.py",
        "pyxel_demo.py",
        "shapes_for_draw_demos.py",
        "slide_and_pinjoint.py",
        "spiderweb.py",
        "tangram.py",
        "tank.py",
        "using_sprites.py",
        "using_sprites_pyglet.py",
        "breakout.py",
        # Start but have some bugs
        # Broken
        "junctions.py",
        "index_video.py",
        "copy_and_pickle.py",
        "threaded_space.py",
        "py2exe_setup__basic_test.py",  # Windows specific?
        "py2exe_setup__breakout.py",
        # Can we run these?
        # "newtons_cradle.ipynb",
        # "matplotlib_util_demo.ipynb",
    ]
    for i, example in enumerate(examples, 1):
        if i >= start_from:
            print(f"\n\nRunning example [{i}]: {example}")
            ctx.run(f"{PYTHON} examples/{example}")

from invoke import task
import sys

PYTHON = sys.executable


@task
def full_check(ctx):
    """
    Run all tests, including code style, type check and other QA metrics.
    """
    return ctx.run(
        (
            f"{PYTHON} -m pytest --cov --cov-report=html"
            f" && {PYTHON} -m flake8 easymunk"
            f" && {PYTHON} -m black . --check"
            f" && {PYTHON} -m mypy easymunk"
            f" && {PYTHON} -m readme_renderer README.rst"
        ),
        pty=True,
    )


@task
def build_docs(ctx):
    ctx.run("sphinx-build docs/src build/docs", pty=True)


@task
def run_examples(ctx, start_from=0):
    examples = [
        # Reviewed implementation and follow best practices
        "logo.py",
        # Works nicely
        "arrows.py",
        "autogeometry.py",
        "balls_and_lines.py",
        "basic_test.py",
        "bouncing_balls.py",
        "box2d_pyramid.py",
        "box2d_vertical_stack.py",
        "constraints.py",
        "contact_and_no_flipy.py",
        "contact_with_friction.py",
        "damped_rotary_spring_pointer.py",
        "deformable.py",
        "flipper.py",
        "kivy_pymunk_demo/main.py",
        "matplotlib_util_demo.py",
        "newtons_cradle.py",
        "platformer.py",
        "playground.py",
        "point_query.py",
        "pygame_demo.py",
        "pyglet_demo.py",
        "pyxel_demo.py",
        "shapes_for_draw_demos.py",
        "slide_and_pinjoint.py",
        "spiderweb.py",
        "tangram.py",
        "tank.py",
        "using_sprites.py",
        "using_sprites_pyglet.py",
        "breakout.py",
        # Start but have some bugs
        # Broken
        "junctions.py",
        "index_video.py",
        "copy_and_pickle.py",
        "threaded_space.py",
        "py2exe_setup__basic_test.py",  # Windows specific?
        "py2exe_setup__breakout.py",
        # Can we run these?
        # "newtons_cradle.ipynb",
        # "matplotlib_util_demo.ipynb",
    ]
    for i, example in enumerate(examples, 1):
        if i >= start_from:
            print(f"\n\nRunning example [{i}]: {example}")
            ctx.run(f"{PYTHON} examples/{example}")

Run all tests, including code style, type check and other QA metrics. # Reviewed implementation and follow best practices # Works nicely # Start but have some bugs # Broken # Windows specific? # Can we run these? # "newtons_cradle.ipynb", # "matplotlib_util_demo.ipynb",