Skip to content

Commit

Permalink
switch to uv
Browse files Browse the repository at this point in the history
  • Loading branch information
xoolive committed Nov 5, 2024
1 parent 10bac92 commit 72a10eb
Show file tree
Hide file tree
Showing 8 changed files with 3,751 additions and 5,656 deletions.
6 changes: 6 additions & 0 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
$schema: "https://docs.renovatebot.com/renovate-schema.json",
lockFileMaintenance: {
enabled: true,
},
}
55 changes: 13 additions & 42 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ on:

env:
PYTHON_VERSION: "3.11"
POETRY_VERSION: "1.8.2"

jobs:
documentation:
Expand All @@ -21,16 +20,16 @@ jobs:
- run: |
git fetch --prune --unshallow --tags
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

# Update full Python version
- name: Full Python version
run: |
echo "PYTHON_VERSION=$(python -c "import platform; print(platform.python_version())")"
- name: Download extra data from private repository
uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -59,25 +58,6 @@ jobs:
unzip ENV_PostOPS_AIRAC_2111_04NOV2021_With_Airspace_Closure.zip -d airac_2111
shell: bash

# virtualenv cache should depends on OS, Python version and `poetry.lock` (and optionally workflow files).
- name: Cache Packages
uses: actions/cache@v4
with:
path: |
~/.local
.venv
key: poetry-${{ runner.os }}-${{ hashFiles('poetry.lock') }}

- name: Install and configure Poetry
uses: snok/install-poetry@v1.4.1
with:
version: ${{ env.POETRY_VERSION }}
virtualenvs-create: true
virtualenvs-in-project: true

- name: Display Python version
run: poetry run python -c "import sys; print(sys.version)"

- name: Cache folder for traffic
uses: actions/cache@v4
id: cache-folder
Expand All @@ -86,15 +66,15 @@ jobs:
~/.cache/traffic/
~/.cache/opensky/
~/.cache/cartes/
key: traffic-${{ hashFiles('poetry.lock') }}
key: traffic-${{ hashFiles('uv.lock') }}

- name: Cache folder for documentation
uses: actions/cache@v4
id: docs-folder
with:
path: |
docs/_build/
key: docs-${{ hashFiles('poetry.lock') }}
key: docs-${{ hashFiles('uv.lock') }}

- name: Ubuntu system dependencies
run: |
Expand All @@ -107,18 +87,9 @@ jobs:
run: |
npm install vega-lite vega-cli canvas # necessary dependency for altair-save
- name: Dynamic versioning
run: poetry self add "poetry-dynamic-versioning[plugin]" || true

- name: Install dependencies
- name: Install the project
run: |
poetry install -E full
# This should not be necessary... but sometimes it is
# https://traffic-viz.github.io/troubleshooting/installation.html
# SHAPELY_VERSION=$(poetry run python -c "import shapely; print(shapely.__version__)")
# poetry run pip uninstall -y shapely
# poetry run pip install --no-binary shapely shapely==${SHAPELY_VERSION}
uv sync --dev --all-extras
- name: Build pages
env:
Expand All @@ -131,11 +102,11 @@ jobs:
TRAFFIC_CACHE_NO_EXPIRE: ""
run: |
# This downloads the cache for cartes atlas
poetry run python -c "from cartes.atlas import default, world_atlas"
uv run python -c "from cartes.atlas import default, world_atlas"
# This downloads files to have in cache first
poetry run traffic cache --fill
uv run traffic cache --fill
export TRAFFIC_CONFIG=$(poetry run python -c "from traffic import config_file; print(config_file)")
export TRAFFIC_CONFIG=$(uv run python -c "from traffic import config_file; print(config_file)")
sed -i "/tqdm_style =/ s,auto,silent," $TRAFFIC_CONFIG
Expand All @@ -144,7 +115,7 @@ jobs:
# sed -i "/pkcs12_password =/ s,=$,= $PKCS12_PASSWORD," $TRAFFIC_CONFIG
# Run the documentation
cd docs && CARTES_CACHE=./cache poetry run make html
cd docs && CARTES_CACHE=./cache uv run make html
- name: Deploy pages
uses: peaceiris/actions-gh-pages@v4
Expand Down
26 changes: 9 additions & 17 deletions .github/workflows/pypi-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,29 @@ name: publish

on:
release:
types: [published]
types:
- published
workflow_dispatch:

env:
POETRY_VERSION: "1.8.2"

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install and configure Poetry
uses: snok/install-poetry@v1.4.1
with:
version: ${{ env.POETRY_VERSION }}
virtualenvs-in-project: true

- name: Display Python version
run: poetry run python -c "import sys; print(sys.version)"

- name: Dynamic versioning
run: poetry self add "poetry-dynamic-versioning[plugin]" || true

- name: Build packages
run: poetry build
run: |
uvx --with hatch-vcs hatchling build
- name: Publish a Python distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
Expand Down
94 changes: 47 additions & 47 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,50 @@ on:
push:
branches:
- master
pull_request:
pull_request_target:
schedule:
- cron: "42 7 * * 0" # Every Sunday morning when I am fast asleep :)
# This is useful for keeping the cache fit and ready
workflow_dispatch:

env:
POETRY_VERSION: "1.8.2"

jobs:
deploy:
linting:
name: linting/formatting

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12

- name: Ubuntu system dependencies
run: |
sudo apt update
sudo apt install -y libgdal-dev libgeos-dev libproj-dev proj-bin proj-data
- name: Install the project
run: |
uv sync --dev --all-extras
- name: Style checking
run: |
uv run ruff check src tests
uv run ruff format --check src tests
- name: Type checking
run: uv run mypy src tests docs/usage/scripts

tests:
name: python-${{ matrix.python-version }} on ${{ matrix.os }}

runs-on: ${{ matrix.os }}
Expand All @@ -41,17 +74,16 @@ jobs:
- run: |
git fetch --prune --unshallow --tags
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

# Update full Python version
- name: Full Python version
run: |
echo "PYTHON_VERSION=$(python -c "import platform; print(platform.python_version())")"
echo "PYTHON_VERSION=$(python -c "import platform; print(platform.python_version())")" >> $GITHUB_ENV
- name: Download extra data from private repository
uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -80,25 +112,6 @@ jobs:
unzip ENV_PostOPS_AIRAC_2111_04NOV2021_With_Airspace_Closure.zip -d airac_2111
shell: bash

# virtualenv cache should depends on OS, Python version and `poetry.lock` (and optionally workflow files).
- name: Cache Packages
uses: actions/cache@v4
with:
path: |
~/.local
.venv
key: poetry-${{ runner.os }}-${{ hashFiles('poetry.lock') }}

- name: Install and configure Poetry
uses: snok/install-poetry@v1.4.1
with:
version: ${{ env.POETRY_VERSION }}
virtualenvs-create: true
virtualenvs-in-project: true

- name: Display Python version
run: poetry run python -c "import sys; print(sys.version)"

- name: Cache folder for traffic
uses: actions/cache@v4
id: cache-folder
Expand All @@ -107,28 +120,16 @@ jobs:
~/.cache/traffic/
~/.cache/opensky/
~/.cache/cartes/
key: traffic-${{ hashFiles('poetry.lock') }}
key: traffic-${{ hashFiles('uv.lock') }}

- name: Ubuntu system dependencies
run: |
sudo apt update
sudo apt install -y libgdal-dev libgeos-dev libproj-dev proj-bin proj-data
- name: Dynamic versioning
run: poetry self add "poetry-dynamic-versioning[plugin]" || true

- name: Install dependencies
run: |
poetry install -E full
- name: Style checking
run: |
poetry run ruff check src tests
poetry run ruff format --check src tests
- name: Type checking
- name: Install project
run: |
poetry run mypy src tests
uv sync --dev --all-extras
- name: Run tests
if: ${{ matrix.python-version == '3.12' || steps.cache-folder.outputs.cache-hit == 'true' }}
Expand All @@ -137,7 +138,6 @@ jobs:
TRAFFIC_NOPLUGIN: ""
OPENSKY_USERNAME: ${{ secrets.OPENSKY_USERNAME }}
OPENSKY_PASSWORD: ${{ secrets.OPENSKY_PASSWORD }}
# PKCS12_PASSWORD: ${{ secrets.PKCS12_PASSWORD }}
run: |
export TRAFFIC_CONFIG=$(poetry run python -c "from traffic import config_file; print(config_file)")
Expand All @@ -148,8 +148,8 @@ jobs:
# Don't purge OpenSky cache files here :)
sed -i "/purge = / d" $TRAFFIC_CONFIG
poetry run traffic cache --fill # download files to have in cache first
poetry run pytest --cov --cov-report xml
uv run traffic cache --fill # download files to have in cache first
uv run pytest --cov --cov-report xml
- name: Upload coverage to Codecov
if: ${{ github.event_name != 'pull_request_target' }}
Expand Down
9 changes: 0 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,6 @@ repos:
- id: mixed-line-ending
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
- repo: https://github.com/python-poetry/poetry
rev: 1.5.1
hooks:
- id: poetry-check
- repo: https://github.com/floatingpurr/sync_with_poetry
rev: 1.1.0
hooks:
- id: sync_with_poetry
args: [] # optional args
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.3.4
hooks:
Expand Down
Loading

0 comments on commit 72a10eb

Please sign in to comment.