Skip to content

Commit

Permalink
Migrate to uv (#755)
Browse files Browse the repository at this point in the history
  • Loading branch information
njooma authored Oct 8, 2024
1 parent 5789139 commit 8a1aef0
Show file tree
Hide file tree
Showing 197 changed files with 4,200 additions and 6,427 deletions.
6 changes: 0 additions & 6 deletions .flake8

This file was deleted.

17 changes: 7 additions & 10 deletions .github/workflows/build-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,14 @@ jobs:
uses: actions/checkout@v4
if: ${{ !inputs.branch }}

- name: Install Poetry
run: pipx install poetry
- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: poetry
run: uv python install 3.12

- name: Install package
run: poetry install --all-extras
run: uv sync

- name: Download binary
run: curl -sL -o src/viam/rpc/libviam_rust_utils.${{ matrix.ext }} https://github.com/viamrobotics/rust-utils/releases/latest/download/libviam_rust_utils-${{ matrix.arch }}.${{ matrix.ext }}
Expand All @@ -74,12 +71,12 @@ jobs:
run: echo "This file enables arm7l support. PyPI doesn't allow for packages with the same hash, so this file must be added to differentiate this arm7l package from the arm6l package." > src/viam/arm7l.txt

- name: Build
run: poetry build -f wheel
run: uv build --wheel

- name: Rename
run: |
echo "WHL_NAME=viam_sdk-$(poetry run python -c 'import viam; print(viam.__version__)')-py3-none-${{ matrix.whl }}.whl" >> $GITHUB_ENV
mv dist/viam_sdk-$(poetry run python -c "import viam; print(viam.__version__)")-py3-none-any.whl dist/viam_sdk-$(poetry run python -c 'import viam; print(viam.__version__)')-py3-none-${{ matrix.whl }}.whl
echo "WHL_NAME=viam_sdk-$(uv run python3 -c 'import viam; print(viam.__version__)')-py3-none-${{ matrix.whl }}.whl" >> $GITHUB_ENV
mv dist/viam_sdk-$(uv run python3 -c "import viam; print(viam.__version__)")-py3-none-any.whl dist/viam_sdk-$(uv run python3 -c 'import viam; print(viam.__version__)')-py3-none-${{ matrix.whl }}.whl
- name: Upload artifacts
uses: actions/upload-artifact@v4
Expand Down
16 changes: 7 additions & 9 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,21 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Install Poetry
uses: snok/install-poetry@v1
- name: Setup Python
run: uv python install 3.12

- name: Install package
run: make install

- name: Generate docs
run: |
poetry run python3 -m docs.examples._server &
poetry run python3 -m examples.server.v1.server 0.0.0.0 9091 &
uv run python3 -m docs.examples._server &
uv run python3 -m examples.server.v1.server 0.0.0.0 9091 &
sleep 2
make documentation
uv run make documentation
- name: Upload artifacts
uses: actions/upload-artifact@v3
Expand Down
13 changes: 4 additions & 9 deletions .github/workflows/license_finder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,21 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install Poetry
run: pipx install poetry
- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11.5"
run: uv python install

- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.3"

- run: gem install license_finder

- name: Install package
run: poetry install --all-extras

- name: Generate requirements.txt (exclude dev dependencies)
run: |
poetry export -f requirements.txt --without-hashes > requirements.txt
uv pip compile pyproject.toml -o requirements.txt
pip install -r requirements.txt
- name: Run license finder
Expand Down
15 changes: 7 additions & 8 deletions .github/workflows/linkcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,27 @@ name: run-htmltest-external
on:
schedule:
# 10am UTC on weekdays
- cron: '0 10 * * 1,2,3,4,5'
- cron: "0 10 * * 1,2,3,4,5"
jobs:
htmltest:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
python-version: "3.12"
enable-cache: true

- name: Install Poetry
uses: snok/install-poetry@v1
- name: Setup Python
run: uv python install 3.12

- name: Install package
run: make install

- name: Generate docs
run: |
make documentation
run: uv run make documentation

- name: Test HTML
# https://github.com/wjdp/htmltest-action/
Expand Down
46 changes: 28 additions & 18 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,53 +4,63 @@ on:
workflow_dispatch:
inputs:
version:
description: "The type of version bump. Use `-s` for no change. See docs for details: https://python-poetry.org/docs/cli/#version"
description: "The type of version bump. Use `-s` for no change. See docs for details: https://hatch.pypa.io/latest/version/#supported-segments"
type: choice
required: true
default: "-s"
options:
- major
- minor
- patch
- premajor
- preminor
- prepatch
- prerelease
- prerelease --next-phase
- "-s"
prerelease:
description: "If this is a prerelease and which type. See docs for details: https://hatch.pypa.io/latest/version/#supported-segments"
type: choice
required: false
options:
- "alpha"
- "beta"
- "rc"

jobs:
prepare:
if: github.repository_owner == 'viamrobotics'
runs-on: ubuntu-latest
outputs:
version: ${{ steps.bump_version.outputs.version }}
version: ${{ steps.set_version.outputs.version }}
steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Install Poetry
run: pipx install poetry
- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: poetry
run: uv python install 3.12

- name: Install Package
run: poetry install --all-extras
run: uv sync --all-extras

- name: Clean Format Test
run: make clean format typecheck test
run: uv run make clean format typecheck test

- name: Bump Version
id: bump_version
shell: bash
if: inputs.version != '-s' && inputs.prerelease
run: echo "ABC" && uvx hatch version ${{ inputs.version }},${{ inputs.prerelease }}

- name: Bump Version
id: bump_version
shell: bash
if: inputs.version != '-s' && !inputs.prerelease
run: echo "DEF" && uvx hatch version ${{ inputs.version }}

- name: Set Version
id: set_version
run: |
poetry version ${{ inputs.version }}
echo "SDK_VERSION=$(poetry version -s)" >> $GITHUB_ENV
echo "version=$(poetry version -s)" >> $GITHUB_OUTPUT
echo "SDK_VERSION=$(uvx hatch version)" >> $GITHUB_ENV
echo "version=$(uvx hatch version)" >> $GITHUB_OUTPUT
- name: Check if release exists
uses: cardinalby/[email protected]
Expand Down
27 changes: 12 additions & 15 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,38 +22,35 @@ jobs:
steps:
- name: Checkout Push/Workflow Dispatch
if: github.event_name == 'workflow_dispatch' || github.event_name == 'push'
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Checkout PR
if: github.event_name == 'pull_request_target'
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Install Poetry
run: pipx install poetry
- name: Setup python
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
python-version: ${{ matrix.python-version }}
cache: poetry
enable-cache: true

- name: Fix Poetry
run: poetry config installer.modern-installation false
- name: Setup Python
run: uv python install ${{ matrix.python-version }}

- name: Install package
run: make install

- name: Install minimum package versions
run: poetry run pip install -r requirements-test.txt
run: uv pip install -r requirements-test.txt
if: ${{ matrix.requirements-version == 'min' }}

- name: Type Check
run: make typecheck
run: uv run make typecheck

- name: Lint
run: make lint
run: uv run make lint

- name: Test
run: make test
run: uv run make test

- name: Test Documentation
run: make test_docs
run: uv run make test_docs
17 changes: 9 additions & 8 deletions .github/workflows/update_protos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,26 @@ jobs:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: "28.2"

- name: Install Poetry
uses: snok/install-poetry@v1
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true

- name: Install package
run: |
poetry install --all-extras
- name: Setup Python
run: uv python install

- name: Store API version
run: |
python3 etc/_update_version_metadata.py src/viam/version_metadata.py ${{ github.event.client_payload.tag }}
uv run python3 etc/_update_version_metadata.py src/viam/version_metadata.py ${{ github.event.client_payload.tag }}
echo "Updated API version to ${{ github.event.client_payload.tag }} in src/viam/version_metadata.py"
- name: Generate buf
run: make buf
run: uv run make buf
env:
BUF_TOKEN: ${{ secrets.BUF_TOKEN }}

- name: Format
run: make format
run: uv run make format

- name: Add + Commit + Open PR
shell: bash
Expand Down
32 changes: 14 additions & 18 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
{
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true
"diffEditor.ignoreTrimWhitespace": false,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.wordBasedSuggestions": "off",
"editor.rulers": [
{
"color": "#777777",
"column": 140
}
]
},
"editor.formatOnSave": true,
"python.linting.ignorePatterns": [
"**/site-packages/**/*.py",
".vscode/*.py",
"gen/**/*",
"viam/proto/**/*"
],
"files.trimTrailingWhitespace": true,
"files.insertFinalNewline": true,
"editor.rulers": [
{
"column": 140,
"color": "#777777"
}
],
"cSpell.words": [
"frombytes",
"grpclib",
Expand All @@ -27,7 +23,7 @@
"segmenters",
"TFLITE",
"tobytes",
"viam"
],
"isort.args": ["-l 140 --profile black"]
"viam",
"viamrobotics"
]
}
7 changes: 0 additions & 7 deletions CHANGELOG.md

This file was deleted.

Loading

0 comments on commit 8a1aef0

Please sign in to comment.