Skip to content

Commit

Permalink
switch to uv (#324)
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelcolvin authored Jan 10, 2025
1 parent 65713ea commit 0f93ff8
Show file tree
Hide file tree
Showing 19 changed files with 1,287 additions and 340 deletions.
43 changes: 18 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ on:
- '**'
pull_request: {}

env:
COLUMNS: 120
UV_PYTHON: 3.12
UV_FROZEN: '1'

jobs:
test:
name: test ${{ matrix.python-version }}, rust ${{ matrix.rust-version }} on ${{ matrix.os }}
Expand Down Expand Up @@ -36,18 +41,16 @@ jobs:
runs-on: ${{ matrix.os }}-latest

env:
PYTHON: ${{ matrix.python-version }}
UV_PYTHON: ${{ matrix.python-version }}
RUST: ${{ matrix.rust-version }}
OS: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4

- name: set up python
uses: actions/setup-python@v5
- uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
enable-cache: true

- name: install rust
uses: actions-rs/toolchain@v1
Expand All @@ -59,11 +62,6 @@ jobs:
- name: cache rust
uses: Swatinem/rust-cache@v1

- run: pip install -r requirements/pyproject.txt -r requirements/testing.txt

- run: pip install -e .
- run: pip freeze

- if: matrix.os == 'ubuntu'
run: |
mkdir -p ${{ github.workspace }}/protected
Expand All @@ -75,22 +73,22 @@ jobs:
env:
WATCHFILES_TEST_PERMISSION_DENIED_PATH: ${{ github.workspace }}/protected

- run: coverage xml
- run: uv run coverage xml

- uses: codecov/[email protected]
with:
file: ./coverage.xml
env_vars: PYTHON,RUST,OS
env_vars: UV_PYTHON,RUST,OS

lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
- uses: astral-sh/setup-uv@v5
with:
python-version: '3.10'
enable-cache: true

- name: install rust
uses: actions-rs/toolchain@v1
Expand All @@ -103,13 +101,11 @@ jobs:
- name: cache rust
uses: Swatinem/rust-cache@v1

- run: pip install -r requirements/pyproject.txt -r requirements/linting.txt

- run: pip install -e .
- run: uv sync --group lint

- uses: pre-commit/[email protected]
with:
extra_args: --all-files
extra_args: --all-files --verbose
env:
SKIP: no-commit-to-branch

Expand All @@ -118,16 +114,13 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: set up python
uses: actions/setup-python@v5
- uses: astral-sh/setup-uv@v5
with:
python-version: '3.10'
enable-cache: true

- name: install
run: pip install -r requirements/docs.txt
- run: uv sync --group docs

- name: build site
run: mkdocs build
- run: make docs

- name: store docs site
uses: actions/upload-artifact@v4
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ docs/_build/
/watchfiles/*.so
/target/
/site/
/.python-version
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ include = [
"/src",
"/watchfiles",
"/tests",
"/requirements",
"/uv.lock",
"/.cargo",
"!__pycache__",
"!tests/.mypy_cache",
Expand Down
44 changes: 20 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,36 +1,32 @@
.DEFAULT_GOAL := all

.PHONY: install
install:
pip install -U pip pre-commit maturin
pip install -r requirements/all.txt
pip install -e .
pre-commit install
.PHONY: .uv
.uv: ## Check that uv is installed
@uv --version || echo 'Please install uv: https://docs.astral.sh/uv/getting-started/installation/'

.PHONY: .pre-commit
.pre-commit: ## Check that pre-commit is installed
@pre-commit -V || echo 'Please install pre-commit: https://pre-commit.com/'

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

.PHONY: build-dev
build-dev:
maturin develop
uv run maturin develop --uv

.PHONY: format
format:
ruff check --fix-only watchfiles tests
ruff format watchfiles tests
@echo 'max_width = 120' > .rustfmt.toml
uv run ruff check --fix-only watchfiles tests
uv run ruff format watchfiles tests
cargo fmt

.PHONY: lint-python
lint-python:
ruff check watchfiles tests
ruff format --check watchfiles tests
uv run ruff check watchfiles tests
uv run ruff format --check watchfiles tests

.PHONY: lint-rust
lint-rust:
Expand All @@ -44,21 +40,21 @@ lint: lint-python lint-rust

.PHONY: mypy
mypy:
mypy watchfiles
uv run mypy watchfiles

.PHONY: test
test:
coverage run -m pytest
uv run coverage run -m pytest

.PHONY: testcov
testcov: test
@echo "building coverage html"
@coverage html
@uv run coverage html

.PHONY: docs
docs:
rm -f watchfiles/*.so
mkdocs build
uv run mkdocs build

.PHONY: all
all: lint mypy testcov docs
Expand Down
File renamed without changes.
8 changes: 3 additions & 5 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ plugins:
merge_init_into_class: true
show_signature_annotations: true
separate_signature: true
- mkdocs-simple-hooks:
hooks:
on_pre_build: 'docs.plugins:on_pre_build'
on_files: 'docs.plugins:on_files'
on_page_markdown: 'docs.plugins:on_page_markdown'

hooks:
- 'docs/.hooks/main.py'
130 changes: 76 additions & 54 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,95 +1,117 @@
[build-system]
requires = ['maturin>=0.14.16,<2']
build-backend = 'maturin'
requires = ["maturin>=0.14.16,<2"]
build-backend = "maturin"

[project]
name = 'watchfiles'
requires-python = '>=3.9'
description = 'Simple, modern and high performance file watching and code reload in python.'
name = "watchfiles"
requires-python = ">=3.9"
description = "Simple, modern and high performance file watching and code reload in python."
authors = [
{name ='Samuel Colvin', email = '[email protected]'},
{name ="Samuel Colvin", email = "[email protected]"},
]
dependencies = [
'anyio>=3.0.0',
"anyio>=3.0.0",
]
classifiers = [
'Development Status :: 5 - Production/Stable',
'Environment :: Console',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: 3.13',
'Intended Audience :: Developers',
'Intended Audience :: Information Technology',
'Intended Audience :: System Administrators',
'License :: OSI Approved :: MIT License',
'Operating System :: POSIX :: Linux',
'Operating System :: Microsoft :: Windows',
'Operating System :: MacOS',
'Environment :: MacOS X',
'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: System :: Filesystems',
'Framework :: AnyIO',
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Intended Audience :: Developers",
"Intended Audience :: Information Technology",
"Intended Audience :: System Administrators",
"License :: OSI Approved :: MIT License",
"Operating System :: POSIX :: Linux",
"Operating System :: Microsoft :: Windows",
"Operating System :: MacOS",
"Environment :: MacOS X",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: System :: Filesystems",
"Framework :: AnyIO",
]
dynamic = [
'license',
'readme',
'version'
"license",
"readme",
"version"
]

[project.scripts]
watchfiles = 'watchfiles.cli:cli'
watchfiles = "watchfiles.cli:cli"

[project.urls]
Homepage = 'https://github.com/samuelcolvin/watchfiles'
Documentation = 'https://watchfiles.helpmanual.io'
Funding = 'https://github.com/sponsors/samuelcolvin'
Source = 'https://github.com/samuelcolvin/watchfiles'
Changelog = 'https://github.com/samuelcolvin/watchfiles/releases'
Homepage = "https://github.com/samuelcolvin/watchfiles"
Documentation = "https://watchfiles.helpmanual.io"
Funding = "https://github.com/sponsors/samuelcolvin"
Source = "https://github.com/samuelcolvin/watchfiles"
Changelog = "https://github.com/samuelcolvin/watchfiles/releases"

[dependency-groups]
dev = [
"coverage>=7.6.10",
"dirty-equals>=0.8.0",
"maturin>=1.8.1",
"pytest>=7.4.4",
"pytest-mock>=3.14.0",
"pytest-pretty>=1.2.0",
"pytest-timeout>=2.3.1",
]
lint = [
"mypy>=1.14.1",
"ruff>=0.9.0",
"trio>=0.28.0",
]
docs = [
"mdx-include>=1.4.2",
"mkdocs>=1.6.1",
"mkdocs-material>=9.5.49",
"mkdocstrings[python]>=0.25.1",
]

[tool.maturin]
module-name = "watchfiles._rust_notify"
bindings = 'pyo3'
bindings = "pyo3"

[tool.pytest.ini_options]
testpaths = 'tests'
log_format = '%(name)s %(levelname)s: %(message)s'
filterwarnings = 'error'
testpaths = "tests"
log_format = "%(name)s %(levelname)s: %(message)s"
filterwarnings = "error"
timeout = 10

[tool.coverage.run]
source = ['watchfiles']
source = ["watchfiles"]
branch = true

[tool.coverage.report]
precision = 2
exclude_lines = [
'pragma: no cover',
'raise NotImplementedError',
'raise NotImplemented',
'if TYPE_CHECKING:',
'@overload',
"pragma: no cover",
"raise NotImplementedError",
"raise NotImplemented",
"if TYPE_CHECKING:",
"@overload",
]
omit = ['*/__main__.py']
omit = ["*/__main__.py"]

[tool.ruff]
line-length = 120
target-version = 'py38'
target-version = "py38"
lint.mccabe = { max-complexity = 14 }
lint.extend-select = ['Q', 'RUF100', 'C90', 'UP', 'I']
lint.flake8-quotes = {inline-quotes = 'single', multiline-quotes = 'double'}
lint.pydocstyle = { convention = 'google' }
format.quote-style = 'single'
lint.extend-select = ["Q", "RUF100", "C90", "UP", "I"]
lint.flake8-quotes = {inline-quotes = "single", multiline-quotes = "double"}
lint.pydocstyle = { convention = "google" }
format.quote-style = "single"

[tool.mypy]
strict = true
warn_return_any = false
show_error_codes = true

[[tool.mypy.overrides]]
module = ['trio.*']
module = ["trio.*"]
ignore_missing_imports = true
4 changes: 0 additions & 4 deletions requirements/all.txt

This file was deleted.

5 changes: 0 additions & 5 deletions requirements/docs.in

This file was deleted.

Loading

0 comments on commit 0f93ff8

Please sign in to comment.