Skip to content

Commit 3de8095

Browse files
committed
chore: migrate to uv
1 parent 70fd026 commit 3de8095

File tree

13 files changed

+855
-777
lines changed

13 files changed

+855
-777
lines changed

.devcontainer/devcontainer.json

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"name": "Python",
3+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
4+
"features": {
5+
"ghcr.io/devcontainers/features/python:1": {
6+
"version": "latest",
7+
"installTools": false,
8+
"installJupyterlab": false,
9+
"toolsToInstall": "mypy"
10+
},
11+
"ghcr.io/va-h/devcontainers-features/uv:1": {},
12+
"ghcr.io/devcontainers-contrib/features/shfmt:1": {},
13+
"ghcr.io/dhoeric/features/hadolint:1": {},
14+
"ghcr.io/michidk/devcontainers-features/typos:1": {},
15+
"ghcr.io/devcontainers/features/common-utils:2": {
16+
"configureZshAsDefaultShell": true
17+
}
18+
},
19+
"postCreateCommand": ".devcontainer/postCreateCommand.sh",
20+
"remoteUser": "vscode",
21+
"containerUser": "vscode",
22+
"customizations": {
23+
"vscode": {
24+
"extensions": [
25+
"charliermarsh.ruff",
26+
"exiasr.hadolint",
27+
"foxundermoon.shell-format",
28+
"GitHub.copilot",
29+
"GitHub.vscode-github-actions",
30+
"Gruntfuggly.todo-tree",
31+
"ms-azuretools.vscode-docker",
32+
"ms-python.mypy-type-checker",
33+
"njpwerner.autodocstring",
34+
"oderwat.indent-rainbow",
35+
"tamasfe.even-better-toml",
36+
"tekumara.typos-vscode",
37+
"timonwong.shellcheck",
38+
"-ms-python.vscode-pylance"
39+
],
40+
"settings": {
41+
"terminal.integrated.defaultProfile.linux": "zsh",
42+
"python.defaultInterpreterPath": "./.venv/bin/python",
43+
"[python]": {
44+
"editor.formatOnSave": true,
45+
"editor.codeActionsOnSave": {
46+
"source.fixAll": "explicit",
47+
"source.organizeImports": "explicit"
48+
},
49+
"editor.defaultFormatter": "charliermarsh.ruff"
50+
}
51+
}
52+
}
53+
}
54+
}

.devcontainer/postCreateCommand.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
3+
set -euxo pipefail
4+
5+
uv sync --dev --all-extras
6+
uv run pre-commit install --allow-missing-config
7+
8+
cat<<'A'>> ~/.zshrc
9+
eval "$(uv generate-shell-completion zsh)"
10+
eval "$(uvx --generate-shell-completion zsh)"
11+
command -v deactivate &>/dev/null || . .venv/bin/activate
12+
A
13+
14+
sed -i ~/.zshrc -e 's/^ZSH_THEME=.*/ZSH_THEME="refined"/'
15+
16+
[[ -d .venv ]] || uv venv

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
version: 2
22
updates:
3-
- package-ecosystem: pip
3+
- package-ecosystem: uv
44
directory: /
55
schedule:
66
interval: monthly

.github/workflows/docs.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Publish docs
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
strategy:
12+
max-parallel: 1
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: astral-sh/setup-uv@v5
17+
with:
18+
enable-cache: true
19+
cache-dependency-glob: uv.lock
20+
- run: uv sync --all-extras --dev
21+
- run: uv run task gendoc
22+
- uses: peaceiris/actions-gh-pages@v4
23+
with:
24+
github_token: ${{ secrets.GITHUB_TOKEN }}
25+
publish_dir: ./docs

.github/workflows/release.yml

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ on:
77
push:
88
tags:
99
- v*
10-
env:
11-
PYTHON_VERSION: '3.11'
12-
PROJECT_NAME: install-playwright-python
1310

1411
jobs:
1512
release:
@@ -33,7 +30,36 @@ jobs:
3330
- uses: actions/checkout@v4
3431
with:
3532
persist-credentials: false
36-
- name: Build and publish to pypi
37-
uses: JRubics/[email protected]
33+
- uses: astral-sh/setup-uv@v5
3834
with:
39-
pypi_token: ${{ secrets.PYPI_PASSWORD }}
35+
enable-cache: true
36+
cache-dependency-glob: uv.lock
37+
- run: uv build
38+
- run: uv publish --token "${{ env.PYPI_TOKEN }}"
39+
env:
40+
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
41+
ghcr:
42+
needs: release
43+
runs-on: ubuntu-latest
44+
steps:
45+
- uses: actions/checkout@v4
46+
- uses: docker/metadata-action@v5
47+
id: meta
48+
with:
49+
images: ghcr.io/${{ github.repository }}
50+
tags: |
51+
type=semver,pattern={{version}}
52+
type=semver,pattern={{major}}.{{minor}}
53+
- uses: docker/login-action@v3
54+
with:
55+
registry: ghcr.io
56+
username: ${{ github.repository_owner }}
57+
password: ${{ secrets.GITHUB_TOKEN }}
58+
- uses: docker/build-push-action@v6
59+
with:
60+
context: .
61+
push: true
62+
tags: ${{ steps.meta.outputs.tags }}
63+
labels: ${{ steps.meta.outputs.labels }}
64+
build-args: |
65+
VERSION=${{ github.event.release.tag_name }}

.github/workflows/test.yml

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,20 @@ jobs:
1515
matrix:
1616
os:
1717
- ubuntu-latest
18-
- windows-latest
19-
- macos-latest
2018
python-version:
21-
# - '3.8'
2219
- '3.12'
2320

2421
steps:
2522
- name: Checkout Repository
2623
uses: actions/checkout@v4
27-
- uses: actions/setup-python@v5
24+
- uses: astral-sh/setup-uv@v5
2825
with:
29-
cache: pip
30-
cache-dependency-path: poetry.lock
26+
enable-cache: true
27+
cache-dependency-glob: uv.lock
3128
python-version: ${{ matrix.python-version }}
32-
- uses: abatilo/actions-poetry@v4
33-
- run: poetry install --no-interaction
34-
- name: Test
35-
if: ${{ runner.os != 'Linux' }}
36-
run: poetry run task test
37-
- name: Test & publish code coverage
38-
if: ${{ runner.os == 'Linux' && env.CC_TEST_REPORTER_ID != '' }}
39-
uses: paambaati/[email protected]
40-
env:
41-
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
29+
- run: uv sync --all-extras --dev
30+
- run: uv run task test:ci
31+
- uses: qltysh/qlty-action/coverage@4147baf5f416bf8b60d036266d95d6099f0d3493
4232
with:
43-
coverageCommand: poetry run task test:ci
44-
coverageLocations: ${{github.workspace}}/cov.xml:coverage.py
45-
debug: true
33+
coverage-token: ${{ secrets.QLTY_COVERAGE_TOKEN }}
34+
files: ${{github.workspace}}/cov.xml

.pre-commit-config.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,6 @@ repos:
2929
rev: v2.5.1
3030
hooks:
3131
- id: pyproject-fmt
32-
- repo: https://github.com/python-poetry/poetry
33-
rev: 2.1.2
34-
hooks:
35-
- id: poetry-check
36-
- repo: https://github.com/psf/black
37-
rev: 25.1.0
38-
hooks:
39-
- id: black
4032
- repo: https://github.com/astral-sh/ruff-pre-commit
4133
rev: v0.11.4
4234
hooks:

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55
)](
66
<https://badge.fury.io/py/install-playwright>
77
) [![Maintainability](
8-
<https://api.codeclimate.com/v1/badges/75293ef4c40e3382cfe8/maintainability>
8+
<https://qlty.sh/badges/5fcd7b4f-782d-4b27-99ef-4f5c6eae678b/maintainability.svg>
99
)](
10-
<https://codeclimate.com/github/eggplants/install-playwright-python/maintainability>
10+
<https://qlty.sh/gh/eggplants/projects/install-playwright-python>
1111
) [![pre-commit.ci status](
1212
<https://results.pre-commit.ci/badge/github/eggplants/install-playwright-python/master.svg>
1313
)](
1414
<https://results.pre-commit.ci/latest/github/eggplants/install-playwright-python/master>
15-
) [![Test Coverage](
16-
<https://api.codeclimate.com/v1/badges/75293ef4c40e3382cfe8/test_coverage>
15+
) [![Maintainability](
16+
<https://qlty.sh/badges/5fcd7b4f-782d-4b27-99ef-4f5c6eae678b/maintainability.svg>
1717
)](
18-
<https://codeclimate.com/github/eggplants/install-playwright-python/test_coverage>
18+
<https://qlty.sh/gh/eggplants/projects/install-playwright-python>
1919
) [![Test](
2020
<https://github.com/eggplants/install-playwright-python/actions/workflows/test.yml/badge.svg>
2121
)](

install_playwright/__init__.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
""".. include:: ../README.md""" # noqa: D415
2+
13
from __future__ import annotations
24

5+
import importlib.metadata
36
import subprocess
47
from typing import TYPE_CHECKING
58

@@ -9,7 +12,12 @@
912
from playwright.async_api import BrowserType as AsyncBrowserType
1013
from playwright.sync_api import BrowserType as SyncBrowserType
1114

12-
__version__ = "0.1.0"
15+
try:
16+
__version__ = importlib.metadata.version(__name__)
17+
except importlib.metadata.PackageNotFoundError:
18+
__version__ = "0.0.0"
19+
20+
1321
__all__ = ["install"]
1422

1523

@@ -18,7 +26,7 @@ def install(
1826
*,
1927
with_deps: bool = False,
2028
) -> bool:
21-
"""install playwright and deps if needed
29+
"""Install playwright and deps if needed.
2230
2331
Args:
2432
browser_type (SyncBrowserType | AsyncBrowserType): `BrowserType` object. Example: `p.chrome`
@@ -33,6 +41,12 @@ def install(
3341
if with_deps:
3442
args.append("--with-deps")
3543

36-
proc = subprocess.run(args, env=get_driver_env(), capture_output=True, text=True, check=False) # noqa: S603
44+
proc = subprocess.run( # noqa: S603
45+
args,
46+
env=get_driver_env(),
47+
capture_output=True,
48+
text=True,
49+
check=False,
50+
)
3751

3852
return proc.returncode == 0

0 commit comments

Comments
 (0)