Skip to content

Commit bf02522

Browse files
authored
Simplify setup process with uv (#71)
Now uv will handle python installation, dependencies and tasks so we don't need to install many things separately Also remove sketchviz git submodule in favor of installing using NPM, now we just need to run npm install. A task defined inside pyproject.toml will expose a environment variable to point into the installed package inside node_modules README and GitHub deploy workflow were updated as well with the new changes
1 parent d6fbbb2 commit bf02522

File tree

13 files changed

+1769
-2687
lines changed

13 files changed

+1769
-2687
lines changed

.github/workflows/deploy-site.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
name: Deploy Python Perú to GitHub Pages
23

34
on:
@@ -10,14 +11,13 @@ permissions:
1011

1112
jobs:
1213
deploy:
13-
runs-on: ubuntu-latest
14+
runs-on: ubuntu-24.04
1415
steps:
1516
- uses: actions/checkout@v4
16-
with:
17-
submodules: true
18-
- uses: actions/setup-python@v5
19-
with:
20-
python-version: '3.13'
17+
18+
- name: Install uv
19+
uses: astral-sh/setup-uv@v5
20+
2121
- name: Set Locale
2222
run: |
2323
sudo apt-get update && sudo apt-get install tzdata locales -y && sudo locale-gen es_ES.UTF-8
@@ -29,16 +29,16 @@ jobs:
2929
locale
3030
locale -c -k LC_NUMERIC
3131
localectl status
32-
- name: Install Dependencies
33-
run: |
34-
pip install -r requirements.txt
3532
- name: Install graphviz
3633
run: |
3734
sudo apt-get install graphviz nodejs npm
38-
sudo ./bin/install-sketchviz.sh
35+
- name: Install Dependencies
36+
run: |
37+
uv sync
38+
npm install
3939
- name: Build Blog
4040
run: |
41-
ablog build
41+
uv run poe build
4242
- name: Publish to GitHub Pages
4343
uses: peaceiris/actions-gh-pages@v4
4444
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,3 +215,5 @@ _website/
215215
# python.pe
216216
_static/images/gravatar/
217217
_static/images/sketchviz/
218+
219+
node_modules/

.gitmodules

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

README.md

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,73 @@
11
# Python Peru's Website
22

3+
## Install build tools
34

45
To build, first you need to install graphviz:
56

67
1. macOS with Homebrew
8+
79
```sh
810
brew install graphviz
911
```
1012

1113
2. macOS with MacPorts
14+
1215
```sh
1316
sudo port install graphviz
1417
```
1518

1619
3. apt-based Linux distribution
20+
1721
```sh
1822
sudo apt install graphviz
1923
```
2024

2125
Then make sure you have installed node and npm
2226

2327
1. macOS with Homebrew
28+
2429
```sh
2530
brew install node
2631
```
2732

2833
2. macOS with MacPorts
34+
2935
```sh
3036
sudo port install nodejs21 npm10
3137
```
3238

3339
3. apt-based Linux distribution
40+
3441
```sh
3542
sudo apt install nodejs npm
3643
```
3744

3845
Install sketchviz
39-
```sh
40-
sudo ./bin/install-sketchviz.sh
41-
```
42-
43-
Make sure you have Python 3.12 installed. Then install `poetry`:
4446

4547
```sh
46-
pip install -U poetry
48+
npm i
4749
```
4850

51+
Install `uv`, follow the instructions in their documentation https://docs.astral.sh/uv/getting-started/installation/,
52+
`uv` will handle all the dependencies and the python installation as well. So we don't need to install `python`
53+
separately.
54+
4955
Then install all the necessary packages (make sure to change to the root directory of the project):
5056

51-
```sh
52-
poetry install
57+
```shell
58+
uv sync
5359
```
5460

61+
## Building the site
62+
5563
You can build the html files of the blog by running the following command:
5664

57-
```sh
58-
poetry run ablog build
65+
```shell
66+
uv run poe build
5967
```
6068

6169
Then you can serve the files locally using this command:
70+
6271
```sh
63-
poetry run ablog serve
72+
uv run ablog serve
6473
```

bin/install-sketchviz.sh

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

deps/sketchviz

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

ext/sketchviz.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ def run(self):
6767
filename = h.digest().hex()
6868
filename = f"{filename}{FILENAME_EXT}"
6969
save_path = os.path.join(save_path, filename)
70-
subprocess.run(["sketchviz", temp_name, save_path], check=True)
70+
# TODO: add a proper way to alert user when this binary is not found
71+
binary_path = os.environ.get("SKETCHVIZ_BINARY")
72+
subprocess.run([binary_path, temp_name, save_path], check=True)
7173
os.remove(temp_name)
7274
logger.info(f"Sketchviz: Created SVG image: {save_path}")
7375

0 commit comments

Comments
 (0)