Skip to content

Commit d04bae1

Browse files
Update build tools, dependencies and stubs (#15)
* Move build directory * Update pybind11 extensions dependency * Update stub generator * Improve stub generator * Update stubs
1 parent f8fc0f1 commit d04bae1

File tree

16 files changed

+256
-32
lines changed

16 files changed

+256
-32
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
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"

src/amulet/game/__init__.pyi

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
"""
2+
A module to store data about the game including state enumerations and translations between different game versions.
3+
"""
4+
5+
from __future__ import annotations
6+
7+
from amulet.game.bedrock._version import BedrockGameVersion
8+
from amulet.game.game import game_platforms, game_versions, get_game_version
9+
from amulet.game.java.version import JavaGameVersion
10+
11+
from . import _amulet_game, _version, abc, bedrock, game, java, translate
12+
13+
__all__: list[str] = [
14+
"BedrockGameVersion",
15+
"JavaGameVersion",
16+
"abc",
17+
"bedrock",
18+
"compiler_config",
19+
"game",
20+
"game_platforms",
21+
"game_versions",
22+
"get_game_version",
23+
"java",
24+
"translate",
25+
]
26+
27+
def _init() -> None: ...
28+
29+
__version__: str
30+
compiler_config: dict

src/amulet/game/_amulet_game.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ from __future__ import annotations
22

33
import types
44

5-
__all__ = ["init"]
5+
__all__: list[str] = ["init"]
66

77
def init(arg0: types.ModuleType) -> None: ...

src/amulet/game/abc/__init__.pyi

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
from __future__ import annotations
2+
3+
import typing
4+
5+
from amulet.game.abc._block_specification import (
6+
BlockSpec,
7+
NBTSpec,
8+
PropertySpec,
9+
PropertyValueSpec,
10+
load_json_block_spec,
11+
)
12+
from amulet.game.abc.biome import (
13+
BiomeData,
14+
BiomeDataNumericalComponent,
15+
BiomeTranslationError,
16+
DatabaseBiomeData,
17+
load_json_biome_data,
18+
)
19+
from amulet.game.abc.block import (
20+
BlockData,
21+
BlockDataNumericalComponent,
22+
BlockTranslationError,
23+
DatabaseBlockData,
24+
)
25+
from amulet.game.abc.json_interface import JSONInterface
26+
from amulet.game.abc.version import GameVersion
27+
28+
from . import (
29+
_block_specification,
30+
biome,
31+
block,
32+
game_version_container,
33+
json_interface,
34+
version,
35+
)
36+
37+
__all__: list[str] = [
38+
"BiomeData",
39+
"BiomeDataNumericalComponent",
40+
"BiomeTranslationError",
41+
"BlockData",
42+
"BlockDataNumericalComponent",
43+
"BlockSpec",
44+
"BlockTranslationError",
45+
"DatabaseBiomeData",
46+
"DatabaseBlockData",
47+
"GameVersion",
48+
"JSONCompatible",
49+
"JSONDict",
50+
"JSONInterface",
51+
"JSONList",
52+
"NBTSpec",
53+
"PropertySpec",
54+
"PropertyValueSpec",
55+
"biome",
56+
"block",
57+
"game_version_container",
58+
"json_interface",
59+
"load_json_biome_data",
60+
"load_json_block_spec",
61+
"version",
62+
]
63+
JSONCompatible: (
64+
typing._UnionGenericAlias
65+
) # value = typing.Union[str, int, float, bool, NoneType, ForwardRef('JSONList'), ForwardRef('JSONDict')]
66+
JSONDict: typing.TypeAlias = dict[str, "JSONCompatible"]
67+
JSONList: typing.TypeAlias = list["JSONCompatible"]
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from __future__ import annotations
2+
3+
from amulet.game.bedrock._version import BedrockGameVersion
4+
5+
from . import _biome, _block, _version
6+
7+
__all__: list[str] = ["BedrockGameVersion"]

src/amulet/game/java/__init__.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ from amulet.game.java.version import JavaGameVersion
55

66
from . import _block, biome, block, version
77

8-
__all__ = ["JavaGameVersion", "Waterloggable", "biome", "block", "version"]
8+
__all__: list[str] = ["JavaGameVersion", "Waterloggable", "biome", "block", "version"]

src/amulet/game/java/_block.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ from __future__ import annotations
22

33
import typing
44

5-
__all__ = ["Waterloggable"]
5+
__all__: list[str] = ["Waterloggable"]
66

77
class Waterloggable:
88
"""
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"""
2+
A package to support translating block and entity data between versions.
3+
Everything that is not imported into this module is an implementation detail.
4+
"""
5+
6+
from __future__ import annotations
7+
8+
from amulet.game.translate._translator import (
9+
BlockFromUniversalTranslator,
10+
BlockToUniversalTranslator,
11+
EntityFromUniversalTranslator,
12+
EntityToUniversalTranslator,
13+
load_json_block_translations,
14+
)
15+
16+
from . import _functions, _translator
17+
18+
__all__: list[str] = [
19+
"BlockFromUniversalTranslator",
20+
"BlockToUniversalTranslator",
21+
"EntityFromUniversalTranslator",
22+
"EntityToUniversalTranslator",
23+
"load_json_block_translations",
24+
]

0 commit comments

Comments
 (0)