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 7fca899 commit fcaab1e
Show file tree
Hide file tree
Showing 9 changed files with 1,379 additions and 1,530 deletions.
19 changes: 9 additions & 10 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,37 +28,36 @@ jobs:
python_files:
- 'src/unihan_etl/**'
- 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
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
if: env.PUBLISH == 'true'
Expand Down
38 changes: 17 additions & 21 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,21 +57,18 @@ 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: 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
8 changes: 8 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ $ pipx install --suffix=@next unihan-etl --pip-args '\--pre' --force

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

### Development

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

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

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

## unihan-etl 0.35.0 (2024-11-25)

### Documentation
Expand Down
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ 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

vulture:
poetry run vulture unihan_etl
uv run vulture unihan_etl

watch_vulture:
if command -v entr > /dev/null; then ${PY_FILES} | entr -c $(MAKE) vulture; else $(MAKE) vulture entr_warn; fi
Expand All @@ -44,16 +44,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 @@ -62,7 +62,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 @@ -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 =
SOURCEDIR = .
BUILDDIR = _build
Expand Down Expand Up @@ -183,8 +183,8 @@ dev:
$(MAKE) -j watch serve

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

design:
# This adds additional watch directories (for _static file changes) and disable incremental builds
poetry run sphinx-autobuild -b html $(SPHINXOPTS) --port ${HTTP_PORT} --watch "." -a $(O) $(SOURCEDIR) $(BUILDDIR)/html
uv run sphinx-autobuild -b html $(SPHINXOPTS) --port ${HTTP_PORT} --watch "." -a $(O) $(SOURCEDIR) $(BUILDDIR)/html
Loading

0 comments on commit fcaab1e

Please sign in to comment.