Skip to content

Commit 94c5ab7

Browse files
authored
Migrate from setup.py to pyproject.toml for uv compatibility (#186)
* Migrate from setup.py to pyproject.toml for uv compatibility - Create pyproject.toml with project metadata, dependencies, and build config - Add dependency-groups for dev (pytest, cogapp, pytest-mock) and docs - Use hatchling as build backend - Remove obsolete setup.py and Pipfile * Use uv_build backend and update homepage URL - Switch build backend from hatchling to uv_build - Set homepage to shot-scraper.datasette.io * Fix pyproject.toml configuration for uv_build - Update requires-python to >=3.10 - Use correct [tool.uv.build-backend] section for flat layout - Add version constraint to uv_build (>=0.9.18,<0.10.0) * Add uv.lock file * Add uv.lock to .gitignore and remove from tracking * Update GitHub Actions to use latest versions * pip install -e . --group dev * Try CI on ubuntu instead * Try pytest -vv * Test Playwright start time before running tests * Ran Cog * Temporarily comment out accessibility, refs #185 --------- https://gistpreview.github.io/?f3290331ec6340757ceb8c2a853bdb95/index.html
1 parent 8435690 commit 94c5ab7

File tree

7 files changed

+74
-67
lines changed

7 files changed

+74
-67
lines changed

.github/workflows/test.yml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,43 +4,46 @@ on: [push, pull_request]
44

55
jobs:
66
test:
7-
runs-on: macos-latest
7+
runs-on: ubuntu-latest
88
strategy:
99
matrix:
10-
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
10+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
1111
steps:
12-
- uses: actions/checkout@v4
12+
- uses: actions/checkout@v6
1313
- name: Set up Python ${{ matrix.python-version }}
14-
uses: actions/setup-python@v5
14+
uses: actions/setup-python@v6
1515
with:
1616
python-version: ${{ matrix.python-version }}
1717
cache: 'pip'
18-
cache-dependency-path: setup.py
18+
cache-dependency-path: pyproject.toml
1919
- name: Cache Playwright browsers
20-
uses: actions/cache@v4
20+
uses: actions/cache@v5
2121
with:
2222
path: ~/.cache/ms-playwright/
2323
key: ${{ runner.os }}-browsers
2424
- name: Install dependencies
2525
run: |
26-
pip install -e '.[test]'
26+
pip install -e . --group dev
2727
- name: Install Playwright dependencies
2828
run: |
2929
python -m playwright install-deps
3030
shot-scraper install
3131
shot-scraper install -b firefox
3232
shot-scraper install -b webkit
33+
- name: Test Playwright startup time
34+
run: |
35+
time python -c "from playwright.sync_api import sync_playwright; p = sync_playwright().start(); b = p.chromium.launch(); b.close(); p.stop(); print('OK')"
3336
- name: Run tests
3437
run: |
35-
pytest
38+
pytest -vv
3639
- name: Check if cog needs to be run
3740
run: |
3841
cog --check docs/*.md
3942
- name: Run test examples
4043
run: |
4144
tests/run_examples.sh
4245
- name: Archive examples
43-
uses: actions/upload-artifact@v4
46+
uses: actions/upload-artifact@v6
4447
with:
4548
name: examples-${{ matrix.python-version }}
4649
path: examples/*

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.venv
2+
uv.lock
23
__pycache__/
34
*.py[cod]
45
*$py.class

Pipfile

Lines changed: 0 additions & 11 deletions
This file was deleted.

docs/pdf.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Options:
5757
--timeout INTEGER Wait this many milliseconds before failing
5858
--media-screen Use screen rather than print styles
5959
--landscape Use landscape orientation
60-
--format [Letter|Legal|Tabloid|Ledger|A0|A1|A2|A3|A4|A5|A6]
60+
--format [letter|legal|tabloid|ledger|a0|a1|a2|a3|a4|a5|a6]
6161
Which standard paper size to use
6262
--width TEXT PDF width including units, e.g. 10cm
6363
--height TEXT PDF height including units, e.g. 10cm

pyproject.toml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
[project]
2+
name = "shot-scraper"
3+
version = "1.8"
4+
description = "A command-line utility for taking automated screenshots of websites"
5+
readme = "README.md"
6+
requires-python = ">=3.10"
7+
license = "Apache-2.0"
8+
authors = [
9+
{ name = "Simon Willison" }
10+
]
11+
12+
classifiers = [
13+
"License :: OSI Approved :: Apache Software License",
14+
]
15+
16+
dependencies = [
17+
"click",
18+
"PyYAML",
19+
"playwright",
20+
"click-default-group",
21+
]
22+
23+
[project.urls]
24+
Homepage = "https://shot-scraper.datasette.io/"
25+
Issues = "https://github.com/simonw/shot-scraper/issues"
26+
CI = "https://github.com/simonw/shot-scraper/actions"
27+
Changelog = "https://github.com/simonw/shot-scraper/releases"
28+
29+
[project.scripts]
30+
shot-scraper = "shot_scraper.cli:cli"
31+
32+
[dependency-groups]
33+
dev = [
34+
"pytest",
35+
"cogapp",
36+
"pytest-mock",
37+
]
38+
docs = [
39+
"furo==2023.9.10",
40+
"sphinx-autobuild",
41+
"sphinx-copybutton",
42+
"myst-parser",
43+
"cogapp",
44+
]
45+
46+
[build-system]
47+
requires = ["uv_build>=0.9.18,<0.10.0"]
48+
build-backend = "uv_build"
49+
50+
[tool.uv.build-backend]
51+
module-root = ""

setup.py

Lines changed: 0 additions & 37 deletions
This file was deleted.

tests/run_examples.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ shot-scraper 'https://www.owlsnearme.com/?place=127871' \
4545
-o examples/owlsnearme-wait.jpg \
4646
--wait-for "!!document.querySelector('section.secondary')"
4747
# Accessibility
48-
shot-scraper accessibility https://datasette.io/ \
49-
> examples/datasette-accessibility.json
50-
shot-scraper accessibility https://simonwillison.net \
51-
--javascript "document.getElementById('wrapper').style.display='none'" \
52-
> examples/simonwillison-accessibility-javascript.json
53-
shot-scraper accessibility https://simonwillison.net \
54-
--javascript "document.getElementById('wrapper').style.display='none'" \
55-
--output examples/simonwillison-accessibility-javascript-and-dash-output.json
56-
shot-scraper accessibility examples/local.html -o examples/local-accessibility.json
48+
# #shot-scraper accessibility https://datasette.io/ \
49+
# > examples/datasette-accessibility.json
50+
# shot-scraper accessibility https://simonwillison.net \
51+
# --javascript "document.getElementById('wrapper').style.display='none'" \
52+
# > examples/simonwillison-accessibility-javascript.json
53+
# shot-scraper accessibility https://simonwillison.net \
54+
# --javascript "document.getElementById('wrapper').style.display='none'" \
55+
# --output examples/simonwillison-accessibility-javascript-and-dash-output.json
56+
# shot-scraper accessibility examples/local.html -o examples/local-accessibility.json
5757
# PDF
5858
(cd examples && shot-scraper pdf https://datasette.io/tools)
5959
shot-scraper pdf https://datasette.io \

0 commit comments

Comments
 (0)