Skip to content

Commit 0f93ff8

Browse files
authored
switch to uv (#324)
1 parent 65713ea commit 0f93ff8

File tree

19 files changed

+1287
-340
lines changed

19 files changed

+1287
-340
lines changed

.github/workflows/ci.yml

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ on:
88
- '**'
99
pull_request: {}
1010

11+
env:
12+
COLUMNS: 120
13+
UV_PYTHON: 3.12
14+
UV_FROZEN: '1'
15+
1116
jobs:
1217
test:
1318
name: test ${{ matrix.python-version }}, rust ${{ matrix.rust-version }} on ${{ matrix.os }}
@@ -36,18 +41,16 @@ jobs:
3641
runs-on: ${{ matrix.os }}-latest
3742

3843
env:
39-
PYTHON: ${{ matrix.python-version }}
44+
UV_PYTHON: ${{ matrix.python-version }}
4045
RUST: ${{ matrix.rust-version }}
4146
OS: ${{ matrix.os }}
4247

4348
steps:
4449
- uses: actions/checkout@v4
4550

46-
- name: set up python
47-
uses: actions/setup-python@v5
51+
- uses: astral-sh/setup-uv@v5
4852
with:
49-
python-version: ${{ matrix.python-version }}
50-
allow-prereleases: true
53+
enable-cache: true
5154

5255
- name: install rust
5356
uses: actions-rs/toolchain@v1
@@ -59,11 +62,6 @@ jobs:
5962
- name: cache rust
6063
uses: Swatinem/rust-cache@v1
6164

62-
- run: pip install -r requirements/pyproject.txt -r requirements/testing.txt
63-
64-
- run: pip install -e .
65-
- run: pip freeze
66-
6765
- if: matrix.os == 'ubuntu'
6866
run: |
6967
mkdir -p ${{ github.workspace }}/protected
@@ -75,22 +73,22 @@ jobs:
7573
env:
7674
WATCHFILES_TEST_PERMISSION_DENIED_PATH: ${{ github.workspace }}/protected
7775

78-
- run: coverage xml
76+
- run: uv run coverage xml
7977

8078
- uses: codecov/[email protected]
8179
with:
8280
file: ./coverage.xml
83-
env_vars: PYTHON,RUST,OS
81+
env_vars: UV_PYTHON,RUST,OS
8482

8583
lint:
8684
runs-on: ubuntu-latest
8785

8886
steps:
8987
- uses: actions/checkout@v4
9088

91-
- uses: actions/setup-python@v5
89+
- uses: astral-sh/setup-uv@v5
9290
with:
93-
python-version: '3.10'
91+
enable-cache: true
9492

9593
- name: install rust
9694
uses: actions-rs/toolchain@v1
@@ -103,13 +101,11 @@ jobs:
103101
- name: cache rust
104102
uses: Swatinem/rust-cache@v1
105103

106-
- run: pip install -r requirements/pyproject.txt -r requirements/linting.txt
107-
108-
- run: pip install -e .
104+
- run: uv sync --group lint
109105

110106
- uses: pre-commit/[email protected]
111107
with:
112-
extra_args: --all-files
108+
extra_args: --all-files --verbose
113109
env:
114110
SKIP: no-commit-to-branch
115111

@@ -118,16 +114,13 @@ jobs:
118114
steps:
119115
- uses: actions/checkout@v4
120116

121-
- name: set up python
122-
uses: actions/setup-python@v5
117+
- uses: astral-sh/setup-uv@v5
123118
with:
124-
python-version: '3.10'
119+
enable-cache: true
125120

126-
- name: install
127-
run: pip install -r requirements/docs.txt
121+
- run: uv sync --group docs
128122

129-
- name: build site
130-
run: mkdocs build
123+
- run: make docs
131124

132125
- name: store docs site
133126
uses: actions/upload-artifact@v4

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ docs/_build/
1717
/watchfiles/*.so
1818
/target/
1919
/site/
20+
/.python-version

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ include = [
1414
"/src",
1515
"/watchfiles",
1616
"/tests",
17-
"/requirements",
17+
"/uv.lock",
1818
"/.cargo",
1919
"!__pycache__",
2020
"!tests/.mypy_cache",

Makefile

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,32 @@
11
.DEFAULT_GOAL := all
22

3-
.PHONY: install
4-
install:
5-
pip install -U pip pre-commit maturin
6-
pip install -r requirements/all.txt
7-
pip install -e .
8-
pre-commit install
3+
.PHONY: .uv
4+
.uv: ## Check that uv is installed
5+
@uv --version || echo 'Please install uv: https://docs.astral.sh/uv/getting-started/installation/'
6+
7+
.PHONY: .pre-commit
8+
.pre-commit: ## Check that pre-commit is installed
9+
@pre-commit -V || echo 'Please install pre-commit: https://pre-commit.com/'
910

10-
.PHONY: update-lockfiles
11-
update-lockfiles:
12-
@echo "Updating requirements files using pip-compile"
13-
pip-compile -q --strip-extras -o requirements/linting.txt requirements/linting.in
14-
pip-compile -q --strip-extras -c requirements/linting.txt -o requirements/pyproject.txt pyproject.toml
15-
pip-compile -q --strip-extras -c requirements/linting.txt -c requirements/pyproject.txt -o requirements/testing.txt requirements/testing.in
16-
pip-compile -q --strip-extras -c requirements/linting.txt -c requirements/pyproject.txt -c requirements/testing.txt -o requirements/docs.txt requirements/docs.in
17-
pip install --dry-run -r requirements/all.txt
11+
.PHONY: install
12+
install: .uv .pre-commit ## Install the package, dependencies, and pre-commit for local development
13+
uv sync --frozen --group lint --group docs
14+
pre-commit install --install-hooks
1815

1916
.PHONY: build-dev
2017
build-dev:
21-
maturin develop
18+
uv run maturin develop --uv
2219

2320
.PHONY: format
2421
format:
25-
ruff check --fix-only watchfiles tests
26-
ruff format watchfiles tests
27-
@echo 'max_width = 120' > .rustfmt.toml
22+
uv run ruff check --fix-only watchfiles tests
23+
uv run ruff format watchfiles tests
2824
cargo fmt
2925

3026
.PHONY: lint-python
3127
lint-python:
32-
ruff check watchfiles tests
33-
ruff format --check watchfiles tests
28+
uv run ruff check watchfiles tests
29+
uv run ruff format --check watchfiles tests
3430

3531
.PHONY: lint-rust
3632
lint-rust:
@@ -44,21 +40,21 @@ lint: lint-python lint-rust
4440

4541
.PHONY: mypy
4642
mypy:
47-
mypy watchfiles
43+
uv run mypy watchfiles
4844

4945
.PHONY: test
5046
test:
51-
coverage run -m pytest
47+
uv run coverage run -m pytest
5248

5349
.PHONY: testcov
5450
testcov: test
5551
@echo "building coverage html"
56-
@coverage html
52+
@uv run coverage html
5753

5854
.PHONY: docs
5955
docs:
6056
rm -f watchfiles/*.so
61-
mkdocs build
57+
uv run mkdocs build
6258

6359
.PHONY: all
6460
all: lint mypy testcov docs
File renamed without changes.

mkdocs.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,6 @@ plugins:
7878
merge_init_into_class: true
7979
show_signature_annotations: true
8080
separate_signature: true
81-
- mkdocs-simple-hooks:
82-
hooks:
83-
on_pre_build: 'docs.plugins:on_pre_build'
84-
on_files: 'docs.plugins:on_files'
85-
on_page_markdown: 'docs.plugins:on_page_markdown'
81+
82+
hooks:
83+
- 'docs/.hooks/main.py'

pyproject.toml

Lines changed: 76 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,117 @@
11
[build-system]
2-
requires = ['maturin>=0.14.16,<2']
3-
build-backend = 'maturin'
2+
requires = ["maturin>=0.14.16,<2"]
3+
build-backend = "maturin"
44

55
[project]
6-
name = 'watchfiles'
7-
requires-python = '>=3.9'
8-
description = 'Simple, modern and high performance file watching and code reload in python.'
6+
name = "watchfiles"
7+
requires-python = ">=3.9"
8+
description = "Simple, modern and high performance file watching and code reload in python."
99
authors = [
10-
{name ='Samuel Colvin', email = '[email protected]'},
10+
{name ="Samuel Colvin", email = "[email protected]"},
1111
]
1212
dependencies = [
13-
'anyio>=3.0.0',
13+
"anyio>=3.0.0",
1414
]
1515
classifiers = [
16-
'Development Status :: 5 - Production/Stable',
17-
'Environment :: Console',
18-
'Programming Language :: Python',
19-
'Programming Language :: Python :: 3',
20-
'Programming Language :: Python :: 3 :: Only',
21-
'Programming Language :: Python :: 3.9',
22-
'Programming Language :: Python :: 3.10',
23-
'Programming Language :: Python :: 3.11',
24-
'Programming Language :: Python :: 3.12',
25-
'Programming Language :: Python :: 3.13',
26-
'Intended Audience :: Developers',
27-
'Intended Audience :: Information Technology',
28-
'Intended Audience :: System Administrators',
29-
'License :: OSI Approved :: MIT License',
30-
'Operating System :: POSIX :: Linux',
31-
'Operating System :: Microsoft :: Windows',
32-
'Operating System :: MacOS',
33-
'Environment :: MacOS X',
34-
'Topic :: Software Development :: Libraries :: Python Modules',
35-
'Topic :: System :: Filesystems',
36-
'Framework :: AnyIO',
16+
"Development Status :: 5 - Production/Stable",
17+
"Environment :: Console",
18+
"Programming Language :: Python",
19+
"Programming Language :: Python :: 3",
20+
"Programming Language :: Python :: 3 :: Only",
21+
"Programming Language :: Python :: 3.9",
22+
"Programming Language :: Python :: 3.10",
23+
"Programming Language :: Python :: 3.11",
24+
"Programming Language :: Python :: 3.12",
25+
"Programming Language :: Python :: 3.13",
26+
"Intended Audience :: Developers",
27+
"Intended Audience :: Information Technology",
28+
"Intended Audience :: System Administrators",
29+
"License :: OSI Approved :: MIT License",
30+
"Operating System :: POSIX :: Linux",
31+
"Operating System :: Microsoft :: Windows",
32+
"Operating System :: MacOS",
33+
"Environment :: MacOS X",
34+
"Topic :: Software Development :: Libraries :: Python Modules",
35+
"Topic :: System :: Filesystems",
36+
"Framework :: AnyIO",
3737
]
3838
dynamic = [
39-
'license',
40-
'readme',
41-
'version'
39+
"license",
40+
"readme",
41+
"version"
4242
]
4343

4444
[project.scripts]
45-
watchfiles = 'watchfiles.cli:cli'
45+
watchfiles = "watchfiles.cli:cli"
4646

4747
[project.urls]
48-
Homepage = 'https://github.com/samuelcolvin/watchfiles'
49-
Documentation = 'https://watchfiles.helpmanual.io'
50-
Funding = 'https://github.com/sponsors/samuelcolvin'
51-
Source = 'https://github.com/samuelcolvin/watchfiles'
52-
Changelog = 'https://github.com/samuelcolvin/watchfiles/releases'
48+
Homepage = "https://github.com/samuelcolvin/watchfiles"
49+
Documentation = "https://watchfiles.helpmanual.io"
50+
Funding = "https://github.com/sponsors/samuelcolvin"
51+
Source = "https://github.com/samuelcolvin/watchfiles"
52+
Changelog = "https://github.com/samuelcolvin/watchfiles/releases"
53+
54+
[dependency-groups]
55+
dev = [
56+
"coverage>=7.6.10",
57+
"dirty-equals>=0.8.0",
58+
"maturin>=1.8.1",
59+
"pytest>=7.4.4",
60+
"pytest-mock>=3.14.0",
61+
"pytest-pretty>=1.2.0",
62+
"pytest-timeout>=2.3.1",
63+
]
64+
lint = [
65+
"mypy>=1.14.1",
66+
"ruff>=0.9.0",
67+
"trio>=0.28.0",
68+
]
69+
docs = [
70+
"mdx-include>=1.4.2",
71+
"mkdocs>=1.6.1",
72+
"mkdocs-material>=9.5.49",
73+
"mkdocstrings[python]>=0.25.1",
74+
]
5375

5476
[tool.maturin]
5577
module-name = "watchfiles._rust_notify"
56-
bindings = 'pyo3'
78+
bindings = "pyo3"
5779

5880
[tool.pytest.ini_options]
59-
testpaths = 'tests'
60-
log_format = '%(name)s %(levelname)s: %(message)s'
61-
filterwarnings = 'error'
81+
testpaths = "tests"
82+
log_format = "%(name)s %(levelname)s: %(message)s"
83+
filterwarnings = "error"
6284
timeout = 10
6385

6486
[tool.coverage.run]
65-
source = ['watchfiles']
87+
source = ["watchfiles"]
6688
branch = true
6789

6890
[tool.coverage.report]
6991
precision = 2
7092
exclude_lines = [
71-
'pragma: no cover',
72-
'raise NotImplementedError',
73-
'raise NotImplemented',
74-
'if TYPE_CHECKING:',
75-
'@overload',
93+
"pragma: no cover",
94+
"raise NotImplementedError",
95+
"raise NotImplemented",
96+
"if TYPE_CHECKING:",
97+
"@overload",
7698
]
77-
omit = ['*/__main__.py']
99+
omit = ["*/__main__.py"]
78100

79101
[tool.ruff]
80102
line-length = 120
81-
target-version = 'py38'
103+
target-version = "py38"
82104
lint.mccabe = { max-complexity = 14 }
83-
lint.extend-select = ['Q', 'RUF100', 'C90', 'UP', 'I']
84-
lint.flake8-quotes = {inline-quotes = 'single', multiline-quotes = 'double'}
85-
lint.pydocstyle = { convention = 'google' }
86-
format.quote-style = 'single'
105+
lint.extend-select = ["Q", "RUF100", "C90", "UP", "I"]
106+
lint.flake8-quotes = {inline-quotes = "single", multiline-quotes = "double"}
107+
lint.pydocstyle = { convention = "google" }
108+
format.quote-style = "single"
87109

88110
[tool.mypy]
89111
strict = true
90112
warn_return_any = false
91113
show_error_codes = true
92114

93115
[[tool.mypy.overrides]]
94-
module = ['trio.*']
116+
module = ["trio.*"]
95117
ignore_missing_imports = true

requirements/all.txt

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

requirements/docs.in

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

0 commit comments

Comments
 (0)