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
28 changes: 14 additions & 14 deletions get_compiler/__init__.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import os
import subprocess

Dir = os.path.dirname(__file__)
from tempfile import TemporaryDirectory


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

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

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

# convert the compiler id to an int so it can be used in a version number
compiler_id_int = 0
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ dev = [
"versioneer",
"packaging",
"wheel",
"amulet_pybind11_extensions~=1.0",
"pybind11_stubgen>=2.5.4",
"black>=22.3",
"isort",
Expand Down
4 changes: 2 additions & 2 deletions requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
AMULET_COMPILER_TARGET_REQUIREMENT = "==2.0"

PYBIND11_REQUIREMENT = "==3.0.0"
AMULET_PYBIND11_EXTENSIONS_REQUIREMENT = "~=1.1.0.0a0"
AMULET_PYBIND11_EXTENSIONS_REQUIREMENT = "~=1.2.0.0a0"
AMULET_IO_REQUIREMENT = "~=1.0"
AMULET_UTILS_REQUIREMENT = "~=1.1.3.0a0"
AMULET_ZLIB_REQUIREMENT = "~=1.0.8.0a0"
AMULET_NBT_REQUIREMENT = "~=5.0.2.0a0"
AMULET_CORE_REQUIREMENT = "~=2.0.5.0a0"
NUMPY_REQUIREMENT = "~=2.0"
PIL_REQUIREMENT = "~=11.0"
PIL_REQUIREMENT = "~=11.3"

if os.environ.get("AMULET_PYBIND11_EXTENSIONS_REQUIREMENT", None):
AMULET_PYBIND11_EXTENSIONS_REQUIREMENT = f"{AMULET_PYBIND11_EXTENSIONS_REQUIREMENT},{os.environ['AMULET_PYBIND11_EXTENSIONS_REQUIREMENT']}"
Expand Down
19 changes: 9 additions & 10 deletions tools/generate_pybind_stubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,18 @@ def eq_sub_func(match: re.Match) -> str:
else:
return "\n".join(
[
f"{match.group('indent')}def __eq__(self, arg0: {match.group('other')}) -> {match.group('return')}:{match.group('ellipsis_docstring')}",
f"{match.group('indent')}def __eq__(self, other: {match.group('other')}) -> {match.group('return')}:{match.group('ellipsis_docstring')}",
f"{match.group('indent')}@typing.overload",
f"{match.group('indent')}def __eq__(self, arg0: typing.Any) -> bool | types.NotImplementedType: ...",
f"{match.group('indent')}def __eq__(self, other: typing.Any) -> bool | types.NotImplementedType: ...",
]
)
else:
return "\n".join(
[
f"{match.group('indent')}@typing.overload",
f"{match.group('indent')}def __eq__(self, arg0: {match.group('other')}) -> {match.group('return')}:{match.group('ellipsis_docstring')}",
f"{match.group('indent')}def __eq__(self, other: {match.group('other')}) -> {match.group('return')}:{match.group('ellipsis_docstring')}",
f"{match.group('indent')}@typing.overload",
f"{match.group('indent')}def __eq__(self, arg0: typing.Any) -> bool | types.NotImplementedType: ...",
f"{match.group('indent')}def __eq__(self, other: typing.Any) -> bool | types.NotImplementedType: ...",
]
)

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