Skip to content

Commit 4d925b3

Browse files
committed
refactor: Initial Python 3.13 rework
* Remove Router in favor of nanoroute * Update all Python.h includes * Update py-build-cmake * Update CI to use pre-installed vcpkg on ubuntu
1 parent b82196e commit 4d925b3

File tree

21 files changed

+90
-391
lines changed

21 files changed

+90
-391
lines changed

.github/workflows/test.yaml

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,53 @@ on:
55
push:
66
pull_request:
77

8-
98
jobs:
109
build_windows:
1110
name: Build and Test on Windows
1211
runs-on: windows-latest
1312

1413
steps:
14+
- name: Export GitHub Actions cache environment variables
15+
uses: actions/github-script@v7
16+
with:
17+
script: |
18+
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
19+
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
20+
1521
- name: Checkout
1622
uses: actions/checkout@v4
1723

1824
- name: Setup Python
1925
uses: actions/setup-python@v5
2026
with:
21-
python-version: '3.12'
27+
python-version: "3.13"
2228

2329
- name: Build
30+
env:
31+
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
2432
run: |
2533
python -m venv .venv
2634
.venv\Scripts\Activate.ps1
27-
pip install .
35+
python -m pip install --upgrade pip
36+
pip install '.[test]' -C override=cmake.args+=["--toolchain=$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake"]
2837
2938
- name: Test
3039
run: |
3140
.venv\Scripts\Activate.ps1
32-
pip install pytest
3341
pytest test
3442
3543
build_macos:
3644
name: Build and Test on MacOS
3745
runs-on: macos-latest
3846

3947
steps:
48+
- name: Export GitHub Actions cache environment variables
49+
uses: actions/github-script@v7
50+
with:
51+
script: |
52+
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
53+
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
54+
4055
- name: Checkout
4156
uses: actions/checkout@v4
4257

@@ -45,35 +60,55 @@ jobs:
4560
with:
4661
xcode-version: latest
4762

63+
- name: Setup Python
64+
uses: actions/setup-python@v5
65+
with:
66+
python-version: "3.13"
67+
4868
- name: Build
69+
env:
70+
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
4971
run: |
5072
python -m venv .venv
5173
. .venv/bin/activate
5274
pip install --upgrade pip
53-
pip install .
75+
pip install '.[test]' -C override=cmake.options.VELOCEM_BOOTSTRAP_VCPKG="ON"
5476
5577
- name: Test
5678
run: |
5779
. .venv/bin/activate
58-
pip install pytest
5980
pytest test
6081
6182
build_linux:
6283
name: Build and Test on Linux
63-
runs-on: ubuntu-24.04
84+
runs-on: ubuntu-latest
85+
6486
steps:
87+
- name: Export GitHub Actions cache environment variables
88+
uses: actions/github-script@v7
89+
with:
90+
script: |
91+
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
92+
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
93+
6594
- name: Checkout
6695
uses: actions/checkout@v4
6796

97+
- name: Setup Python
98+
uses: actions/setup-python@v5
99+
with:
100+
python-version: "3.13"
101+
68102
- name: Build
103+
env:
104+
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
69105
run: |
70106
python -m venv .venv
71107
. .venv/bin/activate
72108
pip install --upgrade pip
73-
pip install .
109+
pip install '.[test]' -C override=cmake.args+=\["--toolchain=${VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake"\]
74110
75111
- name: Test
76112
run: |
77113
. .venv/bin/activate
78-
pip install pytest
79114
pytest test

CMakeLists.txt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,19 @@ cmake_minimum_required(VERSION 3.25)
22

33
include(vcpkg/BootstrapVcpkg.cmake)
44

5-
project(velocem LANGUAGES C CXX VERSION 0.0.12)
5+
project(velocem LANGUAGES C CXX VERSION 0.0.13)
66

77
option(VELOCEM_USE_IO_URING "Use io_uring on Linux" ON)
88
option(VELOCEM_USE_IPO "Use interprocedural optimization if supported" ON)
99
option(VELOCEM_STRIP "Run system strip on compiled module" ON)
1010
set(VELOCEM_WIN_SDK_VER 0x0A00 CACHE STRING "Windows SDK macro version")
1111

12-
find_package(absl CONFIG REQUIRED)
1312
find_package(asio CONFIG REQUIRED)
1413
find_package(llhttp CONFIG REQUIRED)
1514
find_package(Python3 3.12 REQUIRED COMPONENTS Development.Module)
1615

1716
Python3_add_library(velocem MODULE)
1817
target_link_libraries(velocem PRIVATE
19-
absl::flat_hash_map
2018
asio::asio
2119
llhttp::llhttp_static
2220
Python3::Module
@@ -82,7 +80,13 @@ endif()
8280

8381
add_subdirectory(src)
8482

83+
if(DEFINED PY_BUILD_CMAKE_VERSION)
84+
set(VELOCEM_PLATLIB ${PY_BUILD_CMAKE_PROJECT_NAME}-${PY_BUILD_CMAKE_PROJECT_VERSION}.data/platlib)
85+
else()
86+
set(VELOCEM_PLATLIB platlib)
87+
endif()
88+
8589
install(
8690
TARGETS velocem
87-
LIBRARY DESTINATION ${PY_BUILD_CMAKE_PACKAGE_NAME}-${PY_BUILD_CMAKE_PACKAGE_VERSION}.data/platlib
91+
LIBRARY DESTINATION ${VELOCEM_PLATLIB}
8892
)

ReadMe.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ more performant techniques as well.
6565
Flask app is 5x slower than the raw WSGI equivalent. A fast router is
6666
essential to a fast, low latency application.
6767

68-
Velocem has a _very basic_ router, but it should still be faster than most
69-
other implementations. There's a lot of work to do, but it's on the order of
70-
1000x faster than Flask.
68+
Velocem currently recommends/uses [`nanoroute`](https://nanoroute.dev/) as
69+
a fast router for WSGI servers. It does not yet provide a faster native
70+
router.
7171

7272
* **Tests**: There are a couple of tests. The current testing strategy is "when
7373
she segfaults, write a test so the same segfault doesn't happen again".

pyproject.toml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,29 @@
11
[project]
22
name = "velocem"
3-
version = "0.0.12"
3+
version = "0.0.13"
44
description = "Hyperspeed Python Web Framework"
55
readme = "ReadMe.md"
6-
requires-python = ">=3.12"
6+
requires-python = ">=3.13"
77
license = { "file" = "UsageLicense" }
88
authors = [{ "name" = "Vito Gamberini", "email" = "[email protected]" }]
99
keywords = ["WSGI"]
1010
classifiers = [
1111
"Development Status :: 2 - Pre-Alpha",
1212
"License :: OSI Approved :: MIT No Attribution License (MIT-0)",
1313
"Programming Language :: Python :: 3",
14-
"Programming Language :: Python :: 3.12",
14+
"Programming Language :: Python :: 3.13",
1515
"Operating System :: POSIX :: Linux",
1616
"Operating System :: Microsoft :: Windows",
1717
"Operating System :: MacOS",
1818
]
1919
urls = { "Documentation" = "https://github.com/nickelpro/velocem" }
2020
dependencies = []
2121

22+
[project.optional-dependencies]
23+
test = ["pytest", "nanoroute"]
24+
2225
[build-system]
23-
requires = ["py-build-cmake~=0.2.0a14"]
26+
requires = ["py-build-cmake~=0.3.4"]
2427
build-backend = "py_build_cmake.build"
2528

2629
[tool.py-build-cmake.module]
@@ -30,7 +33,7 @@ generated = "module"
3033
include = ["CMakeLists.txt", "vcpkg.json", "src", "vcpkg"]
3134

3235
[tool.py-build-cmake.cmake]
33-
minimum_version = "3.17"
36+
minimum_version = "3.25"
3437
config = "Release"
3538
build_type = "Release"
3639
build_args = ["-j"]

src/CMakeLists.txt

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,17 @@ target_sources(velocem PRIVATE
66
BASE_DIRS ${CMAKE_CURRENT_LIST_DIR}
77

88
FILES
9-
HTTPParser.hpp
10-
Router.hpp
9+
HTTPParser.hpp
1110

12-
plat/plat.hpp
11+
plat/plat.hpp
1312

14-
util/Constants.hpp
15-
util/Util.hpp
13+
util/Constants.hpp
14+
util/Util.hpp
1615

17-
wsgi/App.hpp
18-
wsgi/Input.hpp
19-
wsgi/Request.hpp
20-
wsgi/Server.hpp
16+
wsgi/App.hpp
17+
wsgi/Input.hpp
18+
wsgi/Request.hpp
19+
wsgi/Server.hpp
2120
)
2221

2322
add_subdirectory(plat)

src/ModVelocem.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
#define PY_SSIZE_T_CLEAN
21
#include <Python.h>
32

4-
#include "Router.hpp"
53
#include "util/Constants.hpp"
64
#include "wsgi/Server.hpp"
75

@@ -27,7 +25,7 @@ PyMODINIT_FUNC PyInit_velocem(void) {
2725
auto mod {PyModule_Create(&VelocemModule)};
2826
if(!mod)
2927
return nullptr;
30-
if(PyModule_AddStringConstant(mod, "__version__", "0.0.12") == -1)
28+
if(PyModule_AddStringConstant(mod, "__version__", "0.0.13") == -1)
3129
return nullptr;
3230
velocem::init_globals(mod);
3331
return mod;

0 commit comments

Comments
 (0)