Skip to content

Commit 5ee931f

Browse files
Update build tools and dependencies (#9)
* Move build directory * Update dependencies * Update stub generator
1 parent 41431ae commit 5ee931f

File tree

4 files changed

+25
-27
lines changed

4 files changed

+25
-27
lines changed

get_compiler/__init__.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
import os
22
import subprocess
3-
4-
Dir = os.path.dirname(__file__)
3+
from tempfile import TemporaryDirectory
54

65

76
def main() -> str:
87
if subprocess.run(["cmake", "--version"]).returncode:
98
raise RuntimeError("Could not find cmake")
109

11-
# get the compiler id and version
12-
if subprocess.run(
13-
["cmake", "-S", Dir, "-B", os.path.join(Dir, "build")]
14-
).returncode:
15-
raise RuntimeError(
16-
"Could not find a C++ 20 compiler. Do you have a C++ 20 compiler installed?"
17-
)
10+
with TemporaryDirectory() as build_dir:
11+
# get the compiler id and version
12+
if subprocess.run(
13+
["cmake", "-S", os.path.dirname(__file__), "-B", build_dir]
14+
).returncode:
15+
raise RuntimeError(
16+
"Could not find a C++ 20 compiler. Do you have a C++ 20 compiler installed?"
17+
)
1818

19-
# Get the compiler variables generated by the cmake file
20-
with open(os.path.join(Dir, "build", "compiler_id.txt")) as f:
21-
compiler_id_str = f.read().strip()
22-
with open(os.path.join(Dir, "build", "compiler_version.txt")) as f:
23-
compiler_version = f.read().strip().split(".", 1)[0]
19+
# Get the compiler variables generated by the cmake file
20+
with open(os.path.join(build_dir, "compiler_id.txt")) as f:
21+
compiler_id_str = f.read().strip()
22+
with open(os.path.join(build_dir, "compiler_version.txt")) as f:
23+
compiler_version = f.read().strip().split(".", 1)[0]
2424

2525
# convert the compiler id to an int so it can be used in a version number
2626
compiler_id_int = 0

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ dev = [
2626
"versioneer",
2727
"packaging",
2828
"wheel",
29-
"amulet_pybind11_extensions~=1.0",
3029
"pybind11_stubgen>=2.5.4",
3130
"black>=22.3",
3231
"isort",

requirements.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
AMULET_COMPILER_TARGET_REQUIREMENT = "==2.0"
66

77
PYBIND11_REQUIREMENT = "==3.0.0"
8-
AMULET_PYBIND11_EXTENSIONS_REQUIREMENT = "~=1.1.0.0a0"
8+
AMULET_PYBIND11_EXTENSIONS_REQUIREMENT = "~=1.2.0.0a0"
99
AMULET_IO_REQUIREMENT = "~=1.0"
1010
AMULET_UTILS_REQUIREMENT = "~=1.1.3.0a0"
1111
AMULET_ZLIB_REQUIREMENT = "~=1.0.8.0a0"
1212
AMULET_NBT_REQUIREMENT = "~=5.0.2.0a0"
1313
AMULET_CORE_REQUIREMENT = "~=2.0.5.0a0"
1414
NUMPY_REQUIREMENT = "~=2.0"
15-
PIL_REQUIREMENT = "~=11.0"
15+
PIL_REQUIREMENT = "~=11.3"
1616

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

tools/generate_pybind_stubs.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,18 @@ def eq_sub_func(match: re.Match) -> str:
5858
else:
5959
return "\n".join(
6060
[
61-
f"{match.group('indent')}def __eq__(self, arg0: {match.group('other')}) -> {match.group('return')}:{match.group('ellipsis_docstring')}",
61+
f"{match.group('indent')}def __eq__(self, other: {match.group('other')}) -> {match.group('return')}:{match.group('ellipsis_docstring')}",
6262
f"{match.group('indent')}@typing.overload",
63-
f"{match.group('indent')}def __eq__(self, arg0: typing.Any) -> bool | types.NotImplementedType: ...",
63+
f"{match.group('indent')}def __eq__(self, other: typing.Any) -> bool | types.NotImplementedType: ...",
6464
]
6565
)
6666
else:
6767
return "\n".join(
6868
[
6969
f"{match.group('indent')}@typing.overload",
70-
f"{match.group('indent')}def __eq__(self, arg0: {match.group('other')}) -> {match.group('return')}:{match.group('ellipsis_docstring')}",
70+
f"{match.group('indent')}def __eq__(self, other: {match.group('other')}) -> {match.group('return')}:{match.group('ellipsis_docstring')}",
7171
f"{match.group('indent')}@typing.overload",
72-
f"{match.group('indent')}def __eq__(self, arg0: typing.Any) -> bool | types.NotImplementedType: ...",
72+
f"{match.group('indent')}def __eq__(self, other: typing.Any) -> bool | types.NotImplementedType: ...",
7373
]
7474
)
7575

@@ -246,13 +246,12 @@ def main() -> None:
246246
pyi = EqPattern.sub(eq_sub_func, pyi)
247247
pyi = pyi.replace("**kwargs)", "**kwargs: typing.Any)")
248248
pyi_split = [l.rstrip("\r") for l in pyi.split("\n")]
249-
for hidden_import in ["amulet.nbt"]:
249+
for hidden_import in ["amulet.nbt", "typing", "types"]:
250250
if hidden_import in pyi and f"import {hidden_import}" not in pyi_split:
251-
pyi_split.insert(2, f"import {hidden_import}")
252-
if "import typing" not in pyi_split:
253-
pyi_split.insert(2, "import typing")
254-
if "import types" not in pyi_split:
255-
pyi_split.insert(2, "import types")
251+
pyi_split.insert(
252+
pyi_split.index("from __future__ import annotations") + 1,
253+
f"import {hidden_import}",
254+
)
256255
pyi = "\n".join(pyi_split)
257256
with open(stub_path, "w", encoding="utf-8") as f:
258257
f.write(pyi)

0 commit comments

Comments
 (0)