Skip to content

Commit

Permalink
Textual dev (#2884)
Browse files Browse the repository at this point in the history
* WiP: Move the devtools and related code to `textual-dev` (#2834)

* Remove the textual script from the project file

This is moving into the textual-dev package.

* Remove the textual CLI code from Textual

This has all gone to live in textual-dev.

* Remove the devtools testing from Textual's unit tests

They've moved over to textual-dev instead.

* Remove the devtools server from Textual itself

The start of the process to remove as much of the core devtools as possible
from Textual.

* Switch the console docs example screenshot over to textual_dev

* Remove rednerables.py from Textual

* Remove the last parts of devtools from Textual

This is the last step. It remains to be seen if this is sustainable, but for
testing purposes this is the extreme case we're aiming for. I *think* this
will work though.

Hereon we'll be needing to do an editable install of textual-dev into
textual, and more generally and once this is "live" we'll be needing to make
sure that textual[dev] is installed when doing development work on textual
apps.

The thing that remains to be seen however is how this all works
with *developing* Textual itself. Will I always need to do an editable
install? Still got to figure that one out.

* Start to whittle down the pyproject file

The next step is to try and work out what can come out of the pyproject
file.

* Remove aiohttp from Textual

* Remove some more development dependencies we don't need any more

* Relock

* Remove the pointer to the previews directory

* Reintroduce the border preview snapshot test

* Reintroduce the color preview snapshot test

* Reinstate the key press for the border preview snapshot test

* Reintroduce the easing preview snapshot test

* Reintroduce the keys tool snapshot test

* Add pytest-asyncio as a development dependency

* Relock

* Pin the textual-dev version to 0.1.0 or later

Mostly to try and get the tests kicked off properly.

* Relock dependencies

* Further `textual-dev` changes (#2850)

* Remove the textual script from the project file

This is moving into the textual-dev package.

* Remove the textual CLI code from Textual

This has all gone to live in textual-dev.

* Remove the devtools testing from Textual's unit tests

They've moved over to textual-dev instead.

* Remove the devtools server from Textual itself

The start of the process to remove as much of the core devtools as possible
from Textual.

* Switch the console docs example screenshot over to textual_dev

* Remove rednerables.py from Textual

* Remove the last parts of devtools from Textual

This is the last step. It remains to be seen if this is sustainable, but for
testing purposes this is the extreme case we're aiming for. I *think* this
will work though.

Hereon we'll be needing to do an editable install of textual-dev into
textual, and more generally and once this is "live" we'll be needing to make
sure that textual[dev] is installed when doing development work on textual
apps.

The thing that remains to be seen however is how this all works
with *developing* Textual itself. Will I always need to do an editable
install? Still got to figure that one out.

* Start to whittle down the pyproject file

The next step is to try and work out what can come out of the pyproject
file.

* Remove aiohttp from Textual

* Remove some more development dependencies we don't need any more

* Relock

* Remove the pointer to the previews directory

* Reintroduce the border preview snapshot test

* Reintroduce the color preview snapshot test

* Reinstate the key press for the border preview snapshot test

* Reintroduce the easing preview snapshot test

* Reintroduce the keys tool snapshot test

* Add pytest-asyncio as a development dependency

* Relock

* Pin the textual-dev version to 0.1.0 or later

Mostly to try and get the tests kicked off properly.

* Relock dependencies

* Whitespace cleaning

* Swap mentions of textual[dev] to textual-dev

* Remove the dev extra

* Tweak README.md in response to PR review

* Tweak animation.md in response to PR review

* Tweak getting_started.md in response to PR review

* bump version

* lock

* drop dev

* more

* version bump

---------

Co-authored-by: Dave Pearson <[email protected]>
  • Loading branch information
willmcgugan and davep authored Jul 3, 2023
1 parent 6b3b1ce commit 65e81c5
Show file tree
Hide file tree
Showing 45 changed files with 2,093 additions and 4,621 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
path: .venv
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
run: poetry install --extras "dev"
run: poetry install
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
# - name: Typecheck with mypy
# run: |
Expand Down
6 changes: 2 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased

## [0.29.0] - 2023-07-03

### Added

Expand All @@ -15,14 +14,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Added `default` parameter to `DataTable.add_column` for populating existing rows https://github.com/Textualize/textual/pull/2836
- Added can-focus pseudo-class to target widgets that may receive focus


### Fixed

- Fixed crash when columns were added to populated `DataTable` https://github.com/Textualize/textual/pull/2836
- Fixed issues with opacity on Screens https://github.com/Textualize/textual/issues/2616
- Fixed style problem with selected selections in a non-focused selection list https://github.com/Textualize/textual/issues/2768


## [0.28.1] - 2023-06-20

### Fixed
Expand Down Expand Up @@ -1098,6 +1095,7 @@ https://textual.textualize.io/blog/2022/11/08/version-040/#version-040
- New handler system for messages that doesn't require inheritance
- Improved traceback handling

[0.29.0]: https://github.com/Textualize/textual/compare/v0.28.1...v0.29.0
[0.28.1]: https://github.com/Textualize/textual/compare/v0.28.0...v0.28.1
[0.28.0]: https://github.com/Textualize/textual/compare/v0.27.0...v0.28.0
[0.27.0]: https://github.com/Textualize/textual/compare/v0.26.0...v0.27.0
Expand Down
2 changes: 1 addition & 1 deletion FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ You likely have an older version of Textual. You can install the latest version
The following should do it:

```
pip install "textual[dev]" -U
pip install textual-dev -U
```

<a name="how-can-i-select-and-copy-text-in-a-textual-app"></a>
Expand Down
49 changes: 27 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ Textual is a *Rapid Application Development* framework for Python.
Build sophisticated user interfaces with a simple Python API. Run your apps in the terminal and (coming soon) a web browser!


<details>
<details>
<summary> 🎬 Demonstration </summary>
<hr>

A quick run through of some Textual features.



https://user-images.githubusercontent.com/554369/197355913-65d3c125-493d-4c05-a590-5311f16c40ff.mov
Expand All @@ -32,7 +32,7 @@ https://user-images.githubusercontent.com/554369/197355913-65d3c125-493d-4c05-a5

Textual adds interactivity to [Rich](https://github.com/Textualize/rich) with an API inspired by modern web development.

On modern terminal software (installed by default on most systems), Textual apps can use **16.7 million** colors with mouse support and smooth flicker-free animation. A powerful layout engine and re-usable components makes it possible to build apps that rival the desktop and web experience.
On modern terminal software (installed by default on most systems), Textual apps can use **16.7 million** colors with mouse support and smooth flicker-free animation. A powerful layout engine and re-usable components makes it possible to build apps that rival the desktop and web experience.

## Compatibility

Expand All @@ -43,10 +43,16 @@ Textual runs on Linux, macOS, and Windows. Textual requires Python 3.7 or above.
Install Textual via pip:

```
pip install "textual[dev]"
pip install textual
```

If you plan on developing Textual apps, you should also install the development tools with the following command:

```
pip install textual-dev
```

The addition of `[dev]` installs Textual development tools. See the [docs](https://textual.textualize.io/getting_started/) if you need help getting started.
See the [docs](https://textual.textualize.io/getting_started/) if you need help getting started.

## Demo

Expand Down Expand Up @@ -82,12 +88,12 @@ https://user-images.githubusercontent.com/554369/197188237-88d3f7e4-4e5f-40b5-b9
</details>


<details>
<details>
<summary> 📷 Calculator </summary>
<hr>

This is [calculator.py](https://github.com/Textualize/textual/blob/main/examples/calculator.py) which demonstrates Textual grid layouts.

![calculator screenshot](https://raw.githubusercontent.com/Textualize/textual/main/imgs/calculator.png)
</details>

Expand All @@ -97,7 +103,7 @@ This is [calculator.py](https://github.com/Textualize/textual/blob/main/examples
<hr>

This is the Stopwatch example from the [tutorial](https://textual.textualize.io/tutorial/).



https://user-images.githubusercontent.com/554369/197360718-0c834ef5-6285-4d37-85cf-23eed4aa56c5.mov
Expand All @@ -112,12 +118,12 @@ https://user-images.githubusercontent.com/554369/197360718-0c834ef5-6285-4d37-85

The `textual` command has a few sub-commands to preview Textual styles.

<details>
<details>
<summary> 🎬 Easing reference </summary>
<hr>

This is the *easing* reference which demonstrates the easing parameter on animation, with both movement and opacity. You can run it with the following command:

```bash
textual easing
```
Expand All @@ -128,29 +134,29 @@ https://user-images.githubusercontent.com/554369/196157100-352852a6-2b09-4dc8-a8

</details>

<details>
<details>
<summary> 🎬 Borders reference </summary>
<hr>

This is the borders reference which demonstrates some of the borders styles in Textual. You can run it with the following command:

```bash
textual borders
```


https://user-images.githubusercontent.com/554369/196158235-4b45fb78-053d-4fd5-b285-e09b4f1c67a8.mov


</details>


<details>
<details>
<summary> 🎬 Colors reference </summary>
<hr>

This is a reference for Textual's color design system.

```bash
textual colors
```
Expand All @@ -161,6 +167,5 @@ https://user-images.githubusercontent.com/554369/197357417-2d407aac-8969-44d3-82




</details>

</details>
31 changes: 31 additions & 0 deletions docs/blog/posts/release0-29-0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
draft: false
date: 2023-07-03
categories:
- Release
title: "Textual 0.27.0 refactors dev tools"
authors:
- willmcgugan
---

# Textual 0.27.0 refactors dev tools

It's been a slow week or two at Textualize, with Textual devs taking well-earned annual leave, but we still managed to get a new version out.

<!-- more -->

Version 0.27.0 has shipped with a number of fixes (see the [release notes](https://github.com/Textualize/textual/releases/tag/v0.29.0) for details), but I'd like to use this post to explain a change we made to how Textual developer tools are distributed.

Previously if you installed `textual[dev]` you would get the Textual dev tools plus the library itself. If you were distributing Textual apps and didn't need the developer tools you could drop the `[dev]`.

We did this because the less dependencies a package has, the fewer installation issues you can expect to get in the future. And Textual is surprisingly lean if you only need to *run* apps, and not build them.

Alas, this wasn't quite as elegant solution as we hoped. The dependencies defined in extras wouldn't install commands, so `textual` was bundled with the core library. This meant that if you installed the Textual package *without* the `[dev]` you would still get the `textual` command on your path but it wouldn't run.

We solved this by creating two packages: `textual` contains the core library (with minimal dependencies) and `textual-dev` contains the developer tools. If you are building Textual apps, you should install both as follows:

```
pip install textual textual-dev
```

That's the only difference. If you run in to any issues feel free to ask on the [Discord server](https://discord.gg/Enf6Z3qhVr)!
3 changes: 2 additions & 1 deletion docs/examples/getting_started/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
Simulates a screenshot of the Textual devtools
"""

from textual_dev.renderables import DevConsoleHeader

from textual.app import App
from textual.devtools.renderables import DevConsoleHeader
from textual.widgets import Static


Expand Down
28 changes: 14 additions & 14 deletions docs/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,28 @@ Textual requires Python 3.7 or later (if you have a choice, pick the most recent

## Installation

You can install Textual via PyPI.

If you plan on developing Textual apps, then you should install `textual[dev]`. The `[dev]` part installs a few extra dependencies for development.
You can install Textual via PyPI, with the following command:

```
pip install "textual[dev]"
pip install textual
```

If you only plan on _running_ Textual apps, then you can drop the `[dev]` part:
If you plan on developing Textual apps, you should also install textual developer tools:

```
pip install textual
pip install textual-dev
```

### Textual CLI

If you installed the developer tools you should have access to the `textual` command. There are a number of sub-commands available which will aid you in building Textual apps. Run the following for a list of the available commands:

```bash
textual --help
```

See [devtools](guide/devtools.md) for more about the `textual` command.

## Demo

Once you have Textual installed, run the following to get an impression of what it can do:
Expand Down Expand Up @@ -79,15 +87,7 @@ python code_browser.py ../
```


## Textual CLI

If you installed the dev dependencies you have access to the `textual` CLI command. There are a number of sub-commands which will aid you in building Textual apps.

```bash
textual --help
```

See [devtools](guide/devtools.md) for more about the `textual` command.

## Need help?

Expand Down
2 changes: 1 addition & 1 deletion docs/guide/animation.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ You can specify which easing method to use via the `easing` parameter on the `an

!!! note

The `textual easing` preview requires the `dev` extras to be installed (using `pip install textual[dev]`).
The `textual easing` preview requires the `textual-dev` package to be installed (using `pip install textual-dev`).


## Completion callbacks
Expand Down
Loading

0 comments on commit 65e81c5

Please sign in to comment.