Skip to content

Commit a23bd1d

Browse files
Update pybind11 and enable meta build (#6)
* Update dependencies * Enable meta build * Update stubs * Fix target name
1 parent e39ddf7 commit a23bd1d

File tree

6 files changed

+70
-37
lines changed

6 files changed

+70
-37
lines changed

requirements.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
AMULET_COMPILER_TARGET_REQUIREMENT = "==2.0"
55
AMULET_COMPILER_VERSION_REQUIREMENT = "==3.0.0"
66

7-
PYBIND11_REQUIREMENT = "==2.13.6"
7+
PYBIND11_REQUIREMENT = "==3.0.0"
88
AMULET_PYBIND11_EXTENSIONS_REQUIREMENT = "~=1.1.0.0a0"
99
AMULET_IO_REQUIREMENT = "~=1.0"
10-
AMULET_UTILS_REQUIREMENT = "~=1.1.0.0a6"
11-
AMULET_ZLIB_REQUIREMENT = "~=1.0.0.0a7"
12-
AMULET_NBT_REQUIREMENT = "~=5.0.0.0a6"
13-
AMULET_CORE_REQUIREMENT = "~=2.0.3.0a1"
10+
AMULET_UTILS_REQUIREMENT = "~=1.1.1.0a0"
11+
AMULET_ZLIB_REQUIREMENT = "~=1.0.1.0a0"
12+
AMULET_NBT_REQUIREMENT = "~=5.0.1.0a0"
13+
AMULET_CORE_REQUIREMENT = "~=2.0.4.0a0"
1414

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

src/amulet/anvil/__init__.pyi

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from __future__ import annotations
22

3-
import logging as logging
43
import typing
54

65
import amulet.nbt
@@ -17,7 +16,6 @@ __all__ = [
1716
"RegionDoesNotExist",
1817
"compiler_config",
1918
"dimension",
20-
"logging",
2119
"region",
2220
]
2321

src/amulet/anvil/dimension.pyi

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class AnvilDimension:
2121
layer_names: collections.abc.Iterable[str],
2222
mcc: bool = False,
2323
) -> None: ...
24-
def all_chunk_coords(self) -> typing.Iterator[tuple[int, int]]:
24+
def all_chunk_coords(self) -> collections.abc.Iterator[tuple[int, int]]:
2525
"""
2626
Get an iterator for all the chunks that exist in this dimension.
2727
External Read::SharedReadWrite lock required.
@@ -34,7 +34,7 @@ class AnvilDimension:
3434
External ReadWrite::SharedReadOnly lock required.
3535
"""
3636

37-
def delete_chunk(self, cx: int, cz: int) -> None:
37+
def delete_chunk(self, cx: typing.SupportsInt, cz: typing.SupportsInt) -> None:
3838
"""
3939
Delete all data for the given chunk.
4040
External ReadWrite::SharedReadWrite lock required.
@@ -48,7 +48,9 @@ class AnvilDimension:
4848
External ReadWrite:Unique lock required.
4949
"""
5050

51-
def get_chunk_data(self, cx: int, cz: int) -> dict[str, amulet.nbt.NamedTag]:
51+
def get_chunk_data(
52+
self, cx: typing.SupportsInt, cz: typing.SupportsInt
53+
) -> dict[str, amulet.nbt.NamedTag]:
5254
"""
5355
Get the data for a chunk
5456
External Read::SharedReadWrite lock required.
@@ -62,7 +64,7 @@ class AnvilDimension:
6264
// External ReadWrite::SharedReadWrite lock required if calling ReadWrite methods on AnvilDimensionLayer.
6365
"""
6466

65-
def has_chunk(self, cx: int, cz: int) -> bool:
67+
def has_chunk(self, cx: typing.SupportsInt, cz: typing.SupportsInt) -> bool:
6668
"""
6769
Check if a chunk exists.
6870
External Read::SharedReadWrite lock required.
@@ -85,8 +87,8 @@ class AnvilDimension:
8587

8688
def set_chunk_data(
8789
self,
88-
cx: int,
89-
cz: int,
90+
cx: typing.SupportsInt,
91+
cz: typing.SupportsInt,
9092
data_layers: collections.abc.Iterable[tuple[str, amulet.nbt.NamedTag]],
9193
) -> None:
9294
"""
@@ -129,14 +131,14 @@ class AnvilDimensionLayer:
129131
"""
130132

131133
def __init__(self, directory: str, mcc: bool = False) -> None: ...
132-
def all_chunk_coords(self) -> typing.Iterator[tuple[int, int]]:
134+
def all_chunk_coords(self) -> collections.abc.Iterator[tuple[int, int]]:
133135
"""
134136
An iterator of all chunk coordinates in this layer.
135137
External Read::SharedReadWrite lock required.
136138
External Read::SharedReadOnly lock optional.
137139
"""
138140

139-
def all_region_coords(self) -> typing.Iterator[tuple[int, int]]:
141+
def all_region_coords(self) -> collections.abc.Iterator[tuple[int, int]]:
140142
"""
141143
An iterator of all region coordinates in this layer.
142144
External Read::SharedReadWrite lock required.
@@ -149,7 +151,7 @@ class AnvilDimensionLayer:
149151
External ReadWrite::SharedReadOnly lock required.
150152
"""
151153

152-
def delete_chunk(self, cx: int, cz: int) -> None:
154+
def delete_chunk(self, cx: typing.SupportsInt, cz: typing.SupportsInt) -> None:
153155
"""
154156
Delete the chunk data from this layer.
155157
External ReadWrite::SharedReadWrite lock required.
@@ -163,15 +165,17 @@ class AnvilDimensionLayer:
163165
External ReadWrite:Unique lock required.
164166
"""
165167

166-
def get_chunk_data(self, cx: int, cz: int) -> amulet.nbt.NamedTag:
168+
def get_chunk_data(
169+
self, cx: typing.SupportsInt, cz: typing.SupportsInt
170+
) -> amulet.nbt.NamedTag:
167171
"""
168172
Get a NamedTag of a chunk from the database.
169173
Will raise ChunkDoesNotExist if the region or chunk does not exist
170174
External Read::SharedReadWrite lock required.
171175
"""
172176

173177
def get_region(
174-
self, rx: int, rz: int, create: bool = False
178+
self, rx: typing.SupportsInt, rz: typing.SupportsInt, create: bool = False
175179
) -> amulet.anvil.region.AnvilRegion:
176180
"""
177181
Get an AnvilRegion instance from chunk coordinates it contains. This must not be stored long-term.
@@ -181,7 +185,7 @@ class AnvilDimensionLayer:
181185
"""
182186

183187
def get_region_at_chunk(
184-
self, cx: int, cz: int, create: bool = False
188+
self, cx: typing.SupportsInt, cz: typing.SupportsInt, create: bool = False
185189
) -> amulet.anvil.region.AnvilRegion:
186190
"""
187191
Get an AnvilRegion instance from chunk coordinates it contains. This must not be stored long-term.
@@ -190,21 +194,23 @@ class AnvilDimensionLayer:
190194
External ReadWrite::SharedReadWrite lock required if calling ReadWrite methods on AnvilRegion.
191195
"""
192196

193-
def has_chunk(self, cx: int, cz: int) -> bool:
197+
def has_chunk(self, cx: typing.SupportsInt, cz: typing.SupportsInt) -> bool:
194198
"""
195199
Check if the chunk has data in this layer.
196200
External Read::SharedReadWrite lock required.
197201
External Read::SharedReadOnly lock optional.
198202
"""
199203

200-
def has_region(self, rx: int, rz: int) -> bool:
204+
def has_region(self, rx: typing.SupportsInt, rz: typing.SupportsInt) -> bool:
201205
"""
202206
Check if a region file exists in this layer at given the coordinates.
203207
External Read::SharedReadWrite lock required.
204208
External Read::SharedReadOnly lock optional.
205209
"""
206210

207-
def has_region_at_chunk(self, cx: int, cz: int) -> bool:
211+
def has_region_at_chunk(
212+
self, cx: typing.SupportsInt, cz: typing.SupportsInt
213+
) -> bool:
208214
"""
209215
Check if a region file exists in this layer that contains the given chunk.
210216
External Read::SharedReadWrite lock required.
@@ -218,7 +224,9 @@ class AnvilDimensionLayer:
218224
External Read:SharedReadWrite lock required.
219225
"""
220226

221-
def set_chunk_data(self, cx: int, cz: int, tag: amulet.nbt.NamedTag) -> None:
227+
def set_chunk_data(
228+
self, cx: typing.SupportsInt, cz: typing.SupportsInt, tag: amulet.nbt.NamedTag
229+
) -> None:
222230
"""
223231
Set the chunk data for this layer.
224232
External ReadWrite::SharedReadWrite lock required.

src/amulet/anvil/region.pyi

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import collections.abc
34
import typing
45

56
import amulet.nbt
@@ -24,14 +25,25 @@ class AnvilRegion:
2425

2526
@typing.overload
2627
def __init__(
27-
self, directory: str, file_name: str, rx: int, rz: int, mcc: bool = False
28+
self,
29+
directory: str,
30+
file_name: str,
31+
rx: typing.SupportsInt,
32+
rz: typing.SupportsInt,
33+
mcc: bool = False,
2834
) -> None:
2935
"""
3036
Construct from the directory path, name of the file and region coordinates.
3137
"""
3238

3339
@typing.overload
34-
def __init__(self, directory: str, rx: int, rz: int, mcc: bool = False) -> None:
40+
def __init__(
41+
self,
42+
directory: str,
43+
rx: typing.SupportsInt,
44+
rz: typing.SupportsInt,
45+
mcc: bool = False,
46+
) -> None:
3547
"""
3648
Construct from the directory path and region coordinates.
3749
File name is computed from region coordinates.
@@ -60,22 +72,25 @@ class AnvilRegion:
6072
External ReadWrite:SharedReadWrite lock required.
6173
"""
6274

63-
def contains(self, cx: int, cz: int) -> bool:
75+
def contains(self, cx: typing.SupportsInt, cz: typing.SupportsInt) -> bool:
6476
"""
6577
Is the coordinate in the region.
6678
This returns true even if there is no value for the coordinate.
6779
Coordinates are in world space.
6880
Thread safe.
6981
"""
7082

71-
def delete_batch(self, coords: list[tuple[int, int]]) -> None:
83+
def delete_batch(
84+
self,
85+
coords: collections.abc.Sequence[tuple[typing.SupportsInt, typing.SupportsInt]],
86+
) -> None:
7287
"""
7388
Delete multiple chunk's data.
7489
Coordinates are in world space.
7590
External ReadWrite:SharedReadWrite lock required.
7691
"""
7792

78-
def delete_value(self, cx: int, cz: int) -> None:
93+
def delete_value(self, cx: typing.SupportsInt, cz: typing.SupportsInt) -> None:
7994
"""
8095
Delete the chunk data.
8196
Coordinates are in world space.
@@ -107,14 +122,16 @@ class AnvilRegion:
107122
Thread safe.
108123
"""
109124

110-
def get_value(self, cx: int, cz: int) -> amulet.nbt.NamedTag:
125+
def get_value(
126+
self, cx: typing.SupportsInt, cz: typing.SupportsInt
127+
) -> amulet.nbt.NamedTag:
111128
"""
112129
Get the value for this coordinate.
113130
Coordinates are in world space.
114131
External Read:SharedReadWrite lock required.
115132
"""
116133

117-
def has_value(self, cx: int, cz: int) -> bool:
134+
def has_value(self, cx: typing.SupportsInt, cz: typing.SupportsInt) -> bool:
118135
"""
119136
Is there a value stored for this coordinate.
120137
Coordinates are in world space.
@@ -129,7 +146,9 @@ class AnvilRegion:
129146
External Read:SharedReadWrite lock required.
130147
"""
131148

132-
def set_value(self, cx: int, cz: int, tag: amulet.nbt.NamedTag) -> None:
149+
def set_value(
150+
self, cx: typing.SupportsInt, cz: typing.SupportsInt, tag: amulet.nbt.NamedTag
151+
) -> None:
133152
"""
134153
Set the value for this coordinate.
135154
Coordinates are in world space.

tests/CMakeLists.txt

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,18 @@ else()
1818
endif()
1919

2020
# Find dependencies
21-
find_package(pybind11 CONFIG REQUIRED)
22-
find_package(amulet_pybind11_extensions CONFIG REQUIRED)
23-
find_package(amulet_test_utils CONFIG REQUIRED)
24-
find_package(amulet_anvil CONFIG REQUIRED)
21+
if (NOT TARGET pybind11::module)
22+
find_package(pybind11 CONFIG REQUIRED)
23+
endif()
24+
if (NOT TARGET amulet_pybind11_extensions)
25+
find_package(amulet_pybind11_extensions CONFIG REQUIRED)
26+
endif()
27+
if (NOT TARGET amulet_test_utils)
28+
find_package(amulet_test_utils CONFIG REQUIRED)
29+
endif()
30+
if (NOT TARGET amulet_anvil)
31+
find_package(amulet_anvil CONFIG REQUIRED)
32+
endif()
2533

2634
# Find sources
2735
file(GLOB_RECURSE SOURCES LIST_DIRECTORIES false "${CMAKE_CURRENT_LIST_DIR}/*.py.cpp")

tests/test_amulet_anvil/__init__.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from __future__ import annotations
22

3-
import faulthandler as faulthandler
3+
import faulthandler as _faulthandler
44

55
from . import _test_amulet_anvil, test_region_
66

7-
__all__ = ["compiler_config", "faulthandler", "test_region_"]
7+
__all__ = ["compiler_config", "test_region_"]
88

99
def _init() -> None: ...
1010

0 commit comments

Comments
 (0)