Skip to content

Commit

Permalink
♻️ refactor: use uv
Browse files Browse the repository at this point in the history
  • Loading branch information
SigureMo committed Aug 17, 2024
1 parent e575712 commit fa61ed8
Show file tree
Hide file tree
Showing 13 changed files with 171 additions and 34 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/lint-and-fmt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Install uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh

- name: Install python
uses: actions/setup-python@v4
with:
Expand All @@ -31,7 +34,6 @@ jobs:

- name: Initialize venv and install packages
run: |
just create-venv
just install
- name: lint
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh

- uses: actions/setup-python@v4
with:
python-version: "3.x"
Expand All @@ -23,7 +26,6 @@ jobs:

- name: build release distributions
run: |
just create-venv
just install
just build
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Set up uv
if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' }}
run: curl -LsSf https://astral.sh/uv/install.sh | sh

- name: Set up uv
if: ${{ matrix.os == 'windows-latest' }}
run: irm https://astral.sh/uv/install.ps1 | iex
shell: powershell

- name: Install python
uses: actions/setup-python@v4
with:
Expand All @@ -32,7 +41,6 @@ jobs:

- name: Initialize venv and install packages
run: |
just create-venv
just install
- name: Run Unittest
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<a href="https://pypi.org/project/cmake-lint-paddle/" target="_blank"><img src="https://img.shields.io/pypi/v/cmake-lint-paddle?style=flat-square" alt="pypi"></a>
<a href="https://pypi.org/project/cmake-lint-paddle/" target="_blank"><img alt="PyPI - Downloads" src="https://img.shields.io/pypi/dm/cmake-lint-paddle?style=flat-square"></a>
<a href="LICENSE"><img alt="LICENSE" src="https://img.shields.io/github/license/PFCCLab/cmake-lint-paddle?style=flat-square"></a>
<a href="https://github.com/astral-sh/uv"><img alt="uv" src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json&style=flat-square"></a>
<a href="https://github.com/astral-sh/ruff"><img alt="ruff" src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json&style=flat-square"></a>
<a href="https://gitmoji.dev"><img src="https://img.shields.io/badge/gitmoji-%20😜%20😍-FFDD67?style=flat-square" alt="Gitmoji"></a>
</p>
Expand Down
24 changes: 8 additions & 16 deletions justfile
Original file line number Diff line number Diff line change
@@ -1,28 +1,20 @@
set positional-arguments

PYTHON_DIR := if os_family() == "windows" { "./.venv/Scripts" } else { "./.venv/bin" }
PYTHON := PYTHON_DIR + if os_family() == "windows" { "/python.exe" } else { "/python3" }
SYSTEM_PYTHON := if os_family() == "windows" { "py.exe -3" } else { "python3" }

create-venv:
{{SYSTEM_PYTHON}} -m venv .venv

install:
{{PYTHON}} -m pip install -U pip
{{PYTHON}} -m pip install -e ".[dev]"
uv sync

run *ARGS:
{{PYTHON}} -m cmake-lint {{ARGS}}
uv run cmakelint {{ARGS}}

test:
{{PYTHON}} -m pytest
uv run pytest
just clean

snapshot:
{{PYTHON}} -m pytest --snapshot-update
uv run pytest --snapshot-update

build:
{{PYTHON}} -m build
uv tool run --from build python -m build --installer uv .

release version:
@echo 'Tagging {{version}}...'
Expand All @@ -40,11 +32,11 @@ clean-builds:
rm -rf *.egg-info/

lint:
{{PYTHON}} -m ruff check .
uv run ruff check .

fmt:
{{PYTHON}} -m ruff format .
uv run ruff format .

ci-test:
{{PYTHON}} -m pytest
uv run pytest
just clean
12 changes: 6 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
name = "cmake-lint-paddle"
description = "A fork of cmake-lint for PaddlePaddle"
readme = "README.md"
requires-python = ">=3.7"
requires-python = ">=3.8"
authors = [
{ name = "Richard Quirk", email = "[email protected]" },
{ name = "Nyakku Shigure", email = "[email protected]" },
Expand All @@ -19,20 +19,17 @@ classifiers = [
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: Implementation :: CPython",
]
dependencies = []
dynamic = ["version"]

[project.optional-dependencies]
dev = ["pytest>=7.4.0", "ruff==0.1.5", "syrupy", "build"]

[project.urls]
Homepage = "https://github.com/PFCCLab/cmake-lint-paddle"
Documentation = "https://github.com/PFCCLab/cmake-lint-paddle"
Expand All @@ -46,9 +43,12 @@ where = ["src"]
[tool.setuptools.dynamic]
version = { attr = "cmakelint.__version__.VERSION" }

[tool.uv]
dev-dependencies = ["ruff>=0.6.0", "pytest>=7.4.4", "syrupy>=3"]

[tool.ruff]
line-length = 120
target-version = "py37"
target-version = "py38"

[tool.ruff.lint]
select = [
Expand Down
5 changes: 2 additions & 3 deletions src/cmakelint/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
the License.
"""


from __future__ import annotations

import os
Expand Down Expand Up @@ -162,7 +161,7 @@ def check_command_spaces(filename, linenumber, clean_lines, errors):
line = clean_lines.lines[linenumber]
match = contains_command(line)
if match and len(match.group(2)):
errors(filename, linenumber, "whitespace/extra", "Extra spaces between '%s' and its ()" % (match.group(1)))
errors(filename, linenumber, "whitespace/extra", f"Extra spaces between '{match.group(1)}' and its ()")
if match:
spaces_after_open = len(_RE_COMMAND_START_SPACES.match(line).group(1))
initial_spaces = get_initial_spaces(line)
Expand Down Expand Up @@ -196,7 +195,7 @@ def check_repeat_logic(filename, linenumber, clean_lines, errors):
"""
line = clean_lines.lines[linenumber]
for cmd in _logic_commands:
if re.search(r"\b%s\b" % cmd, line.lower()):
if re.search(rf"\b{cmd}\b", line.lower()):
m = _RE_LOGIC_CHECK.search(line)
if m:
errors(
Expand Down
3 changes: 1 addition & 2 deletions src/cmakelint/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
the License.
"""


from __future__ import annotations

import os
Expand Down Expand Up @@ -72,7 +71,7 @@ def set_filters(self, filters):
if c.startswith(f[1:]):
allowed = True
if not allowed:
raise ValueError("Filter not allowed: %s" % f)
raise ValueError(f"Filter not allowed: {f}")
else:
raise ValueError("Filter should start with - or +")

Expand Down
1 change: 0 additions & 1 deletion tests/test_cli/__snapshots__/test_blender.ambr
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# serializer version: 1
# name: test_blender_check
dict({
'status': 1,
Expand Down
1 change: 0 additions & 1 deletion tests/test_cli/__snapshots__/test_llvm.ambr
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# serializer version: 1
# name: test_llvm_check
dict({
'status': 1,
Expand Down
1 change: 0 additions & 1 deletion tests/test_cli/__snapshots__/test_opencv.ambr
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# serializer version: 1
# name: test_opencv_check
dict({
'status': 1,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# serializer version: 1
# name: test_invocation
dict({
'status': 0,
Expand Down
138 changes: 138 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fa61ed8

Please sign in to comment.