Skip to content
Open
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
24 changes: 8 additions & 16 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,19 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- name: Install and configure Poetry
# TODO: workaround for https://github.com/snok/install-poetry/issues/94
uses: snok/install-poetry@v1.3.4
- name: Install uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
version: 1.3.1
virtualenvs-in-project: true
version: "0.11.26"
enable-cache: true
- name: Install dependencies
run: poetry install
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: uv sync --locked
- name: Format check with black
run: |
source $VENV
make format-check
run: make format-check
- name: Typecheck with mypy
run: |
source $VENV
make typecheck
run: make typecheck
- name: Test with pytest (with coverage)
run: |
source $VENV
pytest tests -v --cov=./rich --cov-report=xml:./coverage.xml --cov-report term-missing
run: uv run pytest tests -v --cov=./rich --cov-report=xml:./coverage.xml --cov-report term-missing
- name: Upload code coverage
uses: codecov/codecov-action@v4
with:
Expand Down
7 changes: 4 additions & 3 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ build:

python:
install:
- requirements: docs/requirements.txt
- method: pip
path: .
- method: uv
command: sync
groups:
- docs
27 changes: 12 additions & 15 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,24 @@ See also [AI_POLICY.md](https://github.com/Textualize/rich/blob/master/AI_POLICY

## Prerequisites

Rich uses [poetry](https://python-poetry.org/docs/) for packaging and
dependency management. To start developing with Rich, install Poetry
using the [recommended method](https://python-poetry.org/docs/#installation).
Rich uses [uv](https://docs.astral.sh/uv/) for packaging and
dependency management. To start developing with Rich, install uv
using the [recommended method](https://docs.astral.sh/uv/getting-started/installation/).

Next, you'll need to create a _fork_ (your own personal copy) of the Rich repository, and clone that fork
on to your local machine. GitHub offers a great tutorial for this process [here](https://docs.github.com/en/get-started/quickstart/fork-a-repo).
After following this guide, you'll have a local copy of the Rich project installed.

Enter the directory containing your copy of Rich (`cd rich`).

Next create and activate a [virtual environment](https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/#create-and-use-virtual-environments) for Rich.

Now we can install the dependencies of Rich into the virtual environment:
Now we can create a virtual environment and install Rich's dependencies:

```
poetry install
uv sync
```

The rest of this guide assumes you're inside the virtual environment.
If you're having difficulty running any of the commands that follow,
ensure you're inside the virtual environment by running `poetry shell`.
The rest of this guide assumes commands are run through `uv run`, or inside
the virtual environment created by uv.

## Developing

Expand Down Expand Up @@ -60,7 +57,7 @@ make test
Or if you don't have `make`, run the following:

```
pytest --cov-report term-missing --cov=rich tests/ -vv
uv run pytest --cov-report term-missing --cov=rich tests/ -vv
```

New code should ideally have tests and not break existing tests.
Expand All @@ -81,7 +78,7 @@ make typecheck
Or if you don't have `make`:

```
mypy -p rich --config-file= --ignore-missing-imports --no-implicit-optional --warn-unreachable
uv run mypy -p rich --config-file= --ignore-missing-imports --no-implicit-optional --warn-unreachable
```

Please add type annotations for all new code, and ensure that type checking succeeds before creating a pull request.
Expand All @@ -99,13 +96,13 @@ and use `make format` to format and write to the files.
Consider whether the change you made would benefit from documentation - if the feature has any user impact at all, the answer is almost certainly yes!
Documentation can be found in the `docs` directory.
There are some additional dependencies required to build the documentation.
These dependencies can be installed by running (from the `docs` directory):
These dependencies can be installed by running:

```
pip install -r requirements.txt
uv sync --group docs
```

After updating the documentation, you can build them (from the project root directory) by running:
After updating the documentation, you can build them by running:

```
make docs
Expand Down
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
test:
TERM=unknown pytest --cov-report term-missing --cov=rich tests/ -vv
TERM=unknown uv run pytest --cov-report term-missing --cov=rich tests/ -vv
test-no-cov:
TERM=unknown pytest tests/ -vv
TERM=unknown uv run pytest tests/ -vv
format-check:
black --check .
uv run black --check .
format:
black .
uv run black .
typecheck:
mypy -p rich --no-incremental
uv run mypy -p rich --no-incremental
typecheck-report:
mypy -p rich --html-report mypy_report
uv run mypy -p rich --html-report mypy_report
.PHONY: docs
docs:
cd docs; make html
uv run --group docs sphinx-build -M html docs/source docs/build
5 changes: 2 additions & 3 deletions asv.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
"return-code=any python -mpip uninstall -y {project}"
],
"build_command": [
"pip install poetry",
"python setup.py build",
"PIP_NO_BUILD_ISOLATION=false python -mpip wheel --no-deps --no-index -w {build_cache_dir} {build_dir}"
"pip install uv",
"uv build --wheel --out-dir {build_cache_dir} {build_dir}"
],
"branches": [
"master"
Expand Down
4 changes: 0 additions & 4 deletions docs/requirements.txt

This file was deleted.

Loading
Loading