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

ci,pkg: poetry -> uv #30

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
21 changes: 11 additions & 10 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,36 +28,37 @@ jobs:
python_files:
- 'src/g.py'
- 'src/g/**'
- pyproject.toml
- uv.lock

- name: Should publish
if: steps.changes.outputs.docs == 'true' || steps.changes.outputs.root_docs == 'true' || steps.changes.outputs.python_files == 'true'
run: echo "PUBLISH=$(echo true)" >> $GITHUB_ENV

- name: Install poetry
- name: Install uv
uses: astral-sh/setup-uv@v3
if: env.PUBLISH == 'true'
run: pipx install "poetry==1.8.4"
with:
enable-cache: true

- name: Set up Python ${{ matrix.python-version }}
if: env.PUBLISH == 'true'
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'poetry'
run: uv python install ${{ matrix.python-version }}

- name: Install dependencies [w/ docs]
- name: Install dependencies
if: env.PUBLISH == 'true'
run: poetry install --with=docs,lint
run: uv sync --all-extras --dev

- name: Print python versions
if: env.PUBLISH == 'true'
run: |
python -V
poetry run python -V
uv run python -V

- name: Build documentation
if: env.PUBLISH == 'true'
run: |
pushd docs; make SPHINXBUILD='poetry run sphinx-build' html; popd
pushd docs; make SPHINXBUILD='uv run sphinx-build' html; popd

- name: Push documentation to S3
if: env.PUBLISH == 'true'
Expand Down
39 changes: 20 additions & 19 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,33 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install poetry
run: pipx install "poetry==1.8.4"
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true

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

- name: Install dependencies
run: poetry install --with=docs,test,coverage,lint
run: uv sync --all-extras --dev

- name: Print python versions
run: |
python -V
poetry run python -V
uv run python -V

- name: Lint with ruff check
run: poetry run ruff check .
run: uv run ruff check .

- name: Format with ruff format
run: poetry run ruff format . --check
run: uv run ruff format . --check

- name: Lint with mypy
run: poetry run mypy .
run: uv run mypy .

- name: Test with pytest
run: poetry run py.test --cov=./ --cov-report=xml
run: uv run py.test --cov=./ --cov-report=xml

- uses: codecov/codecov-action@v5
with:
Expand All @@ -58,18 +57,20 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install poetry
run: pipx install "poetry==1.8.4"
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true

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

- name: Install dependencies
run: uv sync --all-extras --dev

- name: Build package
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
run: poetry build
run: uv build

- name: Publish package
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
Expand Down
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
poetry 1.8.4
uv 0.5.4
python 3.13.0 3.12.7 3.11.10 3.10.15 3.9.20 3.8.20 3.7.17
8 changes: 8 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ $ pipx install --suffix=@next g --pip-args '\--pre' --force

<!-- Maintainers, insert changes / features for the next release here -->

### Development

#### Project and package management: poetry to uv (#30)

[uv] is the new package and project manager for the project, replacing Poetry.

[uv]: https://github.com/astral-sh/uv

## g 0.0.5 (2024-06-08)

### Fixes
Expand Down
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ entr_warn:
@echo "----------------------------------------------------------"

test:
poetry run py.test $(test)
uv run py.test $(test)

start:
$(MAKE) test; poetry run ptw .
$(MAKE) test; uv run ptw .

watch_test:
if command -v entr > /dev/null; then ${PY_FILES} | entr -c $(MAKE) test; else $(MAKE) test entr_warn; fi
Expand All @@ -30,7 +30,7 @@ design_docs:
$(MAKE) -C docs design

ruff_format:
poetry run ruff format .
uv run ruff format .

ruff:
ruff check .
Expand All @@ -39,7 +39,7 @@ watch_ruff:
if command -v entr > /dev/null; then ${PY_FILES} | entr -c $(MAKE) ruff; else $(MAKE) ruff entr_warn; fi

mypy:
poetry run mypy `${PY_FILES}`
uv run mypy `${PY_FILES}`

watch_mypy:
if command -v entr > /dev/null; then ${PY_FILES} | entr -c $(MAKE) mypy; else $(MAKE) mypy entr_warn; fi
Expand All @@ -48,7 +48,7 @@ format_markdown:
prettier --parser=markdown -w *.md docs/*.md docs/**/*.md CHANGES

monkeytype_create:
poetry run monkeytype run `poetry run which py.test`
uv run monkeytype run `uv run which py.test`

monkeytype_apply:
poetry run monkeytype list-modules | xargs -n1 -I{} sh -c 'poetry run monkeytype apply {}'
uv run monkeytype list-modules | xargs -n1 -I{} sh -c 'uv run monkeytype apply {}'
4 changes: 2 additions & 2 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ dev:
$(MAKE) -j watch serve

start:
poetry run sphinx-autobuild "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) --port ${HTTP_PORT} $(O)
uv run sphinx-autobuild "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) --port ${HTTP_PORT} $(O)

design:
# This adds additional watch directories (for _static file changes) and disable incremental builds
poetry run sphinx-autobuild "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) --port ${HTTP_PORT} --watch "." -a $(O)
uv run sphinx-autobuild "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) --port ${HTTP_PORT} --watch "." -a $(O)
49 changes: 31 additions & 18 deletions docs/developing.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
# Development

[poetry] is a required package to develop.
[uv] is a required package to develop.

`git clone https://github.com/vcs-python/g.git`
## Bootstrap the project

`cd g`
Install and [git] and [uv]

`poetry install -E "docs test coverage lint"`
Clone:

Makefile commands prefixed with `watch_` will watch files and rerun.
```console
$ git clone https://github.com/vcs-python/g.git
```

```console
$ cd g
```

Install packages:

```console
$ uv sync --all-extras --dev
```

[installation documentation]: https://docs.astral.sh/uv/getting-started/installation/
[git]: https://git-scm.com/

## Tests

`poetry run py.test`
`uv run py.test`

Helpers: `make test`

Expand Down Expand Up @@ -54,10 +69,10 @@ The project uses [ruff] to handle formatting, sorting imports and linting.

````{tab} Command

poetry:
uv:

```console
$ poetry run ruff
$ uv run ruff
```

If you setup manually:
Expand Down Expand Up @@ -88,10 +103,10 @@ requires [`entr(1)`].

````{tab} Fix files

poetry:
uv:

```console
$ poetry run ruff check . --fix
$ uv run ruff check . --fix
```

If you setup manually:
Expand All @@ -108,10 +123,10 @@ $ ruff check . --fix

````{tab} Command

poetry:
uv:

```console
$ poetry run ruff format .
$ uv run ruff format .
```

If you setup manually:
Expand All @@ -136,10 +151,10 @@ $ make ruff_format

````{tab} Command

poetry:
uv:

```console
$ poetry run mypy .
$ uv run mypy .
```

If you setup manually:
Expand Down Expand Up @@ -169,7 +184,7 @@ requires [`entr(1)`].

## Releasing

[poetry] handles virtualenv creation, package requirements, versioning,
[uv] handles virtualenv creation, package requirements, versioning,
building, and publishing. Therefore there is no setup.py or requirements files.

Update `__version__` in `__about__.py` and `pyproject.toml`::
Expand All @@ -178,10 +193,8 @@ Update `__version__` in `__about__.py` and `pyproject.toml`::
git tag v0.1.1
git push
git push --tags
poetry build
poetry publish

[poetry]: https://python-poetry.org/
[uv]: https://github.com/astral-sh/uv
[entr(1)]: http://eradman.com/entrproject/
[`entr(1)`]: http://eradman.com/entrproject/
[ruff format]: https://docs.astral.sh/ruff/formatter/
Expand Down
Loading