Skip to content

Commit

Permalink
ci,pkg: poetry -> uv
Browse files Browse the repository at this point in the history
  • Loading branch information
tony committed Nov 26, 2024
1 parent 02328bb commit 1186203
Show file tree
Hide file tree
Showing 12 changed files with 1,464 additions and 1,465 deletions.
19 changes: 9 additions & 10 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,38 +27,37 @@ jobs:
- 'examples/**'
python_files:
- 'src/libtmux/**'
- poetry.lock
- uv.lock
- pyproject.toml
- 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
if: env.PUBLISH == 'true'
run: pipx install "poetry==1.8.4"
uses: astral-sh/setup-uv@v3
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]
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
uses: jakejarvis/[email protected]
Expand Down
44 changes: 22 additions & 22 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ 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: Setup tmux build cache for tmux ${{ matrix.tmux-version }}
id: tmux-build-cache
Expand All @@ -46,23 +48,19 @@ jobs:
cd ~
tmux -V
- name: Install python dependencies
run: |
poetry install --with=test,coverage,lint
- 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: Print python versions
run: |
python -V
poetry run python -V
uv run python -V
- name: Test with pytest
continue-on-error: ${{ matrix.tmux-version == 'master' }}
Expand All @@ -71,7 +69,7 @@ jobs:
export PATH=$HOME/tmux-builds/tmux-${{ matrix.tmux-version }}/bin:$PATH
ls $HOME/tmux-builds/tmux-${{ matrix.tmux-version }}/bin
tmux -V
poetry run py.test --cov=./ --cov-append --cov-report=xml -n auto
uv run py.test --cov=./ --cov-append --cov-report=xml -n auto
env:
COV_CORE_SOURCE: .
COV_CORE_CONFIG: .coveragerc
Expand All @@ -92,18 +90,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: 2 additions & 0 deletions .tmuxp.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
session_name: libtmux
start_directory: ./ # load session relative to config location (project root).
shell_command_before:
- uv virtualenv --quiet > /dev/null 2>&1 && clear
windows:
- window_name: libtmux
focus: True
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
6 changes: 6 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,16 @@ $ pip install --user --upgrade --pre libtmux

### Development

- Project and package management: poetry to uv (#547)

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

- Code quality: Use f-strings in more places (#540)

via [ruff 0.4.2](https://github.com/astral-sh/ruff/blob/v0.4.2/CHANGELOG.md).

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

## libtmux 0.37.0 (04-21-2024)

_Maintenance only, no bug fixes or new features_
Expand Down
14 changes: 7 additions & 7 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 ${ALL_FILES} | entr -c $(MAKE) test; else $(MAKE) test entr_warn; fi
Expand All @@ -39,16 +39,16 @@ dev_docs:
$(MAKE) -j watch_docs serve_docs

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

ruff:
poetry run ruff check .
uv run ruff check .

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 @@ -57,7 +57,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 {}'
6 changes: 3 additions & 3 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ WATCH_FILES= find .. -type f -not -path '*/\.*' | grep -i '.*[.]\(rst\|md\)\$\|.

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = poetry run sphinx-build
SPHINXBUILD = uv run sphinx-build
PAPER =
BUILDDIR = _build

Expand Down Expand Up @@ -181,8 +181,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)
37 changes: 21 additions & 16 deletions docs/developing.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Development

[poetry] is a required package to develop.
Install and [git] and [uv]

Clone:

```console
$ git clone https://github.com/tmux-python/libtmux.git
Expand All @@ -10,15 +12,20 @@ $ git clone https://github.com/tmux-python/libtmux.git
$ cd libtmux
```

Install packages:

```console
$ poetry install -E "docs test coverage lint"
$ uv sync --all-extras --dev
```

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

Makefile commands prefixed with `watch_` will watch files and rerun.

## Tests

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

Helpers: `make test`
Rerun tests on file change: `make watch_test` (requires [entr(1)])
Expand Down Expand Up @@ -60,10 +67,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 @@ -94,10 +101,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 @@ -114,10 +121,10 @@ $ ruff check . --fix

````{tab} Command
poetry:
uv:
```console
$ poetry run ruff format .
$ uv run ruff format .
```
If you setup manually:
Expand All @@ -142,10 +149,10 @@ $ make ruff_format

````{tab} Command
poetry:
uv:
```console
$ poetry run mypy .
$ uv run mypy .
```
If you setup manually:
Expand Down Expand Up @@ -213,12 +220,12 @@ $ git tag v0.9.1
After `git push` and `git push --tags`, CI will automatically build and deploy
to PyPI.

### Releasing with Poetry (manual)
### Releasing via GitHub Actions (manual)

This isn't used yet since package maintainers may want setup.py in the source.
See https://github.com/tmux-python/tmuxp/issues/625.

As of 0.10, [poetry] handles virtualenv creation, package requirements, versioning,
As of 0.10, [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 @@ -227,11 +234,9 @@ Update `__version__` in `__about__.py` and `pyproject.toml`::
git tag v0.1.1
git push
git push --tags
poetry build
poetry deploy

[twine]: https://twine.readthedocs.io/
[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

0 comments on commit 1186203

Please sign in to comment.