Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make devtools deps extras, add note to internal ref docs, raise excep… #579

Merged
merged 6 commits into from
Jun 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
version: 1.1.6
virtualenvs-in-project: true
- name: Install dependencies
run: poetry install
run: poetry install --extras "dev"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
- name: Format check with black
run: |
Expand Down
105 changes: 54 additions & 51 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,16 @@ textual = "textual.cli.cli:run"
python = "^3.7"
rich = "^12.4.3"
#rich = {path="../rich", develop=true}
click = "8.1.2"
importlib-metadata = "^4.11.3"
typing-extensions = { version = "^4.0.0", python = "<3.8" }
msgpack = "^1.0.3"

# Dependencies below are required for devtools only
aiohttp = { version = "^3.8.1", optional = true }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@willmcgugan Do we move click into the dev extras too?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so. Is it possible to install the textual command only with dev extras?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand the question, but I don't believe you can install only the extras.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should only install the textual CLI when you pip install textual[dev]. Because we don't need it just to distribute apps. Is that possible?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe so. Think we'd have to distribute the devtools as a separate package.

click = {version = "8.1.2", optional = true}
msgpack = { version = "^1.0.3", optional = true }

[tool.poetry.extras]
dev = ["aiohttp", "click", "msgpack"]

[tool.poetry.dev-dependencies]
pytest = "^6.2.3"
Expand Down
14 changes: 14 additions & 0 deletions reference/_devtools.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Devtools
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are more just notes to remind us what to include in the docs when the structure is in place. They're not the final docs.


## Installation

Using the Textual Devtools requires installation of the `dev` extra dependency.

https://python-poetry.org/docs/pyproject/#extras

## Running

TODO: Note how we run the devtools themselves and how we run our Textual apps
such that they can connect. Don't forget Windows instructions :)
We might also add a link to the documentation from the exception that gets
raised when the "dev" extra dependencies aren't installed.
4 changes: 1 addition & 3 deletions src/textual/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from rich.console import Console, RenderableType
from rich.measure import Measurement
from rich.protocol import is_renderable
from rich.segment import Segments, SegmentLines
from rich.segment import Segments
from rich.traceback import Traceback

from . import actions
Expand All @@ -47,7 +47,6 @@
from ._event_broker import extract_handler_actions, NoHandler
from .binding import Bindings, NoBinding
from .css.stylesheet import Stylesheet
from .css.styles import RenderStyles
from .css.query import NoMatchingNodesError
from .design import ColorSystem
from .devtools.client import DevtoolsClient, DevtoolsConnectionError, DevtoolsLog
Expand All @@ -61,7 +60,6 @@
from .message_pump import MessagePump
from .reactive import Reactive
from .renderables.blank import Blank
from ._profile import timer

from .screen import Screen
from .widget import Widget
Expand Down
22 changes: 19 additions & 3 deletions src/textual/devtools/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,35 @@
import asyncio
import inspect
import json
import msgpack

import pickle
from time import time
from asyncio import Queue, Task, QueueFull
from io import StringIO
from typing import Type, Any, NamedTuple

import aiohttp
from aiohttp import ClientResponseError, ClientConnectorError, ClientWebSocketResponse
from rich.console import Console
from rich.segment import Segment


class DevtoolsDependenciesMissingError(Exception):
"""Raise when the required devtools dependencies are not installed in the environment"""


try:
import aiohttp
from aiohttp import (
ClientResponseError,
ClientConnectorError,
ClientWebSocketResponse,
)
import msgpack
except ImportError:
# TODO: Add link to documentation on how to install devtools
raise DevtoolsDependenciesMissingError(
"Textual Devtools requires installation of the 'dev' extra dependencies. "
darrenburns marked this conversation as resolved.
Show resolved Hide resolved
)

DEVTOOLS_PORT = 8081
WEBSOCKET_CONNECT_TIMEOUT = 3
LOG_QUEUE_MAXSIZE = 512
Expand Down