Skip to content

Commit

Permalink
[BUG] Fix installation setup to avoid no module named cli errors (#128)
Browse files Browse the repository at this point in the history
Fix installation setup to avoid no module named cli errors
  • Loading branch information
apoclyps authored May 22, 2021
1 parent e47ea3a commit 7f19ab0
Show file tree
Hide file tree
Showing 15 changed files with 50 additions and 30 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,6 @@ ENV/
# editors
.vscode/*
.idea/*

# mypy
.mypy_cache/
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,30 @@ $ python3 -m venv env
$ source env/bin/activate
(env)$ pip install -r requirements_dev.txt
(env)$ pip install -r requirements.txt
(env)$ python cli.py dashboard
(env)$ python -m reviews dashboard
```

If you wish to keep a copy of Reviews on your host system forever, you can install and run it using:
If you wish to keep a copy of Reviews on your host system, you can install and run it using:

```bash
$ export REPOSITORY_CONFIGURATION="apoclyps/reviews"
$ pip install -e .
$ reviews dashboard
$ python -m venv env
$ source env/bin/activate
$ python -m pip install -e .
$ reviews -h
```

You can run the Reviews within Docker:

```bash
docker-compose build cli && docker-compose run --rm cli python cli.py dashboard
docker-compose build cli && docker-compose run --rm cli python -m reviews dashboard
```

To build an image and run that image with all of the necessary dependencies using the following commands:

```bash
$ docker-compose build cli
$ docker-compose run --rm cli python cli.py dashboard
$ docker-compose run --rm cli python -m reviews dashboard
```

For instructions on setting up a development enviroment outside of Docker, checkout the [wiki](https://github.com/apoclyps/reviews/wiki/Development-Enviromnent).
Expand Down
7 changes: 7 additions & 0 deletions cli-runner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from reviews.cli.main import main

if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3.7"
services:
cli: &cli
build: .
command: python cli.py dashboard
command: python -m reviews dashboard
working_dir: /usr/src/app/
environment:
- DEBUG=true
Expand Down
7 changes: 7 additions & 0 deletions reviews/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# -*- coding: utf-8 -*-
"""Reviews CLI - Main script."""

from .cli.main import main

if __name__ == "__main__":
main()
Empty file added reviews/cli/__init__.py
Empty file.
15 changes: 8 additions & 7 deletions cli.py → reviews/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@

import asyncclick as click

from reviews.tasks import render, single_render
from reviews.version import __version__
from ..tasks import render, single_render
from ..version import __version__

CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"])


@click.group(context_settings=CONTEXT_SETTINGS)
@click.version_option(__version__, "-v", "--version", message="version %(version)s")
async def main():
async def cli() -> None:
"""Reviews - A terminal UI Dashboard for monitoring code review requests.\n
For feature requests or bug reports: https://github.com/apoclyps/reviews/issues
"""


@main.command(help="Visualize code review requests as a Dashboard")
@cli.command(help="Visualize code review requests as a Dashboard")
@click.option("-r", "--reload/--no-reload", default=True, is_flag=True)
async def dashboard(reload):
async def dashboard(reload: bool) -> None:
"""
Command:\n
reviews dashboard
Expand All @@ -40,5 +40,6 @@ async def dashboard(reload):
single_render()


if __name__ == "__main__":
asyncio.run(main())
def main() -> None:
"""Entry point to CLI"""
asyncio.run(cli())
6 changes: 3 additions & 3 deletions reviews/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from github.PullRequest import PullRequest as ghPullRequest
from rich.table import Table

from reviews import config
from reviews.layout import render_pull_request_table
from reviews.source_control import GithubAPI, Label, PullRequest
from . import config
from .layout import render_pull_request_table
from .source_control import GithubAPI, Label, PullRequest


class PullRequestController:
Expand Down
4 changes: 2 additions & 2 deletions reviews/layout/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from reviews.layout.helpers import ( # NOQA: F401
from ..layout.helpers import ( # NOQA: F401
generate_layout,
generate_log_table,
generate_progress_tracker,
generate_tree_layout,
render_pull_request_table,
)
from reviews.layout.managers import RenderLayoutManager # NOQA: F401
from ..layout.managers import RenderLayoutManager # NOQA: F401
4 changes: 2 additions & 2 deletions reviews/layout/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from rich.table import Table
from rich.tree import Tree

from reviews.config import get_label_colour_map
from reviews.source_control import PullRequest
from ..config import get_label_colour_map
from ..source_control import PullRequest


def render_pull_request_table(
Expand Down
2 changes: 1 addition & 1 deletion reviews/layout/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from rich.panel import Panel
from rich.table import Table

from reviews.layout.components import Header
from ..layout.components import Header

console = Console()

Expand Down
4 changes: 2 additions & 2 deletions reviews/source_control/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from reviews.source_control.client import GithubAPI # NOQA: F401
from reviews.source_control.models import Label, PullRequest # NOQA: F401
from ..source_control.client import GithubAPI # NOQA: F401
from ..source_control.models import Label, PullRequest # NOQA: F401
2 changes: 1 addition & 1 deletion reviews/source_control/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from github.PullRequest import PullRequest
from github.Repository import Repository

from reviews import config
from .. import config


class GithubAPI:
Expand Down
6 changes: 3 additions & 3 deletions reviews/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
from rich.live import Live
from rich.panel import Panel

from reviews import config
from reviews.controller import PullRequestController
from reviews.layout import (
from . import config
from .controller import PullRequestController
from .layout import (
RenderLayoutManager,
generate_layout,
generate_log_table,
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def _requires_from_file(filename):

setup(
name="reviews",
packages=find_namespace_packages(include=["reviews.*"]),
packages=find_namespace_packages(include=["*"]),
version="0.1.7",
license="MIT",
description=(
Expand All @@ -26,7 +26,7 @@ def _requires_from_file(filename):
download_url="https://pypi.org/project/reviews/",
keywords=["Reviews", "pull request review"],
install_requires=_requires_from_file("requirements.txt"),
entry_points={"console_scripts": ["reviews = cli:main"]},
entry_points={"console_scripts": ["reviews = reviews.cli.main:main"]},
classifiers=[
"Development Status :: 3 - Alpha",
"Environment :: Console",
Expand Down

0 comments on commit 7f19ab0

Please sign in to comment.