Skip to content

Commit ff405c9

Browse files
Update build tools and dependencies (#25)
* Update build tools * Improve module constructor * Update dependencies
1 parent 7a12d7c commit ff405c9

File tree

11 files changed

+87
-91
lines changed

11 files changed

+87
-91
lines changed

build_requires.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: disable-error-code=no-redef
2+
13
from typing import Union, Mapping
24

35
from setuptools import build_meta

mypy.ini

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
disallow_untyped_defs = True
33
check_untyped_defs = True
44
warn_return_any = True
5-
python_version = 3.11
6-
mypy_path = $MYPY_CONFIG_FILE_DIR/src
7-
packages = amulet
5+
python_version = 3.12
6+
explicit_package_bases = True
7+
mypy_path = $MYPY_CONFIG_FILE_DIR/src,$MYPY_CONFIG_FILE_DIR/tests
8+
files =
9+
src,
10+
tests,
11+
tools,
12+
get_compiler,
13+
build_requires.py,
14+
requirements.py,
15+
setup.py

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ docs = [
2828
]
2929
dev = [
3030
"setuptools>=42",
31+
"types-setuptools",
3132
"versioneer",
33+
"types-versioneer",
3234
"packaging",
3335
"wheel",
3436
"pybind11_stubgen>=2.5.4",

requirements.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
AMULET_COMPILER_TARGET_REQUIREMENT = "==2.0"
66

7-
PYBIND11_REQUIREMENT = "==3.0.0"
8-
AMULET_PYBIND11_EXTENSIONS_REQUIREMENT = "~=1.2.0.0a0"
7+
PYBIND11_REQUIREMENT = "==3.0.1"
8+
AMULET_PYBIND11_EXTENSIONS_REQUIREMENT = "~=1.2.0.0a2"
99

1010
if os.environ.get("AMULET_PYBIND11_EXTENSIONS_REQUIREMENT", None):
1111
AMULET_PYBIND11_EXTENSIONS_REQUIREMENT = f"{AMULET_PYBIND11_EXTENSIONS_REQUIREMENT},{os.environ['AMULET_PYBIND11_EXTENSIONS_REQUIREMENT']}"

setup.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from pathlib import Path
55
import platform
66
from tempfile import TemporaryDirectory
7+
from typing import TypeAlias, TYPE_CHECKING
78

89
from setuptools import setup, Extension, Command
910
from setuptools.command.build_ext import build_ext
@@ -13,15 +14,20 @@
1314
import requirements
1415

1516

16-
def fix_path(path: str) -> str:
17+
def fix_path(path: str | os.PathLike[str]) -> str:
1718
return os.path.realpath(path).replace(os.sep, "/")
1819

1920

2021
cmdclass: dict[str, type[Command]] = versioneer.get_cmdclass()
2122

23+
if TYPE_CHECKING:
24+
BuildExt: TypeAlias = build_ext
25+
else:
26+
BuildExt = cmdclass.get("build_ext", build_ext)
2227

23-
class CMakeBuild(cmdclass.get("build_ext", build_ext)):
24-
def build_extension(self, ext):
28+
29+
class CMakeBuild(BuildExt):
30+
def build_extension(self, ext: Extension) -> None:
2531
import pybind11
2632
import amulet.pybind11_extensions
2733

@@ -74,7 +80,7 @@ def build_extension(self, ext):
7480
raise RuntimeError("Error installing amulet-zlib")
7581

7682

77-
cmdclass["build_ext"] = CMakeBuild
83+
cmdclass["build_ext"] = CMakeBuild # type: ignore
7884

7985

8086
setup(

src/amulet/zlib/_amulet_zlib.py.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,5 @@ void init_module(py::module m)
6262

6363
PYBIND11_MODULE(_amulet_zlib, m)
6464
{
65-
py::options options;
66-
options.disable_function_signatures();
67-
m.def("init", &init_module, py::doc("init(arg0: types.ModuleType) -> None"));
68-
options.enable_function_signatures();
65+
m.def("init", &init_module, py::arg("m"));
6966
}

src/amulet/zlib/_amulet_zlib.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ import types
44

55
__all__ = ["init"]
66

7-
def init(arg0: types.ModuleType) -> None: ...
7+
def init(m: types.ModuleType) -> None: ...

tests/test_amulet_zlib/_test_amulet_zlib.py.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,5 @@ void init_module(py::module m){
1515
}
1616

1717
PYBIND11_MODULE(_test_amulet_zlib, m) {
18-
py::options options;
19-
options.disable_function_signatures();
20-
m.def("init", &init_module, py::doc("init(arg0: types.ModuleType) -> None"));
21-
options.enable_function_signatures();
18+
m.def("init", &init_module, py::arg("m"));
2219
}

tests/test_amulet_zlib/_test_amulet_zlib.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ import types
44

55
__all__ = ["init"]
66

7-
def init(arg0: types.ModuleType) -> None: ...
7+
def init(m: types.ModuleType) -> None: ...

tools/cmake_generate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def fix_path(path: str) -> str:
1515
RootDir = fix_path(os.path.dirname(os.path.dirname(__file__)))
1616

1717

18-
def main():
18+
def main() -> None:
1919
platform_args = []
2020
if sys.platform == "win32":
2121
platform_args.extend(["-G", "Visual Studio 17 2022"])

0 commit comments

Comments
 (0)