Skip to content

Commit 2ac0b73

Browse files
authored
Merge pull request #160 from Datenschule/use-uv
Switch to uv for dependency locking
2 parents 99072a0 + d194962 commit 2ac0b73

File tree

10 files changed

+762
-34
lines changed

10 files changed

+762
-34
lines changed

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
enable-beta-ecosystems: true
3+
updates:
4+
- package-ecosystem: "uv"
5+
directory: "/" # Location of package manifests
6+
schedule:
7+
interval: "weekly"
8+
- package-ecosystem: "github-actions"
9+
directory: "/"
10+
schedule:
11+
interval: "weekly"

.github/workflows/test.yml

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,8 @@ on:
55

66
jobs:
77
build:
8-
env:
9-
UV_SYSTEM_PYTHON: 1
108
runs-on: ubuntu-latest
11-
strategy:
12-
matrix:
13-
python-version: [ '3.11', '3.12']
14-
fail-fast: false
15-
name: Tests with Python ${{ matrix.python-version }}
9+
name: Run tests
1610
services:
1711
postgres:
1812
image: postgis/postgis:13-3.1-alpine
@@ -36,9 +30,8 @@ jobs:
3630
- name: Setup python
3731
uses: actions/setup-python@v1
3832
with:
39-
python-version: ${{ matrix.python-version }}
40-
architecture: x64
41-
- run: uv pip install -r requirements.txt
33+
python-version-file: ".python-version"
34+
- run: uv sync --locked --all-extras
4235
- run: createdb jedeschule_test
4336
env:
4437
PGHOST: localhost
@@ -47,7 +40,7 @@ jobs:
4740
PGUSER: postgres
4841
- run: |
4942
set -e
50-
alembic upgrade head
51-
python test_models.py
43+
uv run alembic upgrade head
44+
uv run python test_models.py
5245
env:
5346
DATABASE_URL: postgresql://postgres:[email protected]:5432/jedeschule_test

.github/workflows/test_scraper_changes.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ on:
55

66
jobs:
77
build:
8-
env:
9-
UV_SYSTEM_PYTHON: 1
108
runs-on: ubuntu-latest
119
name: Show changes in scraper results
1210
steps:
@@ -18,7 +16,6 @@ jobs:
1816
- name: Setup python
1917
uses: actions/setup-python@v1
2018
with:
21-
python-version: 3.11
22-
architecture: x64
23-
- run: uv pip install -r requirements.txt
24-
- run: ./test_changes.sh
19+
python-version-file: ".python-version"
20+
- run: uv sync --locked --all-extras
21+
- run: uv run ./test_changes.sh

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.12

Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ FROM scrapinghub/scrapinghub-stack-scrapy:2.11
22

33
COPY . .
44

5-
RUN pip install -r requirements.txt
5+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
6+
7+
RUN uv pip install -r requirements.txt
68

79
# Install pg_isready to await db start
810
RUN apt-get update && \

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,11 @@ When available, we try to use the geolocations provided by the data publishers.
6060
| TH | ❌ No | - |
6161

6262
## Installation
63-
Note that at least Python 3.7 is required.
63+
Dependency management is done using [uv](https://docs.astral.sh/uv/). Make sure
64+
to have it installed and then run the following command to install the dependencies:
6465

6566
```bash
66-
pip install -r requirements.txt
67+
uv sync --locked --all-extras
6768
```
6869

6970
Make your you have a postgres database with postgis support
@@ -74,7 +75,7 @@ export DATABASE_URL=postgres://[email protected]:5432/jedeschule
7475
```
7576
Then, run the migrations to bring you database up to date
7677
```sh
77-
alembic upgrade head
78+
uv run alembic upgrade head
7879
```
7980

8081

@@ -84,8 +85,8 @@ database for test data. After creating it, run the following steps
8485
(assuming you called your database `jedeschule_scraper_test`):
8586
```
8687
export DATABASE_URL=postgres://[email protected]:5432/jedeschule_scraper_test
87-
alembic upgrade head
88-
python test_models.py
88+
uv run alembic upgrade head
89+
uv run python test_models.py
8990
```
9091

9192
If you made changes to scrapers, you can also run a script to check the
@@ -108,7 +109,7 @@ bash ./scrape_all.sh
108109
### Updating data for a single state
109110
To get updates for a single state, run
110111
```bash
111-
scrapy crawl <state_name>
112+
uv run scrapy crawl <state_name>
112113
# use `scrapy list` to get a list of all available states
113114
```
114115

pyproject.toml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[project]
2+
name = "jedeschule-scraper"
3+
version = "0.1.0"
4+
description = "Web scrapers for the jedeschule.codefor.de project"
5+
readme = "README.md"
6+
requires-python = ">=3.12"
7+
dependencies = [
8+
"alembic==1.3.3",
9+
"geoalchemy2==0.8.4",
10+
"psycopg2==2.9.10",
11+
"pyproj==3.6.1",
12+
"requests==2.32.0",
13+
"scrapy==2.11.2",
14+
"sqlalchemy==1.3.10",
15+
"xlrd==1.1.0",
16+
]

requirements.txt

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

scrape_all.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ do
88
# cannot even use in the end.
99
# This is why we set the maximum amount of items that are
1010
# allowed to crash to 3 here.
11-
scrapy crawl $spider -s "CLOSESPIDER_ERRORCOUNT=3" --loglevel=INFO
11+
uv run scrapy crawl $spider -s "CLOSESPIDER_ERRORCOUNT=3" --loglevel=INFO
1212
done

uv.lock

Lines changed: 715 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)