Skip to content

Commit f34bb82

Browse files
committed
Switch to PyAwaitable PyPI build.
1 parent 252d5d6 commit f34bb82

13 files changed

+93
-1163
lines changed

CMakeLists.txt

+5-1
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,12 @@ find_package(
1515
# Link Python
1616
python_add_library(_view MODULE ${_view_SRC} WITH_SOABI)
1717

18+
# Settings
19+
add_compile_definitions(PYAWAITABLE_PYAPI)
20+
1821
# Add include directories
1922
target_include_directories(_view PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include/)
23+
target_include_directories(_view PUBLIC $ENV{PYAWAITABLE_INCLUDE_DIR})
2024

2125
# Install extension module
22-
install(TARGETS _view DESTINATION .)
26+
install(TARGETS _view DESTINATION .)

hatch.toml

+4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ packages = ["src/view"]
1010
[build.targets.wheel.force-include]
1111
"_view.pyi" = "_view.pyi"
1212

13+
[metadata.hooks.custom]
14+
path = "hatch_build.py"
15+
enable-by-default = true
16+
1317
[build.targets.wheel.hooks.scikit-build]
1418
experimental = true
1519

hatch_build.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from hatchling.metadata.plugin.interface import MetadataHookInterface
2+
import pyawaitable
3+
import os
4+
5+
class JSONMetaDataHook(MetadataHookInterface):
6+
def update(self, *_) -> None:
7+
os.environ["PYAWAITABLE_INCLUDE_DIR"] = pyawaitable.include()

include/view/pyawaitable.h

-261
This file was deleted.

pyproject.toml

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = ["scikit-build-core>=0.9.0", "hatchling"]
2+
requires = ["scikit-build-core>=0.9.0", "hatchling", "pyawaitable"]
33
build-backend = "hatchling.build"
44

55
[project]
@@ -28,6 +28,7 @@ dependencies = [
2828
"configzen",
2929
"aiofiles",
3030
"prompts.py",
31+
"pyawaitable"
3132
]
3233
dynamic = ["version", "license"]
3334

@@ -73,7 +74,5 @@ view = "view.__main__:main"
7374
view-py = "view.__main__:main"
7475

7576
[tool.pytest.ini_options]
76-
pystack_threshold=60
77-
pystack_path="custom-version-of-pystack"
78-
pystack_output_file="./pystack.log"
79-
pystack_args="--native"
77+
pystack_threshold = 60
78+
pystack_args = "--native"

requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
hatch
1+
hatch

src/_view/app.c

+14-7
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@
3939
#include <view/results.h> // pymem_strdup
4040
#include <view/handling.h> // route_free, route_new, handle_route, handle_route_query
4141
#include <view/map.h>
42-
#include <view/pyawaitable.h>
4342
#include <view/view.h> // VIEW_FATAL
4443

44+
#include <pyawaitable.h>
45+
4546
#define LOAD_ROUTE(target) \
4647
char *path; \
4748
PyObject *callable; \
@@ -265,9 +266,11 @@ lifespan(PyObject *awaitable, PyObject *result)
265266
Py_DECREF(send_dict);
266267

267268
if (
268-
PyAwaitable_AWAIT(
269+
PyAwaitable_AddAwait(
269270
awaitable,
270-
send_coro
271+
send_coro,
272+
NULL,
273+
NULL
271274
) < 0
272275
)
273276
{
@@ -763,9 +766,11 @@ app(
763766
}
764767

765768
if (
766-
PyAwaitable_AWAIT(
769+
PyAwaitable_AddAwait(
767770
awaitable,
768-
coro
771+
coro,
772+
NULL,
773+
NULL
769774
) < 0
770775
)
771776
{
@@ -833,9 +838,11 @@ app(
833838
}
834839

835840
if (
836-
PyAwaitable_AWAIT(
841+
PyAwaitable_AddAwait(
837842
awaitable,
838-
coro
843+
coro,
844+
NULL,
845+
NULL
839846
) < 0
840847
)
841848
{

0 commit comments

Comments
 (0)