Skip to content

Commit d5d1513

Browse files
chore(dev): move to Rye instead of PDM (#420)
* test: re-add opencv-python * chore(dev): move to Rye instead of PDM * try fix * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix: build backend * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix: string quotes? * small fixes * upgrade typing * fix(ci): rye install on Windows * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix(ci): typos * fix * fix(ci): actually use right python version * fix(deps): manimgl * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix docs * another fix * cleanup * make sure to use trusted publisher * chore(docs): remove PDM --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent bd04dae commit d5d1513

31 files changed

+965
-3677
lines changed

.github/workflows/publish.yml

+13-6
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,22 @@ jobs:
1818
- name: Checkout repository
1919
uses: actions/checkout@v4
2020

21-
- name: Install PDM
22-
uses: pdm-project/setup-pdm@v4
23-
with:
24-
python-version: '3.10'
25-
cache: true
21+
- name: Setup Rye
22+
env:
23+
RYE_INSTALL_OPTION: --yes
24+
run: |
25+
curl -sSf https://rye-up.com/get | bash
26+
echo "$HOME/.rye/shims" >> $GITHUB_PATH
27+
28+
- name: Configure Rye
29+
run: rye config --set-bool behavior.use-uv=true
30+
31+
- name: Build package
32+
run: rye build
2633

2734
- name: Publish to PyPI
2835
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
29-
run: pdm publish
36+
uses: pypa/gh-action-pypi-publish@release/v1
3037

3138
publish-docker:
3239
name: Publish Docker image

.github/workflows/tests.yml

+25-22
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,30 @@ jobs:
2525
- name: Checkout repository
2626
uses: actions/checkout@v4
2727

28-
- name: Install PDM
29-
uses: pdm-project/setup-pdm@v4
30-
with:
31-
python-version: ${{ matrix.pyversion }}
32-
cache: true
33-
34-
# Path related stuff
35-
- name: Append to Path on MacOS
36-
if: matrix.os == 'macos-latest'
28+
- name: Setup Rye
29+
if: matrix.os != 'windows-latest'
30+
env:
31+
RYE_TOOLCHAIN_VERSION: ${{ matrix.pyversion}}
32+
RYE_INSTALL_OPTION: --yes
3733
run: |
38-
echo "${HOME}/.local/bin" >> $GITHUB_PATH
39-
echo "/Users/runner/Library/Python/${{ matrix.pyversion }}/bin" >> $GITHUB_PATH
40-
41-
- name: Append to Path on Ubuntu
42-
if: matrix.os == 'ubuntu-latest'
43-
run: echo "${HOME}/.local/bin" >> $GITHUB_PATH
34+
curl -sSf https://rye-up.com/get | bash
35+
echo "$HOME/.rye/shims" >> $GITHUB_PATH
4436
45-
- name: Append to Path on Windows
37+
# Stolen from https://github.com/bluss/pyproject-local-kernel/blob/2b641290694adc998fb6bceea58d3737523a68b7/.github/workflows/ci.yaml
38+
- name: Install Rye (Windows)
4639
if: matrix.os == 'windows-latest'
47-
run: echo "${HOME}/.local/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
40+
shell: bash
41+
run: |
42+
C:/msys64/usr/bin/wget.exe -q 'https://github.com/astral-sh/rye/releases/latest/download/rye-x86_64-windows.exe' -O rye-x86_64-windows.exe
43+
./rye-x86_64-windows.exe self install --toolchain-version ${{ matrix.pyversion }} --modify-path -y
44+
echo "$HOME\\.rye\\shims" >> $GITHUB_PATH
45+
46+
- name: Configure Rye
47+
shell: bash
48+
run: |
49+
rye config --set-bool behavior.use-uv=true
50+
rye pin ${{ matrix.pyversion }}
4851
49-
# OS dependencies
5052
- name: Install manim dependencies on MacOS
5153
if: matrix.os == 'macos-latest'
5254
run: brew install ffmpeg py3cairo
@@ -68,16 +70,17 @@ jobs:
6870
uses: ssciwr/setup-mesa-dist-win@v2
6971

7072
- name: Install Manim Slides
71-
run: |
72-
pdm sync -Ggithub-action -Gtest
73+
shell: bash
74+
run: rye sync
7375

7476
- name: Run pytest
77+
shell: bash
7578
if: matrix.os != 'ubuntu-latest' || matrix.pyversion != '3.11'
76-
run: pdm run pytest
79+
run: rye run pytest
7780

7881
- name: Run pytest and coverage
7982
if: matrix.os == 'ubuntu-latest' && matrix.pyversion == '3.11'
80-
run: pdm run pytest --cov-report xml --cov=manim_slides tests/
83+
run: rye run pytest --cov-report xml --cov=manim_slides tests/
8184

8285
- name: Upload to codecov.io
8386
if: matrix.os == 'ubuntu-latest' && matrix.pyversion == '3.11'

.python-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.11.8

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717
[#417](https://github.com/jeertmans/manim-slides/pull/417)
1818
- Create FAQ page and clear FAQ from README.md.
1919
[#418](https://github.com/jeertmans/manim-slides/pull/418)
20+
- Used Rye instead of PDM for faster development.
21+
[#420](https://github.com/jeertmans/manim-slides/pull/420)
2022

2123
(unreleased-fixed)=
2224
### Fixed

docs/source/contributing/workflow.md

+8-44
Original file line numberDiff line numberDiff line change
@@ -24,61 +24,25 @@ the repository, and clone it locally.
2424

2525
As for every Python project, using virtual environment is recommended to avoid
2626
conflicts between modules.
27-
For this project, we use [PDM](https://pdm-project.org/) to easily manage project
27+
For this project, we use [Rye](https://rye-up.com/) to easily manage project
2828
and development dependencies. If not already, please install this tool.
2929

3030
## Installing Python modules
3131

32-
With PDM, installation becomes straightforward:
32+
With Rye, installation becomes straightforward:
3333

3434
```bash
35-
pdm install
35+
rye sync --all-features
3636
```
3737

38-
This, however, only installs the minimal set of dependencies to run the package.
39-
40-
If you would like to install Manim or ManimGL,
41-
as documented in the [quickstart](/quickstart),
42-
you can use the `-G|--group` option:
43-
44-
```bash
45-
pdm install -Gmanim # For Manim
46-
# or
47-
pdm install -Gmanimgl # For ManimGL
48-
```
49-
50-
Additionally, Manim Slides comes with groups of dependencies for development purposes:
51-
52-
```bash
53-
pdm install -Gdev # For linters and formatters
54-
# or
55-
pdm install -Gdocs # To build the documentation locally
56-
# or
57-
pdm install -Gtest # To run tests
58-
```
59-
60-
:::{note}
61-
You can combine any number of groups or extras when installing the package locally.
62-
63-
You can also install everything with `pdm install -G:all`.
64-
:::
65-
6638
## Running commands
6739

6840
Because modules are installed in a new Python environment,
6941
you cannot use them directly in the shell.
70-
Instead, you either need to prepend `pdm run` to any command, e.g.:
71-
72-
```bash
73-
pdm run manim-slides wizard
74-
```
75-
76-
or [enter a new shell](https://pdm-project.org/latest/usage/venv/#activate-a-virtualenv)
77-
that uses this new Python environment:
42+
Instead, you either need to prepend `rye run` to any command, e.g.:
7843

7944
```bash
80-
eval $(pdm venv activate) # Click on the link above to see shell-specific command
81-
manim-slides wizard
45+
rye run manim-slides wizard
8246
```
8347

8448
## Testing your code
@@ -87,7 +51,7 @@ Most of the tests are done with GitHub actions, thus not on your computer.
8751
The only command you should run locally is:
8852

8953
```bash
90-
pdm run pre-commit run --all-files
54+
rye run pre-commit run --all-files
9155
```
9256

9357
This runs a few linter and formatter to make sure the code quality and style stay
@@ -97,7 +61,7 @@ If a warning or an error is displayed, please fix it before going to next step.
9761
For testing your code, simply run:
9862

9963
```bash
100-
pdm run pytest
64+
rye run pytest
10165
```
10266

10367
## Building the documentation
@@ -109,7 +73,7 @@ To generate the documentation, run the following:
10973

11074
```bash
11175
cd docs
112-
pdm run make html
76+
rye run make html
11377
```
11478

11579
Then, the output index file is located at `docs/build/html/index.html` and

docs/source/installation.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ Along with the optional dependencies for Manim and ManimGL,
106106
Manim Slides offers additional *extras*, that can be activated
107107
using optional dependencies:
108108

109-
- `full`, to include `magic`, `manim`, `manimgl`, and
109+
- `full`, to include `magic`, `manim`, and
110+
`sphinx-directive` extras (see below);
111+
- `full-gl`, to include `magic`, `manimgl`, and
110112
`sphinx-directive` extras (see below);
111113
- `magic`, to include a Jupyter magic to render
112114
animations inside notebooks. This automatically installs `manim`,

docs/source/manim_or_manimgl.md

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ the slides.
1515
If both modules are present in {py:data}`sys.modules`, then Manim Slides will
1616
prefer using `manim`.
1717

18-
1918
### Usage
2019

2120
The simplest way to use Manim Slides with the correct Manim API is to:

docs/source/reference/magic_example.ipynb

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"outputs": [],
1919
"source": [
2020
"from manim import *\n",
21+
"\n",
2122
"from manim_slides import *"
2223
]
2324
},

manim_slides/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def __getattr__(self, name: str) -> Any:
2929

3030
return ModuleType.__getattribute__(self, name)
3131

32-
def __dir__(self) -> List[str]:
32+
def __dir__(self) -> list[str]:
3333
result = list(new_module.__all__)
3434
result.extend(
3535
(

manim_slides/config.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from inspect import Parameter, signature
55
from pathlib import Path
66
from textwrap import dedent
7-
from typing import Any, Callable, Dict, List, Optional, Set, Tuple
7+
from typing import Any, Callable, Optional
88

99
import rtoml
1010
from pydantic import (
@@ -24,7 +24,7 @@
2424

2525

2626
class Signal(BaseModel): # type: ignore[misc]
27-
__receivers: List[Receiver] = PrivateAttr(default_factory=list)
27+
__receivers: list[Receiver] = PrivateAttr(default_factory=list)
2828

2929
def connect(self, receiver: Receiver) -> None:
3030
self.__receivers.append(receiver)
@@ -47,14 +47,14 @@ def key_id(name: str) -> PositiveInt:
4747
class Key(BaseModel): # type: ignore[misc]
4848
"""Represents a list of key codes, with optionally a name."""
4949

50-
ids: List[PositiveInt] = Field(unique=True)
50+
ids: list[PositiveInt] = Field(unique=True)
5151
name: Optional[str] = None
5252

5353
__signal: Signal = PrivateAttr(default_factory=Signal)
5454

5555
@field_validator("ids")
5656
@classmethod
57-
def ids_is_non_empty_set(cls, ids: Set[Any]) -> Set[Any]:
57+
def ids_is_non_empty_set(cls, ids: set[Any]) -> set[Any]:
5858
if len(ids) <= 0:
5959
raise ValueError("Key's ids must be a non-empty set")
6060
return ids
@@ -98,8 +98,8 @@ class Keys(BaseModel): # type: ignore[misc]
9898

9999
@model_validator(mode="before")
100100
@classmethod
101-
def ids_are_unique_across_keys(cls, values: Dict[str, Key]) -> Dict[str, Key]:
102-
ids: Set[int] = set()
101+
def ids_are_unique_across_keys(cls, values: dict[str, Key]) -> dict[str, Key]:
102+
ids: set[int] = set()
103103

104104
for key in values.values():
105105
if len(ids.intersection(key["ids"])) != 0:
@@ -296,8 +296,8 @@ def from_pre_slide_config_and_files(
296296

297297

298298
class PresentationConfig(BaseModel): # type: ignore[misc]
299-
slides: List[SlideConfig] = Field(min_length=1)
300-
resolution: Tuple[PositiveInt, PositiveInt] = (1920, 1080)
299+
slides: list[SlideConfig] = Field(min_length=1)
300+
resolution: tuple[PositiveInt, PositiveInt] = (1920, 1080)
301301
background_color: Color = "black"
302302

303303
@classmethod

manim_slides/convert.py

+6-10
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22
import os
33
import platform
44
import subprocess
5-
import sys
65
import tempfile
76
import webbrowser
87
from base64 import b64encode
98
from collections import deque
109
from enum import Enum
1110
from importlib import resources
1211
from pathlib import Path
13-
from typing import Any, Callable, Dict, List, Optional, Type, Union
12+
from typing import Any, Callable, Optional, Union
1413

1514
import av
1615
import click
@@ -53,7 +52,7 @@ def open_with_default(file: Path) -> None:
5352

5453
def validate_config_option(
5554
ctx: Context, param: Parameter, value: Any
56-
) -> Dict[str, str]:
55+
) -> dict[str, str]:
5756
config = {}
5857

5958
for c_option in value:
@@ -121,7 +120,7 @@ def open(self, file: Path) -> Any:
121120
raise NotImplementedError
122121

123122
@classmethod
124-
def from_string(cls, s: str) -> Type["Converter"]:
123+
def from_string(cls, s: str) -> type["Converter"]:
125124
"""Return the appropriate converter from a string name."""
126125
return {
127126
"html": RevealJS,
@@ -329,7 +328,7 @@ class RevealJS(Converter):
329328
auto_animate_easing: AutoAnimateEasing = AutoAnimateEasing.ease
330329
auto_animate_duration: float = 1.0
331330
auto_animate_unmatched: JsBool = JsBool.true
332-
auto_animate_styles: List[str] = Field(
331+
auto_animate_styles: list[str] = Field(
333332
default_factory=lambda: [
334333
"opacity",
335334
"color",
@@ -379,9 +378,6 @@ def load_template(self) -> str:
379378
if isinstance(self.template, Path):
380379
return self.template.read_text()
381380

382-
if sys.version_info < (3, 9):
383-
return resources.read_text(templates, "revealjs.html")
384-
385381
return resources.files(templates).joinpath("revealjs.html").read_text()
386382

387383
def open(self, file: Path) -> bool:
@@ -658,13 +654,13 @@ def callback(ctx: Context, param: Parameter, value: bool) -> None:
658654
@show_config_options
659655
@verbosity_option
660656
def convert(
661-
scenes: List[str],
657+
scenes: list[str],
662658
folder: Path,
663659
dest: Path,
664660
to: str,
665661
open_result: bool,
666662
force: bool,
667-
config_options: Dict[str, str],
663+
config_options: dict[str, str],
668664
template: Optional[Path],
669665
) -> None:
670666
"""Convert SCENE(s) into a given format and writes the result in DEST."""

0 commit comments

Comments
 (0)