Skip to content

Commit 73f5feb

Browse files
committed
use uv and create a package
1 parent 70b2806 commit 73f5feb

22 files changed

+766
-852
lines changed

.github/dependabot.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ updates:
33
- package-ecosystem: pip
44
directory: "/"
55
schedule:
6-
interval: daily
7-
time: "08:00"
8-
timezone: Europe/Prague
9-
open-pull-requests-limit: 10
6+
interval: weekly
7+
open-pull-requests-limit: 1
8+
groups:
9+
python:
10+
patterns: ["*"]
11+
- package-ecosystem: github-actions
12+
directory: "/"
13+
schedule:
14+
interval: weekly
15+
open-pull-requests-limit: 1

.github/workflows/check_links.yml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,10 @@ jobs:
1111
issues: write # required for peter-evans/create-issue-from-file
1212
steps:
1313
- uses: actions/checkout@v4
14-
- uses: actions/checkout@v3
15-
- name: Set up Python
16-
uses: actions/setup-python@v4
17-
with:
18-
python-version: "3.12"
19-
- name: Install dependencies
20-
run: python -m pip install -r requirements.txt
14+
- name: Install uv
15+
uses: astral-sh/setup-uv@v6
2116
- name: Build documentation
22-
run: sphinx-build -nWaE . _build
17+
run: uv run sphinx-build -nWaE . _build
2318
- name: Link Checker
2419
id: lychee
2520
uses: lycheeverse/lychee-action@v2

.github/workflows/generate_grants.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,11 @@ jobs:
99
build:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v3
13-
- name: Set up Python
14-
uses: actions/setup-python@v4
15-
with:
16-
python-version: "3.12"
17-
- name: Install dependencies
18-
run: python -m pip install -r requirements.txt
12+
- uses: actions/checkout@v4
13+
- name: Install uv
14+
uses: astral-sh/setup-uv@v6
1915
- name: Generate the list of grants
20-
run: python _scripts/generate_grants.py > ./operations/grants.rst
16+
run: uv run python _scripts/generate_grants.py > ./operations/grants.rst
2117
env:
2218
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2319
- name: Create PR

.github/workflows/test.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,10 @@ jobs:
66
test:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@v3
10-
- name: Set up Python
11-
uses: actions/setup-python@v4
12-
with:
13-
python-version: "3.12"
14-
- name: Install dependencies
15-
run: python -m pip install -r requirements.txt
9+
- uses: actions/checkout@v4
10+
- name: Install uv
11+
uses: astral-sh/setup-uv@v6
1612
- name: Test
17-
run: pytest
13+
run: uv run pytest
1814
- name: Build documentation
19-
run: sphinx-build -nWaE . _build
15+
run: uv run sphinx-build -nWaE . _build

.readthedocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build:
55
python: "3.12"
66
python:
77
install:
8-
- requirements: requirements.txt
8+
- method: pip
99
sphinx:
1010
configuration: conf.py
1111
fail_on_warning: true

CONTRIBUTING.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,15 @@ Abyste něco změnili v textech, nemusíte nic instalovat. Obsah lze upravovat o
1313
Instalace
1414
---------
1515

16-
Když toho upravujete víc, nebo máte zálusk na nějaké složitější kejkle, je lepší mít materiály nainstalované na svém počítači. Projekt vyžaduje Python 3.12.
16+
Když toho upravujete víc, nebo máte zálusk na nějaké složitější kejkle, je lepší mít materiály nainstalované na svém počítači. Bude k tomu potřeba `uv <https://docs.astral.sh/uv/>`_:
1717

1818
#. Stáhněte projekt: ``git clone https://github.com/pyvec/docs.pyvec.org.git``
19-
#. Vytvořte si a aktivujte virtuální prostředí
20-
#. Nainstalujte do prostředí závislosti: ``python -m pip install -r requirements.txt``
19+
#. Nainstalujte: ``uv sync --group=dev``
2120

2221
Běžná práce
2322
-----------
2423

25-
#. Ve virtuálním prostředí spusťte projekt: ``sphinx-autobuild . _build``
24+
#. Ve virtuálním prostředí spusťte projekt: ``uv sphinx-autobuild . _build``
2625
#. Otevřete si v prohlížeči `<http://127.0.0.1:8000>`_
2726
#. V editoru upravujete texty a v prohlížeči si kontrolujete výsledek
2827
#. Projekt zastavíte v terminálu pomocí :kbd:`Ctrl+C`
@@ -102,4 +101,4 @@ V adresáři ``_scripts`` je skript ``generate_grants.py``, který:
102101
* vygeneruje soubor ``operations/grants.rst`` z dat na `pyvec/money <https://github.com/pyvec/money>`_ a ze šablony ``operations/grants.rst``,
103102
* commitne a pushne jej přes Git do repozitáře.
104103

105-
Hlasování o grantech probíhá :ref:`pomocí reakcí <jak-hlasovani>` na GitHub Issues a tento skript hlasování archivuje sem do dokumentace pro účely jednoduššího vyhledávání, zálohy, kdyby se s `pyvec/money <https://github.com/pyvec/money>`_ něco stalo, a pro nějakou historickou evidenci. Kanonickým zdrojem pravdy ale zůstává hlasování přímo na GitHub Issues, toto je jen automatizovaný přepis. Skript započítává pouze hlasy od členů výboru (podle souboru ``board.yml``).
104+
Hlasování o grantech probíhá :ref:`pomocí reakcí <jak-hlasovani>` na GitHub Issues a tento skript hlasování archivuje sem do dokumentace pro účely jednoduššího vyhledávání, zálohy, kdyby se s `pyvec/money <https://github.com/pyvec/money>`_ něco stalo, a pro nějakou historickou evidenci. Kanonickým zdrojem pravdy ale zůstává hlasování přímo na GitHub Issues, toto je jen automatizovaný přepis. Skript započítává pouze hlasy od členů výboru (podle souboru ``src/pyvec_docs/board.yml``).

_scripts/generate_grants.py

Lines changed: 5 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,21 @@
11
import os
2-
import re
3-
from datetime import date
42
from operator import itemgetter
53
from pathlib import Path
64

75
import requests
8-
import strictyaml as yaml
96
from jinja2 import Template
107

8+
from pyvec_docs.board import BOARD_HISTORY
9+
from pyvec_docs.grants import get_lock_date, get_votes, remove_comments, to_date
10+
1111

1212
GITHUB_TOKEN = os.getenv("GITHUB_TOKEN")
1313
GITHUB_API_HEADERS = {
1414
"Accept": "application/vnd.github.squirrel-girl-preview",
1515
"Authorization": f"token {GITHUB_TOKEN}",
1616
}
1717
GITHUB_API_URL = "https://api.github.com/repos/pyvec/money/issues"
18-
REACTIONS_MAPPING = {"+1": "ano", "-1": "ne", "eyes": "zdržel(a) se"}
19-
CONTENT_PATH = Path(__file__).parent.parent
20-
21-
BOARD_HISTORY_SCHEMA = yaml.Seq(
22-
yaml.Map(
23-
{
24-
"from": yaml.Datetime(),
25-
"members": yaml.MapPattern(yaml.Str(), yaml.Str()),
26-
}
27-
)
28-
)
29-
BOARD_HISTORY_PATH = Path(__file__).parent.parent / "board.yml"
30-
BOARD_HISTORY = sorted(
31-
yaml.load(BOARD_HISTORY_PATH.read_text(), BOARD_HISTORY_SCHEMA).data,
32-
key=itemgetter("from"),
33-
reverse=True,
34-
)
35-
36-
37-
def to_date(iso_datetime_string):
38-
iso_date_string, _ = iso_datetime_string.split("T")
39-
return date.fromisoformat(iso_date_string)
40-
41-
42-
def remove_comments(html):
43-
return re.sub(r"<!--[^<]+-->", "", html).strip()
44-
45-
46-
def get_board_member_name(username, voted_at, board_history=None):
47-
board_history = board_history or BOARD_HISTORY
48-
for board in board_history: # sorted from the most recent
49-
if voted_at > board["from"].date():
50-
return board["members"].get(username)
51-
return None
52-
53-
54-
def get_votes(reactions, voted_at, board_history=None):
55-
for reaction in reactions:
56-
username = reaction["user"]["login"]
57-
name = get_board_member_name(username, voted_at, board_history)
58-
if name: # else not reaction from a board member
59-
text = REACTIONS_MAPPING.get(reaction["content"])
60-
if text:
61-
yield {"name": name, "text": text}
62-
63-
64-
def get_lock_date(events):
65-
for event in reversed(events):
66-
if event["event"] == "locked":
67-
return to_date(event["created_at"])
18+
CONTENT_PATH = Path(__file__).parent.parent.parent.parent
6819

6920

7021
if __name__ == "__main__":
@@ -103,7 +54,7 @@ def get_lock_date(events):
10354

10455
res = requests.get(issue["reactions"]["url"], headers=GITHUB_API_HEADERS)
10556
res.raise_for_status()
106-
votes = list(get_votes(res.json(), voted_at))
57+
votes = list(get_votes(res.json(), voted_at, BOARD_HISTORY))
10758

10859
grants.append(
10960
{

conf.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
# Configuration file for the Sphinx documentation builder
22

33
import os
4-
import sys
5-
6-
7-
# -- Environment -------------------------------------------------------------
8-
9-
# Explicitly put the extensions directory to Python path
10-
sys.path.append(os.path.abspath("_extensions"))
114

125

136
# -- Project information -----------------------------------------------------
@@ -32,9 +25,9 @@
3225
"sphinx.ext.todo",
3326
"sphinx.ext.githubpages",
3427
"sphinxemoji.sphinxemoji",
35-
"slack",
36-
"twitter",
37-
"gh_repo",
28+
"pyvec_docs.ext.slack",
29+
"pyvec_docs.ext.twitter",
30+
"pyvec_docs.ext.gh_repo",
3831
"myst_parser",
3932
]
4033

@@ -69,6 +62,8 @@
6962
".github",
7063
".pytest_cache",
7164
".ruff_cache",
65+
"src",
66+
"tests",
7267
]
7368

7469
# The name of the Pygments (syntax highlighting) style to use.

0 commit comments

Comments
 (0)