Skip to content

Commit 8df1e22

Browse files
Switch to UV + dependency upgrade + Python 3.13 + replace filemagic with python-magic + remove docker compose (#348)
1 parent c1f860c commit 8df1e22

22 files changed

Lines changed: 1805 additions & 706 deletions

.github/workflows/python-tests.yml

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ jobs:
99
pre-commit:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v3
13-
- uses: actions/setup-python@v3
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-python@v5
1414
- uses: pre-commit/action@v3.0.0
1515

1616
build:
@@ -32,38 +32,42 @@ jobs:
3232

3333

3434
steps:
35-
- uses: actions/checkout@v3
35+
- uses: actions/checkout@v4
36+
37+
- name: Install uv
38+
uses: astral-sh/setup-uv@v5
39+
40+
- name: "Set up Python"
41+
uses: actions/setup-python@v5
42+
with:
43+
python-version-file: ".python-version"
44+
3645
- name: Apt update
3746
run: sudo apt update
47+
3848
- name: Install apt packages
3949
run: sudo apt install -y graphicsmagick mupdf-tools ghostscript unoconv python3-dev
40-
- name: Set up Python
41-
uses: actions/setup-python@v4
42-
with:
43-
python-version: "3.10"
4450

45-
- name: Install python packages
46-
run: |
47-
python -m pip install --upgrade pip
48-
pip install -r requirements.txt
51+
- name: Install the project
52+
run: uv sync --dev
4953

5054
- name: Django checks
51-
run: ./manage.py check
55+
run: uv run ./manage.py check
5256

5357
- name: Check migrations
54-
run: ./manage.py makemigrations --dry-run --check
58+
run: uv run ./manage.py makemigrations --dry-run --check
5559

5660
- name: mypy
57-
run: mypy
61+
run: uv run mypy
5862

5963
- name: Statics checks
60-
run: ./manage.py collectstatic --noinput -v 0
64+
run: uv run ./manage.py collectstatic --noinput -v 0
6165

6266
- name: pytest with SQLite
63-
run: pytest -k "not unoconv"
67+
run: uv run pytest -k "not unoconv"
6468

6569
- name: pytest with PostgreSQL
66-
run: pytest -k "not unoconv" -m postgresql
70+
run: uv run pytest -k "not unoconv" -m postgresql
6771
env:
6872
DB_URL: postgres://postgres:postgres@localhost:5432/postgres
6973

.pre-commit-config.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
repos:
22
- repo: https://github.com/psf/black
3-
rev: 24.10.0
3+
rev: 25.1.0
44
hooks:
55
- id: black
66

77
- repo: https://github.com/pycqa/isort
8-
rev: 5.13.2
8+
rev: 6.0.1
99
hooks:
1010
- id: isort
1111

@@ -17,7 +17,7 @@ repos:
1717
files: \.html$
1818

1919
- repo: https://github.com/asottile/pyupgrade
20-
rev: v3.19.0
20+
rev: v3.19.1
2121
hooks:
2222
- id: pyupgrade
2323
args: [ "--py310-plus" ]
@@ -30,13 +30,13 @@ repos:
3030
- id: djjs
3131

3232
- repo: https://github.com/adamchainz/django-upgrade
33-
rev: 1.22.2
33+
rev: 1.24.0
3434
hooks:
3535
- id: django-upgrade
3636
args: [ --target-version, "4.1" ]
3737

3838
- repo: https://github.com/charliermarsh/ruff-pre-commit
39-
rev: 'v0.8.2'
39+
rev: 'v0.11.3'
4040
hooks:
4141
- id: ruff
4242
args: [--fix, --exit-non-zero-on-fix]

.python-version

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

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
This page tries to contain all changes made on DocHub.
44

5+
# 2025.6.0
6+
7+
* Switch to UV as the package manager
8+
* Upgrade dependencies
9+
* Switch to Python 3.13
10+
* Remove deprecated `filemagic` and replace with `python-magic`
11+
* Remove unmaintained docker compose setup
12+
513
# 2024.3.0
614

715
* Upgrade JS libraries (notable change is Turbo 8)

Makefile

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,7 @@
1-
ifeq ($(CI),true)
2-
PY=python3
3-
else
4-
ifndef VIRTUAL_ENV
5-
PY=ve/bin/python
6-
else
7-
PY=python3
8-
endif
9-
endif
1+
PY=uv run
102

113
init: database
124

13-
install: packages
14-
15-
ve:
16-
$(PY) -m venv ve
17-
18-
packages: ve
19-
ve/bin/pip install -r requirements.txt
205

216
database:
227
$(PY) manage.py migrate -v 0
@@ -26,10 +11,6 @@ database:
2611
@echo "Creating user blabevue with password 'test'"
2712
@echo "from users.models import User; u=User.objects.get_or_create(netid='blabevue', first_name='Bertrand', last_name='Labevue', email='blabevue@fake.ulb.ac.be'); u[0].set_password('test'); u[0].save()" | $(PY) manage.py shell > /dev/null
2813

29-
# @echo "Loading an minimal course tree"
30-
# $(PY) manage.py load_tree
31-
# $(PY) manage.py load_courses
32-
3314
@echo "Creating some tags"
3415
@echo "[__import__('tags').models.Tag.objects.create(name=x) for x in ('syllabus', 'officiel', 'examen', 'resume', 'synthese', 'notes')]" | $(PY) manage.py shell > /dev/null
3516

README.md

Lines changed: 25 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
[![License](https://img.shields.io/badge/license-AGPL%20v3-blue.svg)](https://github.com/UrLab/dochub/blob/master/LICENSE)
44

5-
DocHub is a website, written in django. It's main goal is to provide a space for students (for now form the [ULB](https://ulb.ac.be) university) to collaborate, help each other and distribute old exams and exercices.
5+
DocHub is a website written in django. Its main goal is to provide a space for students
6+
(for now form the [ULB](https://ulb.ac.be) university) to collaborate, help each other and distribute old exams and exercises.
67

78
There is a [live instance of DocHub](https://dochub.be) hosted by [UrLab](https://urlab.be) and the [Cercle Informatique](https://cerkinfo.be).
89

@@ -14,11 +15,22 @@ There is a [live instance of DocHub](https://dochub.be) hosted by [UrLab](https:
1415

1516
## Tech
1617

17-
DocHub currently (Feb 2022) runs with Python 3.10 and Postgresql 14.
18+
DocHub currently (Feb 2025) runs with Python 3.13 and Postgresql 16.
1819

19-
### Dependencies
20+
### Installation
21+
22+
If you install the packages listed above and follow the installation steps exactly, you should have a running version
23+
of DocHub on your machine. If it's not the case, **you are not the problem**, it means we have a bug.
24+
25+
Please open an issue with the output of your console and describe the problem you encountered, we **will** and will fix
26+
it for you and all the next users :rocket:
27+
28+
First, install uv and system dependencies:
2029

2130
```console
31+
# Install uv
32+
curl -LsSf https://astral.sh/uv/install.sh | sh
33+
2234
# Ubuntu
2335
sudo apt-get install unoconv python3-dev ruby libtiff5-dev libjpeg-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python-tk mupdf-tools redis-server
2436
sudo systemctl enable --now redis-server
@@ -30,27 +42,8 @@ sudo pacman -S unoconv ruby python mupdf-tools redis
3042
sudo systemctl enable --now redis
3143
```
3244

33-
34-
### Installation
35-
36-
If you install the packages listed above and follow the installation steps exactly, you should have a running version
37-
of DocHub on your machine. If it's not the case, **you are not the problem**, it means we have a bug.
38-
39-
Please open an issue with the output of your console and describe the problem you encountered, we **will** and will fix
40-
it for you and the all the next users :rocket:
41-
42-
To create the virtual environment and install the requirements, run the following command:
43-
```console
44-
make install
45-
46-
# Alternatively, if you prefer to do it by hand
47-
python3 -m venv ve
48-
source ve/bin/activate
49-
pip install -r requirements.txt
50-
```
51-
52-
To create a database and fill it with some dummy data, run the following command. Observe the output, it
53-
will tell you the credentials you can then use to log in.
45+
To create a database and fill it with some fake data, run the following command.
46+
Observe the output, it will tell you the credentials you can then use to log in.
5447
```console
5548
make database
5649
```
@@ -60,45 +53,44 @@ make database
6053
This will have to be done each time you want to run DocHub.
6154

6255
```console
63-
source ve/bin/activate
64-
./manage.py runserver
56+
uv run manage.py runserver
6557
```
6658

6759
Then go http://localhost:8000/
6860

6961
There will already be 2 users in the database, both with `test` as a password:
7062

71-
- $(USER) : your username on your machine
63+
- $(USER): your username on your machine
7264
- blabevue
7365

7466
### Misc
7567

7668
#### Add another user to the db
7769

7870
```console
79-
./manage.py createuser
71+
uv run manage.py createuser
8072
```
8173

8274
#### Requirements
8375

84-
To add a requirement, write it in `requirements.in` file, and generate the requirements.txt file with the following command
76+
To add a requirement, use:
8577

8678
```console
87-
pip-compile
79+
uv add <package-name>
8880
```
8981

9082
## Testing
9183

9284
Run only fast tests (total time < 2 sec) : not testing actual file conversions
9385

9486
```console
95-
py.test -k "not slow"
87+
uv run pytest -k "not slow"
9688
```
9789

9890
Run all tests (~20 sec)
9991

10092
```console
101-
py.test
93+
uv run pytest
10294
```
10395

10496
## Contribute !
@@ -112,13 +104,9 @@ Check the issues tab and look and the issues tagged with the `easy pick` label.
112104
Assign yourself to an issue and start working on it *in your own branch*. If you have any questions or issue, feel free to ask them in the issue or tag some people you know can help.<br/>
113105
If your PR is completed, ask for reviews either by mentioning the people you want to review your PR (You can also set them as reviewers on the right) or by asking on our irc channel **#urlab** on libera.chat.
114106

115-
### Any question ?
116-
117-
Come by #urlab on libera.chat and feel free to ask anything !
118-
119107
## License
120108

121-
Copyright 2012 - 2022, Cercle Informatique ASBL. All rights reserved.
109+
Copyright 2012, Cercle Informatique ASBL. All rights reserved.
122110

123111
This program is free software: you can redistribute it and/or modify it
124112
under the terms of the GNU Affero General Public License as published by

build.sh

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

catalog/management/commands/download_programs.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: disable-error-code="union-attr, arg-type"
12
from typing import Any
23

34
import json

docker/Dockerfile

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

docker/celery.sh

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)