Skip to content

Commit 902e9ce

Browse files
authored
Merge pull request #112 from ComputerScienceHouse/uv-project
Migrates to UV Package Management
2 parents 8014907 + 11349fe commit 902e9ce

11 files changed

Lines changed: 1702 additions & 78 deletions

File tree

‎.env.template‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ CALENDAR_TIMEZONE=
66

77
WATCHED_CHANNELS=
88
SLACK_API_TOKEN=
9-
SLACK_JUMPSTART_MESSAGE=
109
SLACK_SIGNING_SECRET=
1110

1211
WIKI_API=

‎.github/workflows/sonarqube.yml‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,11 @@ jobs:
2626
- name: Install dependencies
2727
run: |
2828
pip install uv
29-
uv pip install -r src/requirements.txt --system
30-
uv pip install -r tests/requirements.txt --system
29+
uv sync --group tests --frozen
3130
3231
- name: Run tests with coverage
3332
run: |
34-
pytest -v
33+
uv run pytest -v
3534
3635
- uses: SonarSource/sonarqube-scan-action@v6
3736
env:

‎Dockerfile‎

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,37 @@
1-
FROM ghcr.io/astral-sh/uv:python3.14-alpine AS docbuilder
21

3-
WORKDIR /jumpstartdocs
2+
FROM ghcr.io/astral-sh/uv:python3.14-alpine AS base
3+
4+
ENV UV_NO_CACHE=1
5+
WORKDIR /app
6+
7+
COPY pyproject.toml uv.lock ./
8+
RUN uv sync --group docs --frozen
9+
10+
FROM base AS docbuilder
11+
ENV UV_NO_CACHE=1
12+
13+
WORKDIR /appdocs
414

515
COPY mkdocs.yml .
616
COPY docs ./docs
717
COPY src ./src
818

9-
RUN uv pip install --no-cache-dir -r ./docs/requirements.txt --system && \
10-
zensical build
19+
WORKDIR /app
20+
21+
RUN uv run zensical build --config-file /appdocs/mkdocs.yml
1122

1223
FROM ghcr.io/astral-sh/uv:python3.14-alpine
24+
ENV UV_NO_CACHE=1
1325

14-
COPY src /jumpstart
15-
COPY --from=docbuilder /jumpstartdocs/site /jumpstart/docs
26+
COPY --from=base /app/.venv /app/.venv
27+
COPY src /app
28+
COPY --from=docbuilder /appdocs/site /app/docs
1629

17-
WORKDIR /jumpstart
30+
WORKDIR /app
1831

19-
RUN addgroup -g 2000 jumpgroup && adduser -S -u 1001 -G jumpgroup jumpstart && \
20-
uv pip install --no-cache-dir -r requirements.txt --system && rm requirements.txt
32+
RUN addgroup -g 2000 jumpgroup && \
33+
adduser -S -u 1001 -G jumpgroup jumpstart
2134

2235
USER jumpstart
2336

24-
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--log-config", "/jumpstart/logging_config.yaml", "--proxy-headers", "--forwarded-allow-ips", "*"]
37+
CMD ["uv", "run", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--log-config", "/app/logging_config.yaml", "--proxy-headers", "--forwarded-allow-ips", "*"]

‎README.md‎

Lines changed: 47 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ All information displayed has been authorized to been shown.
1111
Documentation for the project can be found be appended /docs to the url
1212
All HTML requests that are sent in the project can be seen by appending /swag
1313

14-
This project uses Python, [FastAPI](https://fastapi.tiangolo.com/), HTML/CSS, and Javascript.
14+
This project uses Python, [FastAPI](https://fastapi.tiangolo.com/), [UV](https://docs.astral.sh/uv/), HTML/CSS, and Javascript.
1515
See it live [here](https://jumpstart.csh.rit.edu)!
1616

1717
## Installing
@@ -43,26 +43,59 @@ Jumpstart also has support for Docker Compose, a extended version of docker that
4343

4444
(This is a really cool thing! If you use docker often, check it out!)
4545
```
46-
docker compose up
46+
docker compose up --build
4747
```
4848

49-
## Development
49+
## Local Development
5050

51-
### Setup
52-
1. Install uv on your system if not already on it (this just makes it easy)
53-
2. Run: `uv venv .venv`
54-
3. Activate the virtual environment
51+
### NOTE: MAKE SURE TO USE `uv add` IN THIS PROJECT TO KEEP `pyproject.toml` and `uv.lock` UPDATED!
52+
## UV Setup
53+
54+
Install UV on your system if not already on it. If you already have it installed, you can skip down to the Project Setup page
55+
56+
UV is a blazingly fast python package manager written in Rust. The Jumpstart project uses UV for speed and simplicity. Run the linked install command for your operating system
57+
58+
__Linux and macOS__
59+
```
60+
curl -LsSf https://astral.sh/uv/install.sh | sh
61+
```
62+
63+
__Windows (Powershell)__
64+
```
65+
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
66+
```
67+
68+
## UV Commands Useful For this Project
69+
70+
__uv sync__: UV sync serves to replace pip install -r requirements.txt. This command syncs your virtual environment to match the `pyproject.toml` file. By default, it will only copy the default dependencies for the project (found in dependencies)
71+
72+
__uv sync --group $GROUP__: UV sync with the added group flag will ALSO install all dependencies found in that group ALONG with the default dependencies.
73+
74+
__uv sync --frozen__: When reading the UV Sync, it reads ONLY the `uv.lock` file, and does not attempt to make any modifications, and failing instead. This is incredibly useful for reproducibility, which is why its used in the docker file.
75+
76+
__uv sync --all-groups__: UV sync, along with installing dependencies of every group
77+
78+
__uv add $PACKAGE__: UV serves to replace pip install $PACKAGE. It installs the most recent version of the inserted package, and adds it to the projects default dependencies
79+
80+
__uv add --group $GROUP $PACKAGE__: Same as UV add, but adds the package to the group instead of the default project dependencies.
81+
82+
## UV Groups Used in this Project
83+
__dev__: Dependencys needed for testing locally
84+
85+
__docs__: Dependencys used for creating the statically generated website on /docs
86+
87+
__tests__: Dependencys used for running the unit tests.
88+
89+
## Project Setup
90+
1. Run: `uv venv .venv --python 3.14`
91+
2. Activate the virtual environment
5592
* Bash: `source .venv/bin/activate`
5693
* Fish: `source .venv/bin/activate.fish`
5794
* Windows: `.venv\Scripts\activate`
5895
* Other: Good luck!
59-
4. Run:
60-
* `uv pip install -r dev-requirements.txt`
61-
* `uv pip install -r src/requirements.txt`
62-
* `uv pip install -r tests/requirements,txt`
63-
* `uv pip install -r docs/requirements.txt`
64-
5. Run: `pre-commit install`
65-
6. You're all set!
96+
3. Run: `uv sync --all-groups`
97+
4. Run: `pre-commit install`
98+
5. You're all set!
6699

67100
### Testing
68101

‎dev-requirements.txt‎

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

‎docker-compose.yml‎

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,5 @@ services:
66
container_name: Jumpstart
77
ports:
88
- "8000:8000"
9-
environment:
10-
- CALENDAR_URL=${CALENDAR_URL}
11-
- CALENDAR_OUTLOOK_DAYS=${CALENDAR_OUTLOOK_DAYS}
12-
- CALENDAR_EVENT_MAXIMUM=${CALENDAR_EVENT_MAXIMUM}
13-
- CALENDAR_TIMEZONE=${CALENDAR_TIMEZONE}
14-
15-
- WATCHED_CHANNELS=${WATCHED_CHANNELS}
16-
- SLACK_API_TOKEN=${SLACK_API_TOKEN}
17-
- SLACK_JUMPSTART_MESSAGE=${SLACK_JUMPSTART_MESSAGE}
18-
- SLACK_SIGNING_SECRET=${SLACK_SIGNING_SECRET}
19-
20-
- WIKI_API=${WIKI_API}
21-
- WIKIBOT_USER=${WIKIBOT_USER}
22-
- WIKIBOT_PASSWORD=${WIKIBOT_PASSWORD}
23-
- WIKI_CATEGORY=${WIKI_CATEGORY}
9+
env_file:
10+
- .env

‎docs/requirements.txt‎

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

‎pyproject.toml‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
[project]
2+
name = "jumpstart"
3+
version = "0.1.0"
4+
description = "A graphical interface that displays information in the elevator lobby of Computer Science House."
5+
readme = "README.md"
6+
requires-python = ">=3.14"
7+
dependencies = [
8+
"aiohttp==3.13.3",
9+
"arrow==1.4.0",
10+
"dotenv==0.9.9",
11+
"fastapi==0.135.1",
12+
"google-api-python-client==2.191.0",
13+
"httpx==0.28.1",
14+
"icalendar==7.0.3",
15+
"jinja2==3.1.6",
16+
"logging==0.4.9.6",
17+
"python-multipart==0.0.22",
18+
"pyyaml==6.0.3",
19+
"recurring-ical-events==3.8.1",
20+
"requests==2.32.5",
21+
"slack-sdk==3.40.1",
22+
"uvicorn==0.41.0",
23+
]
24+
25+
[dependency-groups]
26+
dev = [
27+
"pre-commit==4.5.1",
28+
"pytest==9.0.2",
29+
"ruff==0.15.6",
30+
]
31+
docs = [
32+
"mkdocs-git-revision-date-localized-plugin==1.5.1",
33+
"mkdocs-minify-plugin==0.8.0",
34+
"mkdocstrings==1.0.3",
35+
"mkdocstrings-python==2.0.3",
36+
"pymdown-extensions==10.21.2",
37+
"zensical==0.0.24",
38+
]
39+
tests = [
40+
"coverage==7.13.4",
41+
"pytest==9.0.2",
42+
]

‎src/requirements.txt‎

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

‎tests/requirements.txt‎

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

0 commit comments

Comments
 (0)