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 25, 2024
1 parent 763da16 commit 1a06dee
Show file tree
Hide file tree
Showing 13 changed files with 1,481 additions and 1,624 deletions.
21 changes: 10 additions & 11 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,37 +27,36 @@ jobs:
python_files:
- 'src/tmuxp/**'
- pyproject.toml
- poetry.lock
- 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 }}
uses: actions/setup-python@v5
if: env.PUBLISH == 'true'
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
45 changes: 22 additions & 23 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,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 @@ -52,22 +54,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
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 @@ -76,7 +75,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-report=xml
uv run py.test --cov=./ --cov-report=xml
- uses: codecov/codecov-action@v5
with:
Expand All @@ -94,21 +93,21 @@ 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')
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
Expand Down
3 changes: 3 additions & 0 deletions .tmuxp.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"session_name": "tmuxp",
"start_directory": "./",
"shell_command_before": [
"uv virtualenv --quiet > /dev/null 2>&1 && clear"
],
"windows": [
{
"window_name": "tmuxp",
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: tmuxp
start_directory: ./ # load session relative to config location (project root).
shell_command_before:
- uv virtualenv --quiet > /dev/null 2>&1 && clear
windows:
- window_name: tmuxp
focus: True
Expand Down
6 changes: 6 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,16 @@ $ pipx install --suffix=@next 'tmuxp' --pip-args '\--pre' --force

### Development

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

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

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

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

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

## tmuxp 1.47.0 (2024-04-21)

_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 ${TEST_FILES} | entr -c $(MAKE) test; else $(MAKE) test entr_warn; fi
Expand All @@ -39,16 +39,16 @@ design_docs:
$(MAKE) -C docs design

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:
npx 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 @@ -6,7 +6,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 @@ -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)
4 changes: 2 additions & 2 deletions docs/configuration/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -636,9 +636,9 @@ windows:
- focus: True
- blank
- >
poetry run ./manage.py migrate &&
uv run ./manage.py migrate &&
npm -C js run start
- poetry run ./manage.py runserver
- uv run ./manage.py runserver
options:
main-pane-height: 35
```
Expand Down
53 changes: 23 additions & 30 deletions docs/developing.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ $ cd tmuxp

### Bootstrap

The easiest way to configure a dev environment is through [poetry]. This
The easiest way to configure a dev environment is through [uv]. This
automatically will manage virtualenv and python dependencies for tmuxp.
For information on installing poetry visit the [poetry's documentation].
For information on installing uv visit the [uv's documentation].

To begin developing, check out the code from github:

Expand All @@ -48,34 +48,29 @@ $ cd tmuxp
```

You can create a virtualenv, and install all of the locked
packages as listed in poetry.lock:
packages as listed in uv.lock:

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

If you ever need to update packages during your development session, the
following command can be used to update all packages as per poetry settings or
individual package (second command):
following command can be used to update all packages as per uv settings:

```console
$ poetry update
$ uv sync --all-extras --dev --upgrade
```

```console
$ poetry update requests
```

Then activate it to your current tty / terminal session with:
Then before any python command in tty / terminal session, run with:

```console
$ poetry shell
$ uv run [command]
```

That is it! You are now ready to code!

[poetry]: https://python-poetry.org/
[poetry's documentation]: https://python-poetry.org/docs/
[uv]: https://github.com/astral-sh/uv
[uv's documentation]: https://docs.astral.sh/uv

### Advanced: Manual virtualenv

Expand Down Expand Up @@ -134,7 +129,7 @@ $ make watch_test
### Manual (just the command, please)

```console
$ poetry run py.test
$ uv run py.test
```

or:
Expand All @@ -159,19 +154,19 @@ $ env PYTEST_ADDOPTS="-verbose" make start
Pick a file:

```console
$ env PYTEST_ADDOPTS="tests/workspace/test_builder.py" poetry run make start
$ env PYTEST_ADDOPTS="tests/workspace/test_builder.py" uv run make start
```

Drop into `test_automatic_rename_option()` in `tests/workspace/test_builder.py`:

```console
$ env PYTEST_ADDOPTS="-s -x -vv tests/workspace/test_builder.py" poetry run make start
$ env PYTEST_ADDOPTS="-s -x -vv tests/workspace/test_builder.py" uv run make start
```

Drop into `test_automatic_rename_option()` in `tests/workspace/test_builder.py` and stop on first error:

```console
$ env PYTEST_ADDOPTS="-s -x -vv tests/workspace/test_builder.py::test_automatic_rename_option" poetry run make start
$ env PYTEST_ADDOPTS="-s -x -vv tests/workspace/test_builder.py::test_automatic_rename_option" uv run make start
```

Drop into `pdb` on first error:
Expand Down Expand Up @@ -299,10 +294,8 @@ $ cd doc
$ make watch
```

If you're not source'd via `poetry shell`, you can use this:

```console
$ make SPHINXBUILD='poetry run sphinx-build' watch
$ make SPHINXBUILD='uv run sphinx-build' watch
```

(tmuxp-developer-config)=
Expand Down Expand Up @@ -335,10 +328,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 @@ -369,10 +362,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 @@ -389,10 +382,10 @@ $ ruff check . --fix

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

````{tab} Command
poetry:
uv:
```console
$ poetry run mypy .
$ uv run mypy .
```
If you setup manually:
Expand Down
Loading

0 comments on commit 1a06dee

Please sign in to comment.