Skip to content

Commit 8011785

Browse files
committed
Migrate packaging to uv
1 parent 9d8f9a3 commit 8011785

11 files changed

Lines changed: 1938 additions & 1146 deletions

File tree

.github/workflows/pythonpackage.yml

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,19 @@ jobs:
2222
with:
2323
python-version: ${{ matrix.python-version }}
2424
allow-prereleases: true
25-
- name: Install and configure Poetry
26-
# TODO: workaround for https://github.com/snok/install-poetry/issues/94
27-
uses: snok/install-poetry@v1.3.4
25+
- name: Install uv
26+
uses: astral-sh/setup-uv@v6
2827
with:
29-
version: 1.3.1
30-
virtualenvs-in-project: true
28+
version: "0.11.26"
29+
enable-cache: true
3130
- name: Install dependencies
32-
run: poetry install
33-
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
31+
run: uv sync --locked
3432
- name: Format check with black
35-
run: |
36-
source $VENV
37-
make format-check
33+
run: make format-check
3834
- name: Typecheck with mypy
39-
run: |
40-
source $VENV
41-
make typecheck
35+
run: make typecheck
4236
- name: Test with pytest (with coverage)
43-
run: |
44-
source $VENV
45-
pytest tests -v --cov=./rich --cov-report=xml:./coverage.xml --cov-report term-missing
37+
run: uv run pytest tests -v --cov=./rich --cov-report=xml:./coverage.xml --cov-report term-missing
4638
- name: Upload code coverage
4739
uses: codecov/codecov-action@v4
4840
with:

.readthedocs.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ build:
1818

1919
python:
2020
install:
21-
- requirements: docs/requirements.txt
22-
- method: pip
23-
path: .
21+
- method: uv
22+
command: sync
23+
groups:
24+
- docs

CONTRIBUTING.md

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,24 @@ See also [AI_POLICY.md](https://github.com/Textualize/rich/blob/master/AI_POLICY
1010

1111
## Prerequisites
1212

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

1717
Next, you'll need to create a _fork_ (your own personal copy) of the Rich repository, and clone that fork
1818
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).
1919
After following this guide, you'll have a local copy of the Rich project installed.
2020

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

23-
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.
24-
25-
Now we can install the dependencies of Rich into the virtual environment:
23+
Now we can create a virtual environment and install Rich's dependencies:
2624

2725
```
28-
poetry install
26+
uv sync
2927
```
3028

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

3532
## Developing
3633

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

6259
```
63-
pytest --cov-report term-missing --cov=rich tests/ -vv
60+
uv run pytest --cov-report term-missing --cov=rich tests/ -vv
6461
```
6562

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

8380
```
84-
mypy -p rich --config-file= --ignore-missing-imports --no-implicit-optional --warn-unreachable
81+
uv run mypy -p rich --config-file= --ignore-missing-imports --no-implicit-optional --warn-unreachable
8582
```
8683

8784
Please add type annotations for all new code, and ensure that type checking succeeds before creating a pull request.
@@ -99,13 +96,13 @@ and use `make format` to format and write to the files.
9996
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!
10097
Documentation can be found in the `docs` directory.
10198
There are some additional dependencies required to build the documentation.
102-
These dependencies can be installed by running (from the `docs` directory):
99+
These dependencies can be installed by running:
103100

104101
```
105-
pip install -r requirements.txt
102+
uv sync --group docs
106103
```
107104

108-
After updating the documentation, you can build them (from the project root directory) by running:
105+
After updating the documentation, you can build them by running:
109106

110107
```
111108
make docs

Makefile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
test:
2-
TERM=unknown pytest --cov-report term-missing --cov=rich tests/ -vv
2+
TERM=unknown uv run pytest --cov-report term-missing --cov=rich tests/ -vv
33
test-no-cov:
4-
TERM=unknown pytest tests/ -vv
4+
TERM=unknown uv run pytest tests/ -vv
55
format-check:
6-
black --check .
6+
uv run black --check .
77
format:
8-
black .
8+
uv run black .
99
typecheck:
10-
mypy -p rich --no-incremental
10+
uv run mypy -p rich --no-incremental
1111
typecheck-report:
12-
mypy -p rich --html-report mypy_report
12+
uv run mypy -p rich --html-report mypy_report
1313
.PHONY: docs
1414
docs:
15-
cd docs; make html
15+
uv run --group docs sphinx-build -M html docs/source docs/build

asv.conf.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@
1111
"return-code=any python -mpip uninstall -y {project}"
1212
],
1313
"build_command": [
14-
"pip install poetry",
15-
"python setup.py build",
16-
"PIP_NO_BUILD_ISOLATION=false python -mpip wheel --no-deps --no-index -w {build_cache_dir} {build_dir}"
14+
"pip install uv",
15+
"uv build --wheel --out-dir {build_cache_dir} {build_dir}"
1716
],
1817
"branches": [
1918
"master"

docs/requirements.txt

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)