Skip to content

Commit

Permalink
Switch to PyAwaitable PyPI build.
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeroIntensity committed Aug 4, 2024
1 parent 252d5d6 commit f34bb82
Show file tree
Hide file tree
Showing 13 changed files with 93 additions and 1,163 deletions.
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ find_package(
# Link Python
python_add_library(_view MODULE ${_view_SRC} WITH_SOABI)

# Settings
add_compile_definitions(PYAWAITABLE_PYAPI)

# Add include directories
target_include_directories(_view PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include/)
target_include_directories(_view PUBLIC $ENV{PYAWAITABLE_INCLUDE_DIR})

# Install extension module
install(TARGETS _view DESTINATION .)
install(TARGETS _view DESTINATION .)
4 changes: 4 additions & 0 deletions hatch.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ packages = ["src/view"]
[build.targets.wheel.force-include]
"_view.pyi" = "_view.pyi"

[metadata.hooks.custom]
path = "hatch_build.py"
enable-by-default = true

[build.targets.wheel.hooks.scikit-build]
experimental = true

Expand Down
7 changes: 7 additions & 0 deletions hatch_build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from hatchling.metadata.plugin.interface import MetadataHookInterface
import pyawaitable
import os

class JSONMetaDataHook(MetadataHookInterface):
def update(self, *_) -> None:
os.environ["PYAWAITABLE_INCLUDE_DIR"] = pyawaitable.include()
261 changes: 0 additions & 261 deletions include/view/pyawaitable.h

This file was deleted.

9 changes: 4 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["scikit-build-core>=0.9.0", "hatchling"]
requires = ["scikit-build-core>=0.9.0", "hatchling", "pyawaitable"]
build-backend = "hatchling.build"

[project]
Expand Down Expand Up @@ -28,6 +28,7 @@ dependencies = [
"configzen",
"aiofiles",
"prompts.py",
"pyawaitable"
]
dynamic = ["version", "license"]

Expand Down Expand Up @@ -73,7 +74,5 @@ view = "view.__main__:main"
view-py = "view.__main__:main"

[tool.pytest.ini_options]
pystack_threshold=60
pystack_path="custom-version-of-pystack"
pystack_output_file="./pystack.log"
pystack_args="--native"
pystack_threshold = 60
pystack_args = "--native"
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
hatch
hatch
21 changes: 14 additions & 7 deletions src/_view/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@
#include <view/results.h> // pymem_strdup
#include <view/handling.h> // route_free, route_new, handle_route, handle_route_query
#include <view/map.h>
#include <view/pyawaitable.h>
#include <view/view.h> // VIEW_FATAL

#include <pyawaitable.h>

#define LOAD_ROUTE(target) \
char *path; \
PyObject *callable; \
Expand Down Expand Up @@ -265,9 +266,11 @@ lifespan(PyObject *awaitable, PyObject *result)
Py_DECREF(send_dict);

if (
PyAwaitable_AWAIT(
PyAwaitable_AddAwait(
awaitable,
send_coro
send_coro,
NULL,
NULL
) < 0
)
{
Expand Down Expand Up @@ -763,9 +766,11 @@ app(
}

if (
PyAwaitable_AWAIT(
PyAwaitable_AddAwait(
awaitable,
coro
coro,
NULL,
NULL
) < 0
)
{
Expand Down Expand Up @@ -833,9 +838,11 @@ app(
}

if (
PyAwaitable_AWAIT(
PyAwaitable_AddAwait(
awaitable,
coro
coro,
NULL,
NULL
) < 0
)
{
Expand Down
Loading

0 comments on commit f34bb82

Please sign in to comment.