Skip to content

Commit

Permalink
Merge pull request #42 from jorenham/uv
Browse files Browse the repository at this point in the history
Migrate from poetry to uv
  • Loading branch information
KotlinIsland authored Sep 17, 2024
2 parents 4298079 + eea18e9 commit 8df78e0
Show file tree
Hide file tree
Showing 7 changed files with 732 additions and 870 deletions.
79 changes: 27 additions & 52 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
VERSION_UV: '0.4.10'

jobs:
lint:
timeout-minutes: 5
Expand All @@ -20,94 +23,66 @@ jobs:
- name: checkout
uses: actions/checkout@v4

- name: install poetry
run: pipx install poetry
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: ${{ env.VERSION_UV }}
enable-cache: true

- name: setup python
uses: actions/setup-python@v5
with:
python-version: 3.8
cache: poetry
run: uv python install 3.8

- name: install
run: poetry install
- name: uv sync
run: uv sync --frozen

- name: codespell
run: poetry run codespell .
run: uv run codespell .

- name: ruff check
run: poetry run ruff check --output-format=github
run: uv run ruff check --output-format=github

- name: markdownlint
uses: DavidAnson/markdownlint-cli2-action@v16
uses: DavidAnson/markdownlint-cli2-action@v17
with:
config: ".markdownlint.yaml"
globs: "**/*.md"
globs: "*.md"

- name: repo-review
uses: scientific-python/[email protected]
with:
plugins: sp-repo-review

typecheck:
timeout-minutes: 5
runs-on: ubuntu-latest

strategy:
matrix:
python-version: ["3.8", "3.12", "3.13-dev"]

steps:
- name: checkout
uses: actions/checkout@v4

- name: install poetry
run: |
pipx install poetry
poetry config virtualenvs.create true --local
poetry config virtualenvs.in-project true --local
- name: setup python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: poetry

- name: install
run: poetry install

- name: basedpyright
run: poetry run basedpyright
run: uv run basedpyright

- name: basedpyright --verifytypes
run: poetry run basedpyright --ignoreexternal --verifytypes mainpy
run: uv run basedpyright --ignoreexternal --verifytypes mainpy

test:
timeout-minutes: 5

strategy:
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ["3.8", "3.12", "3.13-dev"]
python-version: ["3.8", "3.12", "3.13"]

runs-on: ${{ matrix.os }}

steps:
- name: checkout
uses: actions/checkout@v4

- name: install poetry
run: pipx install poetry
- name: setup uv
uses: astral-sh/setup-uv@v3
with:
version: ${{ env.VERSION_UV }}
enable-cache: true

- name: setup python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: poetry
run: uv python install ${{ matrix.python-version }}

- name: install
run: poetry install --extras uvloop --with test-github --sync
- name: uv sync
run: uv sync --frozen

- name: pytest
run: poetry run pytest
run: uv run pytest
9 changes: 2 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ repos:
hooks:
- id: markdownlint

- repo: https://github.com/python-poetry/poetry
rev: 1.8.3
hooks:
- id: poetry-check

- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
Expand All @@ -68,13 +63,13 @@ repos:
hooks:
- id: basedpyright
name: basedpyright
entry: poetry run basedpyright
entry: uv run basedpyright
language: system
types_or: [python, pyi]

- id: basedpyright-verifytypes
name: basedpyright --verifytypes
entry: poetry run basedpyright --ignoreexternal --verifytypes mainpy
entry: uv run basedpyright --ignoreexternal --verifytypes mainpy
language: system
always_run: true
pass_filenames: false
33 changes: 9 additions & 24 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,19 +176,15 @@ which could serve as inspiration.

### Your First Code Contribution

Ensure you have [poetry](https://python-poetry.org/docs/#installation)
installed.
It can help to use mainpy's lowest-supported Python version, so that you don't
accidentally use those bleeding-edge Python features that you shouldn't, e.g.
Ensure you have [uv](https://github.com/astral-sh/uv) installed.
It can help to use mainpy's lowest-supported Python version (3.10 for
development), so that you don't accidentally use those bleeding-edge Python
features that you shouldn't.

```bash
poetry env use python3.11
```

Now you can install the dev dependencies using
You can install the lowest supported Python version with

```bash
poetry install --sync
uv sync --python 3.10
```

### pre-commit
Expand All @@ -199,24 +195,13 @@ formatted and typed correctly when committing the changes.
You can install it with

```bash
poetry run pre-commit install
uv run pre-commit install
```

It can also be manually run:

```bash
poetry run pre-commit run --all-files
```

This is roughly the same as manually running

```bash
poetry install --sync
poetry check
poetry run codespell
poetry run ruff --fix
poetry run basedpyright
poetry run repo-review pyproject.toml
uv run pre-commit run --all-files
```

> [!NOTE]
Expand All @@ -229,7 +214,7 @@ Mainpy uses [pytest](https://docs.pytest.org/en/stable/) for unit testing.
These tests can be run with

```bash
poetry run pytest
uv run pytest
```

### Improving The Documentation
Expand Down
4 changes: 2 additions & 2 deletions mainpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,9 @@ def _main(_func: _F, /) -> _F | object:

if sys.version_info < (3, 11):
if use_uvloop:
import uvloop # pyright: ignore[reportMissingImports]
import uvloop

uvloop.install() # pyright: ignore[reportUnknownMemberType]
uvloop.install()

return asyncio.run(cast(Coroutine[Any, Any, _R], func()), debug=debug)

Expand Down
Loading

0 comments on commit 8df78e0

Please sign in to comment.