Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate from poetry to uv #42

Merged
merged 17 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
60 changes: 28 additions & 32 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,29 @@ jobs:
- name: checkout
uses: actions/checkout@v4

- name: install poetry
run: pipx install poetry
- name: setup uv
uses: eifinger/setup-uv@v1
jorenham marked this conversation as resolved.
Show resolved Hide resolved
with:
version: '0.4.3'
jorenham marked this conversation as resolved.
Show resolved Hide resolved
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: install dependencies
run: uv sync --frozen --all-extras --dev
jorenham marked this conversation as resolved.
Show resolved Hide resolved

- 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
with:
config: ".markdownlint.yaml"
globs: "**/*.md"
globs: "*.md"

- name: repo-review
uses: scientific-python/repo-review@v0.11.2
Expand All @@ -61,27 +61,23 @@ jobs:
- 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 uv
uses: eifinger/setup-uv@v1
with:
version: '0.4.3'
enable-cache: true

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

- name: install
run: poetry install
run: uv sync --frozen --all-extras --dev

- 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
Expand All @@ -97,17 +93,17 @@ jobs:
- name: checkout
uses: actions/checkout@v4

- name: install poetry
run: pipx install poetry
- name: setup uv
uses: eifinger/setup-uv@v1
with:
version: '0.4.3'
enable-cache: true

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

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

- 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
jorenham marked this conversation as resolved.
Show resolved Hide resolved
29 changes: 9 additions & 20 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,19 +176,19 @@ 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, e.g.

```bash
poetry env use python3.11
uv python install 3.10
jorenham marked this conversation as resolved.
Show resolved Hide resolved
```

Now you can install the dev dependencies using

```bash
poetry install --sync
uv sync --dev
```

### pre-commit
Expand All @@ -199,24 +199,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 +218,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