Skip to content

Use uv and create a package #413

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ updates:
- package-ecosystem: pip
directory: "/"
schedule:
interval: daily
time: "08:00"
timezone: Europe/Prague
open-pull-requests-limit: 10
interval: weekly
open-pull-requests-limit: 1
groups:
python:
patterns: ["*"]
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: weekly
open-pull-requests-limit: 1
11 changes: 3 additions & 8 deletions .github/workflows/check_links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,10 @@ jobs:
issues: write # required for peter-evans/create-issue-from-file
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.12"
- name: Install dependencies
run: python -m pip install -r requirements.txt
- name: Install uv
uses: astral-sh/setup-uv@v6
- name: Build documentation
run: sphinx-build -nWaE . _build
run: uv run sphinx-build -nWaE . _build
- name: Link Checker
id: lychee
uses: lycheeverse/lychee-action@v2
Expand Down
12 changes: 4 additions & 8 deletions .github/workflows/generate_grants.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,11 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.12"
- name: Install dependencies
run: python -m pip install -r requirements.txt
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v6
- name: Generate the list of grants
run: python _scripts/generate_grants.py > ./operations/grants.rst
run: uv run python _scripts/generate_grants.py > ./operations/grants.rst
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create PR
Expand Down
14 changes: 5 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,10 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.12"
- name: Install dependencies
run: python -m pip install -r requirements.txt
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v6
- name: Test
run: pytest
run: uv run pytest
- name: Build documentation
run: sphinx-build -nWaE . _build
run: uv run sphinx-build -nWaE . _build
3 changes: 2 additions & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ build:
python: "3.12"
python:
install:
- requirements: requirements.txt
- method: pip
path: .
sphinx:
configuration: conf.py
fail_on_warning: true
9 changes: 4 additions & 5 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,15 @@ Abyste něco změnili v textech, nemusíte nic instalovat. Obsah lze upravovat o
Instalace
---------

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.
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/>`_:

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

Běžná práce
-----------

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

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``).
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``).
59 changes: 5 additions & 54 deletions _scripts/generate_grants.py
Original file line number Diff line number Diff line change
@@ -1,70 +1,21 @@
import os
import re
from datetime import date
from operator import itemgetter
from pathlib import Path

import requests
import strictyaml as yaml
from jinja2 import Template

from pyvec_docs.board import BOARD_HISTORY
from pyvec_docs.grants import get_lock_date, get_votes, remove_comments, to_date


GITHUB_TOKEN = os.getenv("GITHUB_TOKEN")
GITHUB_API_HEADERS = {
"Accept": "application/vnd.github.squirrel-girl-preview",
"Authorization": f"token {GITHUB_TOKEN}",
}
GITHUB_API_URL = "https://api.github.com/repos/pyvec/money/issues"
REACTIONS_MAPPING = {"+1": "ano", "-1": "ne", "eyes": "zdržel(a) se"}
CONTENT_PATH = Path(__file__).parent.parent

BOARD_HISTORY_SCHEMA = yaml.Seq(
yaml.Map(
{
"from": yaml.Datetime(),
"members": yaml.MapPattern(yaml.Str(), yaml.Str()),
}
)
)
BOARD_HISTORY_PATH = Path(__file__).parent.parent / "board.yml"
BOARD_HISTORY = sorted(
yaml.load(BOARD_HISTORY_PATH.read_text(), BOARD_HISTORY_SCHEMA).data,
key=itemgetter("from"),
reverse=True,
)


def to_date(iso_datetime_string):
iso_date_string, _ = iso_datetime_string.split("T")
return date.fromisoformat(iso_date_string)


def remove_comments(html):
return re.sub(r"<!--[^<]+-->", "", html).strip()


def get_board_member_name(username, voted_at, board_history=None):
board_history = board_history or BOARD_HISTORY
for board in board_history: # sorted from the most recent
if voted_at > board["from"].date():
return board["members"].get(username)
return None


def get_votes(reactions, voted_at, board_history=None):
for reaction in reactions:
username = reaction["user"]["login"]
name = get_board_member_name(username, voted_at, board_history)
if name: # else not reaction from a board member
text = REACTIONS_MAPPING.get(reaction["content"])
if text:
yield {"name": name, "text": text}


def get_lock_date(events):
for event in reversed(events):
if event["event"] == "locked":
return to_date(event["created_at"])
CONTENT_PATH = Path(__file__).parent.parent.parent.parent


if __name__ == "__main__":
Expand Down Expand Up @@ -103,7 +54,7 @@ def get_lock_date(events):

res = requests.get(issue["reactions"]["url"], headers=GITHUB_API_HEADERS)
res.raise_for_status()
votes = list(get_votes(res.json(), voted_at))
votes = list(get_votes(res.json(), voted_at, BOARD_HISTORY))

grants.append(
{
Expand Down
15 changes: 5 additions & 10 deletions conf.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
# Configuration file for the Sphinx documentation builder

import os
import sys


# -- Environment -------------------------------------------------------------

# Explicitly put the extensions directory to Python path
sys.path.append(os.path.abspath("_extensions"))


# -- Project information -----------------------------------------------------
Expand All @@ -32,9 +25,9 @@
"sphinx.ext.todo",
"sphinx.ext.githubpages",
"sphinxemoji.sphinxemoji",
"slack",
"twitter",
"gh_repo",
"pyvec_docs.ext.slack",
"pyvec_docs.ext.twitter",
"pyvec_docs.ext.gh_repo",
"myst_parser",
]

Expand Down Expand Up @@ -69,6 +62,8 @@
".github",
".pytest_cache",
".ruff_cache",
"src",
"tests",
]

# The name of the Pygments (syntax highlighting) style to use.
Expand Down
16 changes: 8 additions & 8 deletions operations/grants.rst
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ Dne 25. 7. 2023 požádal uživatel `@clytaemnestra <https://github.com/clytaemn
2990

**Na jakou věc to je?**
trička na EuroPython pro stankaře
trička na EuroPython pro stankaře

**Proč? (čemu prospějeme, proč je to dobrý nápad, jaký to bude mít dopad?)**
promoce PyCon CZ a české komunity
Expand All @@ -366,7 +366,7 @@ Dne 13. 6. 2023 požádal uživatel `@befeleme <https://github.com/befeleme>`_ o
Karolina Surma - PyLadies

**Kolik potřebujete? (aspoň odhad nebo rozmezí)**
~6800 Kč
~6800 Kč

*detailně*
hlavička: 6.24 Kč / ks = 2496 Kč
Expand Down Expand Up @@ -403,7 +403,7 @@ Dne 27. 2. 2023 požádal uživatel `@Zuzanita <https://github.com/Zuzanita>`_ o
.. code-block:: text

**Kdo jste?**
Organizátoři PyLadies - podává Zuzana Pokorná za všechny
Organizátoři PyLadies - podává Zuzana Pokorná za všechny

**Kolik potřebujete? (aspoň odhad nebo rozmezí)**
25 000 Kč z toho bude část vrácena z příspěvků jednotlivců na trička
Expand Down Expand Up @@ -613,15 +613,15 @@ Dne 16. 12. 2020 požádal uživatel `@kvbik <https://github.com/kvbik>`_ o gran

**Kdo jste?**

Jakub Vysoky, clen Pyvec, spolu organizator prazskeho Pyva
Jakub Vysoky, clen Pyvec, spolu organizator prazskeho Pyva

**Kolik potřebujete? (aspoň odhad nebo rozmezí)**

Do 15tis Kc. (jidlo a piti na 3-4 dny pro 20-30 lidi)

**Na jakou věc to je?**

Letni edice Python komunitniho Sprintu ve Msenych-laznich v srpen 2020.
Letni edice Python komunitniho Sprintu ve Msenych-laznich v srpen 2020.

**Proč? (čemu prospějeme, proč je to dobrý nápad, jaký to bude mít dopad?)**

Expand Down Expand Up @@ -651,13 +651,13 @@ Dne 26. 2. 2020 požádal uživatel `@radusaaa <https://github.com/radusaaa>`_ o
PyLadies Praha

**Kolik potřebujete? (aspoň odhad nebo rozmezí)**
500,- Kč za oba běhy
500,- Kč za oba běhy

**Na jakou věc to je?**

- kancelářské potřeby

- drobné odměny do soutěží
- drobné odměny do soutěží

**Proč? (čemu prospějeme, proč je to dobrý nápad, jaký to bude mít dopad?)**
Organizujeme dva běhy začátečnických kurzů viz https://pyladies.cz/praha/. Součástí kurzů jsou i dva sobotní celodenní pyworkingy a závěrečný hackathon.
Expand Down Expand Up @@ -686,7 +686,7 @@ Dne 13. 2. 2020 požádal uživatel `@IvaFingerova <https://github.com/IvaFinger
Iva Fingerová

**Kolik potřebujete? (aspoň odhad nebo rozmezí)**
1 723,- CZK
1 723,- CZK

**Na jakou věc to je?**
Subscription meetup.com pro Pyworking
Expand Down
34 changes: 24 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
# Currently this file is used merely for configuration
# of tools. For dependencies, see requirements.txt.
#
# One day there will be a way how to specify dependencies
# in pyproject.toml, and then install them by pip without
# the need for installing this directory as a package
# on its own, but that day is not today.

[project]
requires-python = "==3.12"
name = "pyvec-docs"
version = "0"
requires-python = "==3.12.*"
dependencies = [
"jinja2==3.1.5",
"myst-parser==4.0.1",
"requests==2.32.3",
"sphinx-rtd-theme==3.0.2",
"sphinx==8.1.3",
"sphinxemoji==0.3.1",
"strictyaml==1.7.3",
]

[dependency-groups]
dev = [
"pytest-ruff==0.4.1",
"pytest==8.3.4",
"sphinx-autobuild==2024.10.3",
]

[build-system]
requires = ["uv_build>=0.7.3,<0.8.0"]
build-backend = "uv_build"

[tool.pytest.ini_options]
testpaths = "_*"
testpaths = "tests"
addopts = "--ff --ruff --ruff-format"
norecursedirs = "_build _static _templates"

Expand Down
10 changes: 0 additions & 10 deletions requirements.txt

This file was deleted.

Empty file added src/pyvec_docs/__init__.py
Empty file.
20 changes: 20 additions & 0 deletions src/pyvec_docs/board.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from operator import itemgetter
from pathlib import Path

import strictyaml as yaml


BOARD_HISTORY_SCHEMA = yaml.Seq(
yaml.Map(
{
"from": yaml.Datetime(),
"members": yaml.MapPattern(yaml.Str(), yaml.Str()),
}
)
)
BOARD_HISTORY_PATH = Path(__file__).parent / "board.yml"
BOARD_HISTORY = sorted(
yaml.load(BOARD_HISTORY_PATH.read_text(), BOARD_HISTORY_SCHEMA).data,
key=itemgetter("from"),
reverse=True,
)
2 changes: 1 addition & 1 deletion board.yml → src/pyvec_docs/board.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# The Pyvec board members in time
# The current board is first, previous boards are listed in descending order
# Keys are GitHub handles, values legal names
# Members start with chairman, others are sorted by GitHub handles
# Members start with chair, others are sorted by GitHub handles
- from: 2022-04-09
members:
baradrb: Barbora Drbohlavová
Expand Down
Empty file added src/pyvec_docs/ext/__init__.py
Empty file.
File renamed without changes.
Loading