Skip to content

Commit 4cccc4a

Browse files
committed
refactor: switch to mixed project
1 parent d429e3c commit 4cccc4a

File tree

4 files changed

+258
-248
lines changed

4 files changed

+258
-248
lines changed

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ asyncio_mode = "auto"
4646
asyncio_default_fixture_loop_scope = "function"
4747

4848
[tool.ruff]
49-
exclude = ["docs/examples/example_*.py"]
49+
exclude = ["python/rustac/__init__.py", "docs/examples/example_*.py"]
5050

5151
[dependency-groups]
5252
dev = [
@@ -87,7 +87,8 @@ requires = ["maturin>=1.7,<2.0"]
8787
build-backend = "maturin"
8888

8989
[tool.maturin]
90+
python-source = "python"
9091
strip = true
91-
opt-level = "z" # TODO compare with "s"
92+
opt-level = "z" # TODO compare with "s"
9293
lto = true
9394
codegen-units = 1

python/rustac/__init__.py

Lines changed: 253 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,253 @@
1+
from __future__ import annotations
2+
3+
from .rustac import *
4+
from typing import TypedDict
5+
6+
7+
class Catalog(TypedDict):
8+
"""A STAC Catalog object represents a logical group of other Catalog, Collection, and Item objects."""
9+
10+
type: str
11+
"""Set to Catalog if this Catalog only implements the Catalog spec."""
12+
13+
stac_version: str
14+
"""The STAC version the Catalog implements."""
15+
16+
stac_extensions: list[str] | None
17+
"""A list of extension identifiers the Catalog implements."""
18+
19+
id: str
20+
"""Identifier for the Catalog."""
21+
22+
title: str | None
23+
"""A short descriptive one-line title for the Catalog."""
24+
25+
description: str
26+
"""Detailed multi-line description to fully explain the Catalog.
27+
28+
CommonMark 0.29 syntax MAY be used for rich text representation."""
29+
30+
links: list[Link]
31+
"""A list of references to other documents."""
32+
33+
class Collection(TypedDict):
34+
"""The STAC Collection Specification defines a set of common fields to describe a group of Items that share properties and metadata."""
35+
36+
type: str
37+
"""Must be set to Collection to be a valid Collection."""
38+
39+
stac_version: str
40+
"""The STAC version the Collection implements."""
41+
42+
stac_extensions: list[str] | None
43+
"""A list of extension identifiers the Collection implements."""
44+
45+
id: str
46+
"""Identifier for the Collection that is unique across all collections in the root catalog."""
47+
48+
title: str | None
49+
"""A short descriptive one-line title for the Collection."""
50+
51+
description: str
52+
"""Detailed multi-line description to fully explain the Collection.
53+
54+
CommonMark 0.29 syntax MAY be used for rich text representation."""
55+
56+
keywords: list[str] | None
57+
"""List of keywords describing the Collection."""
58+
59+
license: str
60+
"""License(s) of the data collection as SPDX License identifier, SPDX License expression, or `other`."""
61+
62+
providers: list[Provider] | None
63+
"""A list of providers, which may include all organizations capturing or processing the data or the hosting provider."""
64+
65+
extent: Extent
66+
"""Spatial and temporal extents."""
67+
68+
summaries: dict[str, Any]
69+
"""A map of property summaries, either a set of values, a range of values or a JSON Schema."""
70+
71+
links: list[Link]
72+
"""A list of references to other documents."""
73+
74+
assets: dict[str, Asset] | None
75+
"""Dictionary of asset objects that can be downloaded, each with a unique key."""
76+
77+
item_assets: dict[str, ItemAsset] | None
78+
"""A dictionary of assets that can be found in member Items."""
79+
80+
class Provider(TypedDict):
81+
"""A provider is any of the organizations that captures or processes the content of the Collection and therefore influences the data offered by this Collection."""
82+
83+
name: str
84+
"""The name of the organization or the individual."""
85+
86+
description: str | None
87+
"""Multi-line description to add further provider information such as processing details for processors and producers, hosting details for hosts or basic contact information.
88+
89+
CommonMark 0.29 syntax MAY be used for rich text representation."""
90+
91+
roles: list[
92+
Literal["licensor"]
93+
| Literal["producer"]
94+
| Literal["processor"]
95+
| Literal["host"]
96+
]
97+
"""Roles of the provider."""
98+
99+
url: str | None
100+
"""Homepage on which the provider describes the dataset and publishes contact information."""
101+
102+
class Extent(TypedDict):
103+
"""The object describes the spatio-temporal extents of the Collection."""
104+
105+
spatial: SpatialExtent
106+
"""Potential spatial extents covered by the Collection."""
107+
108+
temporal: TemporalExtent
109+
"""Potential temporal extents covered by the Collection."""
110+
111+
class SpatialExtent(TypedDict):
112+
"""The object describes the spatial extents of the Collection."""
113+
114+
bbox: list[list[int | float]]
115+
"""Potential spatial extents covered by the Collection."""
116+
117+
class TemporalExtent(TypedDict):
118+
"""The object describes the temporal extents of the Collection."""
119+
120+
bbox: list[list[str | None]]
121+
"""Potential temporal extents covered by the Collection."""
122+
123+
class ItemAsset(TypedDict):
124+
"""An Item Asset Object defined at the Collection level is nearly the same as the Asset Object in Items, except for two differences.
125+
126+
The href field is not required, because Item Asset Definitions don't point to any data by themselves, but at least two other fields must be present."""
127+
128+
title: str | None
129+
"""The displayed title for clients and users."""
130+
131+
description: str | None
132+
"""A description of the Asset providing additional details, such as how it was processed or created.
133+
134+
CommonMark 0.29 syntax MAY be used for rich text representation."""
135+
136+
type: str | None
137+
"""Media type of the asset."""
138+
139+
roles: list[str] | None
140+
"""The semantic roles of the asset, similar to the use of rel in links."""
141+
142+
class Item(TypedDict):
143+
"""An Item is a GeoJSON Feature augmented with foreign members relevant to a STAC object."""
144+
145+
type: str
146+
"""Type of the GeoJSON Object. MUST be set to Feature."""
147+
148+
stac_version: str
149+
"""The STAC version the Item implements."""
150+
151+
stac_extensions: list[str] | None
152+
"""A list of extensions the Item implements."""
153+
154+
id: str
155+
"""Provider identifier. The ID should be unique within the Collection that contains the Item."""
156+
157+
geometry: dict[str, Any] | None
158+
"""Defines the full footprint of the asset represented by this item, formatted according to RFC 7946, section 3.1 if a geometry is provided or section 3.2 if no geometry is provided."""
159+
160+
bbox: list[int | float] | None
161+
"""REQUIRED if geometry is not null, prohibited if geometry is null.
162+
163+
Bounding Box of the asset represented by this Item, formatted according to RFC 7946, section 5."""
164+
165+
properties: Properties
166+
"""A dictionary of additional metadata for the Item."""
167+
168+
links: list[Link]
169+
"""List of link objects to resources and related URLs.
170+
171+
See the best practices for details on when the use self links is strongly recommended."""
172+
173+
assets: dict[str, Asset]
174+
"""Dictionary of asset objects that can be downloaded, each with a unique key."""
175+
176+
collection: str | None
177+
"""The id of the STAC Collection this Item references to.
178+
179+
This field is required if a link with a collection relation type is present and is not allowed otherwise."""
180+
181+
class Properties(TypedDict):
182+
"""Additional metadata fields can be added to the GeoJSON Object Properties."""
183+
184+
datetime: str | None
185+
"""The searchable date and time of the assets, which must be in UTC.
186+
187+
It is formatted according to RFC 3339, section 5.6. null is allowed, but requires start_datetime and end_datetime from common metadata to be set."""
188+
189+
class Link(TypedDict):
190+
"""This object describes a relationship with another entity.
191+
192+
Data providers are advised to be liberal with the links section, to describe
193+
things like the Catalog an Item is in, related Items, parent or child Items
194+
(modeled in different ways, like an 'acquisition' or derived data)."""
195+
196+
href: str
197+
"""The actual link in the format of an URL.
198+
199+
Relative and absolute links are both allowed. Trailing slashes are significant."""
200+
201+
rel: str
202+
"""Relationship between the current document and the linked document."""
203+
204+
type: str | None
205+
"""Media type of the referenced entity."""
206+
207+
title: str | None
208+
"""A human readable title to be used in rendered displays of the link."""
209+
210+
method: str | None
211+
"""The HTTP method that shall be used for the request to the target resource, in uppercase.
212+
213+
GET by default"""
214+
215+
headers: dict[str, str | list[str]] | None
216+
"""The HTTP headers to be sent for the request to the target resource."""
217+
218+
body: Any | None
219+
"""The HTTP body to be sent to the target resource."""
220+
221+
class Asset(TypedDict):
222+
"""An Asset is an object that contains a URI to data associated with the Item that can be downloaded or streamed.
223+
224+
It is allowed to add additional fields."""
225+
226+
href: str
227+
"""URI to the asset object. Relative and absolute URI are both allowed. Trailing slashes are significant."""
228+
229+
title: str | None
230+
"""The displayed title for clients and users."""
231+
232+
description: str | None
233+
"""A description of the Asset providing additional details, such as how it was processed or created.
234+
235+
CommonMark 0.29 syntax MAY be used for rich text representation."""
236+
237+
type: str | None
238+
"""Media type of the asset.
239+
240+
See the common media types in the best practice doc for commonly used asset types."""
241+
242+
roles: list[str] | None
243+
"""The semantic roles of the asset, similar to the use of rel in links."""
244+
245+
class ItemCollection(TypedDict):
246+
"""A GeoJSON feature collection of STAC Items."""
247+
248+
features: list[Item]
249+
"""STAC items."""
250+
251+
__doc__ = rustac.__doc__
252+
if hasattr(rustac, "__all__"):
253+
__all__ = rustac.__all__

python/rustac/py.typed

Whitespace-only changes.

0 commit comments

Comments
 (0)