Skip to content

Commit 6bd696f

Browse files
jyoo980nickswalker
andauthored
Adding support for uv and updating README.md (#47)
* Adding support for `uv` and updating `README.md` * Use UV in CI pipeline Drop requirements.txt now that we have uv lock file and pyproject Remove release pins in pyproject, since the lock file contains the same information. This lets us use uv to upgrade dependencies easily Track dependency resolution for route image optional dependencies into the lock file. Only installed when user provides extra arg * Update uv usage in readme --------- Co-authored-by: Nick Walker <nick@nickwalker.us>
1 parent f1fbda2 commit 6bd696f

File tree

7 files changed

+361
-26
lines changed

7 files changed

+361
-26
lines changed

.github/workflows/github-pages.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
cache: pip
3737

3838
- name: Install Python Dependencies
39-
run: pip install -r requirements.txt
39+
run: pip install uv && uv sync
4040

4141
- name: Check Schedules
4242
continue-on-error: false
@@ -100,8 +100,7 @@ jobs:
100100
- name: Install Playwright
101101
if: steps.cache-route-images.outputs.cache-hit != 'true'
102102
run: |
103-
pip install playwright pillow
104-
playwright install chromium
103+
uv sync --extra route-images
105104
106105
- name: Generate route OpenGraph images
107106
if: steps.cache-route-images.outputs.cache-hit != 'true'

.python-version

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

Makefile

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,43 +23,43 @@ $(NEIGHBORHOODS):
2323
@wget -c $(NEIGHBORHOODS_URL) -O $@
2424

2525
$(ROUTES_YML): _bin/make_routes_table.py $(ROUTES_GPX_NORMALIZED)
26-
python3 $< $(ROUTES_GPX_NORMALIZED) $@
26+
uv run python3 $< $(ROUTES_GPX_NORMALIZED) $@
2727

2828

2929
routes/geojson/%.geojson: _bin/gpx_to_geojson.py routes/_gpx/%.gpx $(NEIGHBORHOODS)
3030
@mkdir -p $(@D)
31-
python3 $< --input routes/_gpx/$*.gpx --output $@
31+
uv run python3 $< --input routes/_gpx/$*.gpx --output $@
3232

3333
# Batch convert; use when building from scratch (e.g. CI)
3434
convert-routes:
3535
@mkdir -p routes/geojson
36-
python3 _bin/gpx_to_geojson.py --input $(foreach raw, $(ROUTE_RAW_GPX_FILES),$(raw))\
36+
uv run python3 _bin/gpx_to_geojson.py --input $(foreach raw, $(ROUTE_RAW_GPX_FILES),$(raw))\
3737
--output $(foreach raw, $(ROUTE_RAW_GPX_FILES),$(patsubst %.gpx, routes/geojson/%.geojson, $(notdir $(raw))))
3838

3939

4040
# All routes in one file
4141
routes/geojson/routes.geojson: _bin/merge_geojson.py $(ROUTE_GEOJSON_FILES)
42-
python3 $< $(ROUTE_GEOJSON_FILES) $@
42+
uv run python3 $< $(ROUTE_GEOJSON_FILES) $@
4343

4444
routes/gpx/%.gpx: _bin/normalize_gpx.py routes/_gpx/%.gpx
4545
@mkdir -p $(@D)
46-
python3 $< --input routes/_gpx/$*.gpx --output routes/gpx/$*.gpx
46+
uv run python3 $< --input routes/_gpx/$*.gpx --output routes/gpx/$*.gpx
4747

4848
# Batch normalize; use when building from scratch (e.g. CI)
4949
normalize-routes:
5050
@mkdir -p routes/gpx
51-
python3 _bin/normalize_gpx.py --input $(foreach raw, $(ROUTE_RAW_GPX_FILES),$(raw))\
51+
uv run python3 _bin/normalize_gpx.py --input $(foreach raw, $(ROUTE_RAW_GPX_FILES),$(raw))\
5252
--output $(foreach raw, $(ROUTE_RAW_GPX_FILES),$(patsubst routes/_gpx/%, routes/gpx/%,$(raw)))
5353

5454
$(TRANSIT_DATA):
5555
_bin/fetch_transit_data.sh
5656

5757
update-locations: _bin/update_location_transit.py $(TRANSIT_DATA_CSV) $(TRANSIT_DATA) $(NEIGHBORHOODS)
58-
python3 $<
58+
uv run python3 $<
5959

6060
# also generates rcc_weekends.ics
6161
rcc.ics: _bin/mkical.py $(ROUTES_YML)
62-
python3 $<
62+
uv run python3 $<
6363

6464
build: rcc.ics $(ROUTES_YML) $(ROUTE_GEOJSON_FILES)
6565
bundle exec jekyll build $(JEKYLL_FLAGS)
@@ -78,15 +78,15 @@ check-html:
7878
--cache '{ "timeframe": { "external": "30d" } }'
7979

8080
check-javascript:
81-
python3 _bin/check_javascript.py _site
81+
uv run python3 _bin/check_javascript.py _site
8282

8383
check-schedules: $(SCHEDULE)
84-
python3 _bin/check-schedules.py
84+
uv run python3 _bin/check-schedules.py
8585

8686
check: check-images check-html check-javascript check-schedules
8787

8888
og-route-images:
89-
python _bin/generate_route_images.py $(if $(URL_BASE_PATH),--base-path $(URL_BASE_PATH),)
89+
uv run python _bin/generate_route_images.py $(if $(URL_BASE_PATH),--base-path $(URL_BASE_PATH),)
9090

9191
serve: rcc.ics $(ROUTES_YML) $(ROUTE_GEOJSON_FILES)
9292
ls _config.yml | entr -r bundle exec jekyll serve --watch --drafts --host=0.0.0.0 $(JEKYLL_FLAGS)

README.md

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,30 @@
55
This repo contains the website for Race Condition Running
66
http://raceconditionrunning.com/
77

8-
Install dependencies with `pip3 install -r requirements.txt` and
9-
`bundle install`.
8+
## Building and Developing Locally
109

11-
To test locally, run `make serve` (requires [`entr`](https://github.com/eradman/entr); install with
12-
`brew install entr` or `sudo apt install entr`), after which the page will be available at
13-
[http://localhost:4000](http://localhost:4000).
10+
You should use virtual environments to isolate dependencies for Python.
11+
[`uv`](https://github.com/astral-sh/uv) is a great way to simplify dependency
12+
and virtual environment management, and it enables you to use per-project
13+
Python versions.
14+
15+
1. Install [`uv`](https://github.com/astral-sh/uv). Run `uv help` to make sure
16+
your installation was successful.
17+
2. Run: `uv sync` and `bundle install`.
18+
3. Install [`entr`](https://github.com/eradman/entr), either via running:
19+
`brew install entr` (for macOS) or `sudo apt install entr`.
20+
21+
### Running Locally
22+
23+
After you've installed the Python (`uv sync` ),
24+
Ruby (`bundle install`) dependencies and `entr` (see section above for commands),
25+
run:
26+
27+
> `make serve`
28+
29+
From the root of this directory.
30+
A successful deployment will serve a local instance of `raceconditionrunning.github.io`
31+
on [http://localhost:4000](`localhost:4000`).
1432

1533
The entire site is built by `_bin/mkical.py` and Jekyll; the live site is built
1634
and deployed by a GitHub action and served by GitHub pages.

pyproject.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[project]
2+
name = "raceconditionrunning-github-io"
3+
version = "0.1.0"
4+
description = "Website for Race Condition Running (RCR)"
5+
readme = "README.md"
6+
requires-python = ">=3.13"
7+
dependencies = [
8+
"gpxpy",
9+
"haversine",
10+
"icalendar",
11+
"joblib",
12+
"pyyaml",
13+
"requests",
14+
"tqdm",
15+
]
16+
17+
[project.optional-dependencies]
18+
route-images = [
19+
"playwright",
20+
"pillow",
21+
]

requirements.txt

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

0 commit comments

Comments
 (0)