Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python: ["3.9", "3.10", "3.11", "3.12", "3.13"]
python: ["3.10", "3.11", "3.12", "3.13"]

name: "Python ${{ matrix.python }}"
runs-on: ubuntu-24.04
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
fail-fast: false
matrix:
os: ["ubuntu-24.04", "windows-2025"]
python: ["3.9", "3.10", "3.11", "3.12", "3.13"]
python: ["3.10", "3.11", "3.12", "3.13"]

name: "${{ matrix.os }} / Python ${{ matrix.python }}"
runs-on: ${{ matrix.os }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ CharonLoad reduces the burden to start writing and experimenting with custom GPU

## Installation

CharonLoad requires **Python >=3.9** and can be installed from PyPI:
CharonLoad requires **Python >=3.10** and can be installed from PyPI:

```sh
pip install charonload
Expand Down
4 changes: 3 additions & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ def docs_live(session: nox.Session) -> None:
# sphinx-build
force_building = "-E"
watch_dirs_and_files = ["src", "README.md", "CHANGELOG.md"]
watch_args = [v for pair in zip(["--watch"] * len(watch_dirs_and_files), watch_dirs_and_files) for v in pair]
watch_args = [
v for pair in zip(["--watch"] * len(watch_dirs_and_files), watch_dirs_and_files, strict=True) for v in pair
]
session.run(
"sphinx-autobuild",
"-b",
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ version = "0.2.1"
authors = [{ name = "Patrick Stotko", email = "[email protected]" }]
description = "Develop C++/CUDA extensions with PyTorch like Python scripts"
readme = "README.md"
requires-python = ">=3.9"
requires-python = ">=3.10"
dependencies = [
"cmake>=3.27",
'dlltracer ; platform_system == "Windows"',
'ninja ; platform_system != "Windows"',
"filelock",
"torch",
Expand All @@ -21,7 +22,6 @@ classifiers = [
"License :: OSI Approved :: MIT License",
"Programming Language :: C++",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
Expand Down Expand Up @@ -92,7 +92,7 @@ line-length = 120
[tool.isort]
profile = "black"
multi_line_output = 3
py_version = 39
py_version = 310


[tool.docformatter]
Expand Down
2 changes: 1 addition & 1 deletion src/charonload/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import sys

required_version = (3, 8)
required_version = (3, 10)

if sys.version_info[:2] < required_version: # pragma: no cover
msg = "%s requires Python %d.%d+" % (__package__, *required_version) # noqa: UP031
Expand Down
3 changes: 2 additions & 1 deletion src/charonload/_compat/hashlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

import sys
from hashlib import * # noqa: F403
from typing import TYPE_CHECKING, BinaryIO, Callable
from typing import TYPE_CHECKING, BinaryIO

if TYPE_CHECKING:
from collections.abc import Callable
from hashlib import _Hash


Expand Down
68 changes: 15 additions & 53 deletions src/charonload/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import sysconfig
import tempfile
from collections import UserDict
from dataclasses import dataclass
from dataclasses import KW_ONLY, dataclass
from typing import TYPE_CHECKING

import colorama
Expand All @@ -22,7 +22,7 @@
colorama.just_fix_windows_console()


@dataclass(init=False) # Python 3.10+: Use "_: KW_ONLY"
@dataclass
class Config:
"""
Set of user-specified configuration options for setting up the import logic of :class:`JITCompileFinder`.
Expand All @@ -33,14 +33,16 @@ class Config:
project_directory: pathlib.Path | str
"""The absolute path to the root directory of the C++/CUDA extension containing the root ``CMakeLists.txt`` file."""

build_directory: pathlib.Path | str | None
build_directory: pathlib.Path | str | None = None
"""
An optional absolute path to a build directory.

If not specified, the build will be placed in the temporary directory of the operating system.
"""

clean_build: bool
_: KW_ONLY

clean_build: bool = False
"""
Whether to remove all cached files of previous builds from the build directory.

Expand All @@ -53,13 +55,13 @@ class Config:
:class:`ResolvedConfig`.
"""

build_type: str
build_type: str = "RelWithDebInfo"
"""The build type passed to CMake to compile the extension."""

cmake_options: dict[str, str] | None
cmake_options: dict[str, str] | None = None
"""Additional CMake options to pass to the project when JIT compiling."""

stubs_directory: pathlib.Path | str | None
stubs_directory: pathlib.Path | str | None = None
"""
An optional absolute path to the directory where stub files of the extension should be generated.

Expand All @@ -68,7 +70,7 @@ class Config:
if set to ``None``.
"""

stubs_invalid_ok: bool
stubs_invalid_ok: bool = False
"""
Whether to accept invalid stubs and skip raising an error.

Expand All @@ -79,7 +81,7 @@ class Config:
:class:`ResolvedConfig`.
"""

verbose: bool
verbose: bool = False
"""
Whether to enable printing the full log of the JIT compilation.

Expand All @@ -92,36 +94,17 @@ class Config:
:class:`ResolvedConfig`.
"""

def __init__(
self: Self,
project_directory: pathlib.Path | str,
build_directory: pathlib.Path | str | None = None,
*,
clean_build: bool = False,
build_type: str = "RelWithDebInfo",
cmake_options: dict[str, str] | None = None,
stubs_directory: pathlib.Path | str | None = None,
stubs_invalid_ok: bool = False,
verbose: bool = False,
) -> None:
self.project_directory = project_directory
self.build_directory = build_directory
self.clean_build = clean_build
self.build_type = build_type
self.cmake_options = cmake_options
self.stubs_directory = stubs_directory
self.stubs_invalid_ok = stubs_invalid_ok
self.verbose = verbose


@dataclass(init=False) # Python 3.10+: Use "kw_only=True"

@dataclass
class ResolvedConfig:
"""
Set of resolved configuration options that is **actually used** in the import logic of :class:`JITCompileFinder`.

This has been resolved from :class:`Config` and from the environment variables.
"""

_: KW_ONLY

full_project_directory: pathlib.Path
"""The full absolute path to the project directory."""

Expand All @@ -146,27 +129,6 @@ class ResolvedConfig:
verbose: bool
"""Flag to enable printing the full log of the JIT compilation."""

def __init__(
self: Self,
*,
full_project_directory: pathlib.Path,
full_build_directory: pathlib.Path,
clean_build: bool,
build_type: str,
cmake_options: dict[str, str],
full_stubs_directory: pathlib.Path | None,
stubs_invalid_ok: bool,
verbose: bool,
) -> None:
self.full_project_directory = full_project_directory
self.full_build_directory = full_build_directory
self.clean_build = clean_build
self.build_type = build_type
self.cmake_options = cmake_options
self.full_stubs_directory = full_stubs_directory
self.stubs_invalid_ok = stubs_invalid_ok
self.verbose = verbose


class ConfigDict(UserDict[str, ResolvedConfig]):
"""
Expand Down
3 changes: 2 additions & 1 deletion src/charonload/_persistence.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
import pathlib
import sys
from dataclasses import dataclass
from typing import TYPE_CHECKING, Any, Callable
from typing import TYPE_CHECKING, Any

from ._errors import _SerializerNotConnectedError

if TYPE_CHECKING: # pragma: no cover
import enum
from collections.abc import Callable

from ._compat.typing import Self

Expand Down