bustapi 0.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. bustapi-0.2.2/.github/workflows/ci.yml +106 -0
  2. bustapi-0.2.2/.github/workflows/docs.yml +75 -0
  3. bustapi-0.2.2/.github/workflows/pypi.yml +91 -0
  4. bustapi-0.2.2/.github/workflows/rls.yml +164 -0
  5. bustapi-0.2.2/.gitignore +154 -0
  6. bustapi-0.2.2/CHANGELOG.md +29 -0
  7. bustapi-0.2.2/Cargo.lock +1913 -0
  8. bustapi-0.2.2/Cargo.toml +47 -0
  9. bustapi-0.2.2/LICENSE +21 -0
  10. bustapi-0.2.2/PKG-INFO +320 -0
  11. bustapi-0.2.2/README.md +264 -0
  12. bustapi-0.2.2/benchmarks/README.md +39 -0
  13. bustapi-0.2.2/benchmarks/catzilla_server.py +51 -0
  14. bustapi-0.2.2/benchmarks/comprehensive_benchmark.py +336 -0
  15. bustapi-0.2.2/benchmarks/run_comparison_auto.py +534 -0
  16. bustapi-0.2.2/examples/01_hello_world.py +13 -0
  17. bustapi-0.2.2/examples/02_parameters.py +33 -0
  18. bustapi-0.2.2/examples/03_async.py +22 -0
  19. bustapi-0.2.2/examples/04_request_data.py +25 -0
  20. bustapi-0.2.2/examples/05_templates.py +20 -0
  21. bustapi-0.2.2/examples/06_blueprints.py +47 -0
  22. bustapi-0.2.2/examples/07_database_raw.py +49 -0
  23. bustapi-0.2.2/examples/08_auto_docs.py +48 -0
  24. bustapi-0.2.2/examples/09_complex_routing.py +36 -0
  25. bustapi-0.2.2/examples/templates/index.html +12 -0
  26. bustapi-0.2.2/mkdocs.yml +41 -0
  27. bustapi-0.2.2/pyproject.toml +130 -0
  28. bustapi-0.2.2/python/bustapi/__init__.py +100 -0
  29. bustapi-0.2.2/python/bustapi/app.py +767 -0
  30. bustapi-0.2.2/python/bustapi/blueprints.py +500 -0
  31. bustapi-0.2.2/python/bustapi/docs.py +216 -0
  32. bustapi-0.2.2/python/bustapi/exceptions.py +438 -0
  33. bustapi-0.2.2/python/bustapi/helpers.py +408 -0
  34. bustapi-0.2.2/python/bustapi/logging.py +468 -0
  35. bustapi-0.2.2/python/bustapi/py.typed +0 -0
  36. bustapi-0.2.2/python/bustapi/request.py +433 -0
  37. bustapi-0.2.2/python/bustapi/response.py +471 -0
  38. bustapi-0.2.2/python/bustapi/templating.py +30 -0
  39. bustapi-0.2.2/python/bustapi/testing.py +376 -0
  40. bustapi-0.2.2/src/bindings/app.rs +125 -0
  41. bustapi-0.2.2/src/bindings/converters.rs +130 -0
  42. bustapi-0.2.2/src/bindings/handlers.rs +164 -0
  43. bustapi-0.2.2/src/bindings/mod.rs +7 -0
  44. bustapi-0.2.2/src/bindings/request.rs +102 -0
  45. bustapi-0.2.2/src/lib.rs +45 -0
  46. bustapi-0.2.2/src/request/methods.rs +161 -0
  47. bustapi-0.2.2/src/request/mod.rs +4 -0
  48. bustapi-0.2.2/src/request/tests.rs +53 -0
  49. bustapi-0.2.2/src/response/builders.rs +114 -0
  50. bustapi-0.2.2/src/response/methods.rs +44 -0
  51. bustapi-0.2.2/src/response/mod.rs +4 -0
  52. bustapi-0.2.2/src/router/handlers.rs +136 -0
  53. bustapi-0.2.2/src/router/matching.rs +72 -0
  54. bustapi-0.2.2/src/router/middleware.rs +73 -0
  55. bustapi-0.2.2/src/router/mod.rs +6 -0
  56. bustapi-0.2.2/src/router/tests.rs +9 -0
  57. bustapi-0.2.2/src/server/handlers.rs +125 -0
  58. bustapi-0.2.2/src/server/mod.rs +5 -0
  59. bustapi-0.2.2/src/server/startup.rs +23 -0
  60. bustapi-0.2.2/tests/docs_test_all.py +72 -0
  61. bustapi-0.2.2/tests/docs_test_api_reference.py +327 -0
  62. bustapi-0.2.2/tests/docs_test_installation.py +167 -0
  63. bustapi-0.2.2/tests/docs_test_quickstart.py +409 -0
  64. bustapi-0.2.2/tests/docs_test_simple.py +260 -0
  65. bustapi-0.2.2/tests/test_examples.py +110 -0
  66. bustapi-0.2.2/tests/test_new_examples.py +123 -0
  67. bustapi-0.2.2/tests/verify_router.py +42 -0
  68. bustapi-0.2.2/todo.md +87 -0
@@ -0,0 +1,106 @@
1
+ name: BustAPI CI
2
+
3
+ on:
4
+ workflow_dispatch: {}
5
+
6
+ jobs:
7
+ lint-and-test:
8
+ name: Lint and Test Python ${{ matrix.python-version }}
9
+ runs-on: ubuntu-latest
10
+ env:
11
+ PYO3_USE_ABI3_FORWARD_COMPATIBILITY: 1
12
+ strategy:
13
+ matrix:
14
+ python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
15
+
16
+ steps:
17
+ - name: Checkout code
18
+ uses: actions/checkout@v4
19
+
20
+ - name: Set up uv
21
+ uses: astral-sh/setup-uv@v3
22
+
23
+ - name: Set up Python ${{ matrix.python-version }}
24
+ run: uv python install ${{ matrix.python-version }}
25
+
26
+ - name: Set up Rust
27
+ uses: dtolnay/rust-toolchain@stable
28
+ with:
29
+ components: clippy, rustfmt
30
+
31
+ - name: Create venv
32
+ run: |
33
+ uv venv .venv
34
+ echo "VENV_PY=./.venv/bin/python" >> $GITHUB_ENV
35
+
36
+ - name: Install tools
37
+ run: |
38
+ uv pip install maturin black ruff requests --python $VENV_PY
39
+
40
+ - name: Lint Rust code
41
+ if: matrix.python-version == '3.12'
42
+ run: |
43
+ cargo fmt --check
44
+ cargo clippy --all-targets --all-features -- -D warnings
45
+
46
+ - name: Lint Python code
47
+ if: matrix.python-version == '3.12'
48
+ run: |
49
+ $VENV_PY -m black --check --diff .
50
+ $VENV_PY -m ruff check .
51
+
52
+ - name: Build with maturin
53
+ run: |
54
+ $VENV_PY -m maturin develop --release
55
+ $VENV_PY -c "import bustapi; print(f'BustAPI {bustapi.__version__} installed')"
56
+
57
+ - name: Run basic tests
58
+ run: |
59
+ $VENV_PY -m unittest discover tests
60
+
61
+ build-wheels:
62
+ name: Build wheels on ${{ matrix.os }}
63
+ runs-on: ${{ matrix.os }}
64
+ needs: lint-and-test
65
+ env:
66
+ PYO3_USE_ABI3_FORWARD_COMPATIBILITY: 1
67
+ strategy:
68
+ matrix:
69
+ os: [ubuntu-latest, macos-latest, windows-latest]
70
+
71
+ steps:
72
+ - name: Checkout code
73
+ uses: actions/checkout@v4
74
+
75
+ - name: Set up uv
76
+ uses: astral-sh/setup-uv@v3
77
+
78
+ - name: Set up Python
79
+ run: uv python install 3.11
80
+
81
+ - name: Set up Rust
82
+ uses: dtolnay/rust-toolchain@stable
83
+
84
+ - name: Create venv
85
+ run: uv venv .venv
86
+
87
+ - name: Install maturin
88
+ shell: bash
89
+ run: |
90
+ VENV_PY=./.venv/bin/python
91
+ if [ "$RUNNER_OS" == "Windows" ]; then
92
+ VENV_PY=./.venv/Scripts/python.exe
93
+ fi
94
+ uv pip install maturin --python $VENV_PY
95
+ echo "VENV_PY=$VENV_PY" >> $GITHUB_ENV
96
+
97
+ - name: Build wheels
98
+ shell: bash
99
+ run: |
100
+ $VENV_PY -m maturin build --release --out dist
101
+
102
+ - name: Upload wheels
103
+ uses: actions/upload-artifact@v4
104
+ with:
105
+ name: wheels-${{ matrix.os }}
106
+ path: dist/*.whl
@@ -0,0 +1,75 @@
1
+ name: Deploy Documentation
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ # push:
6
+ # branches: [ main ]
7
+ # paths:
8
+ # - 'docs/**'
9
+ # - 'python/**'
10
+ # - 'src/**'
11
+ # - 'mkdocs.yml'
12
+ # - 'pyproject.toml'
13
+
14
+ permissions:
15
+ contents: read
16
+ pages: write
17
+ id-token: write
18
+
19
+ concurrency:
20
+ group: "pages"
21
+ cancel-in-progress: false
22
+
23
+ jobs:
24
+ build:
25
+ runs-on: ubuntu-latest
26
+ steps:
27
+ - name: Checkout
28
+ uses: actions/checkout@v4
29
+
30
+ - name: Setup Python
31
+ uses: actions/setup-python@v5
32
+ with:
33
+ python-version: "3.13"
34
+
35
+ - name: Setup Rust
36
+ uses: dtolnay/rust-toolchain@stable
37
+
38
+ - name: Setup UV
39
+ uses: astral-sh/setup-uv@v3
40
+
41
+ - name: Install maturin globally
42
+ run: uv pip install --system maturin
43
+
44
+ - name: Create virtual environment
45
+ run: uv venv
46
+
47
+ - name: Install dependencies
48
+ run: |
49
+ uv pip install -e .
50
+ uv pip install mkdocs mkdocs-material mkdocstrings[python]
51
+
52
+ - name: Build Rust extension
53
+ run: uv run maturin develop
54
+
55
+ - name: Setup Pages
56
+ uses: actions/configure-pages@v5
57
+
58
+ - name: Build documentation
59
+ run: uv run mkdocs build --clean
60
+
61
+ - name: Upload artifact
62
+ uses: actions/upload-pages-artifact@v3
63
+ with:
64
+ path: ./site
65
+
66
+ deploy:
67
+ environment:
68
+ name: github-pages
69
+ url: ${{ steps.deployment.outputs.page_url }}
70
+ runs-on: ubuntu-latest
71
+ needs: build
72
+ steps:
73
+ - name: Deploy to GitHub Pages
74
+ id: deployment
75
+ uses: actions/deploy-pages@v4
@@ -0,0 +1,91 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+ workflow_dispatch:
8
+
9
+ jobs:
10
+ build-sdist:
11
+ name: Build source distribution
12
+ runs-on: ubuntu-latest
13
+
14
+ steps:
15
+ - name: Checkout code
16
+ uses: actions/checkout@v4
17
+
18
+ - name: Set up uv
19
+ uses: astral-sh/setup-uv@v3
20
+
21
+ - name: Set up Python
22
+ run: uv python install 3.11
23
+
24
+ - name: Set up Rust
25
+ uses: dtolnay/rust-toolchain@stable
26
+
27
+ - name: Create venv
28
+ run: uv venv .venv
29
+
30
+ - name: Install maturin
31
+ run: uv pip install maturin --python ./.venv/bin/python
32
+
33
+ - name: Build sdist
34
+ run: ./.venv/bin/python -m maturin sdist --out dist
35
+
36
+ - name: Upload sdist artifact
37
+ uses: actions/upload-artifact@v4
38
+ with:
39
+ name: sdist
40
+ path: dist/*.tar.gz
41
+
42
+ publish:
43
+ name: Publish to PyPI
44
+ needs: build-sdist
45
+ runs-on: ubuntu-latest
46
+ environment:
47
+ name: pypi
48
+ url: https://pypi.org/p/bustapi
49
+ permissions:
50
+ contents: read
51
+
52
+ steps:
53
+ - name: Download CI wheels
54
+ uses: actions/download-artifact@v4
55
+ with:
56
+ workflow: ci.yml
57
+ path: dist
58
+
59
+ - name: Download sdist
60
+ uses: actions/download-artifact@v4
61
+ with:
62
+ name: sdist
63
+ path: dist
64
+
65
+ - name: Flatten downloaded artifacts
66
+ run: |
67
+ echo "Flattening artifacts into dist/"
68
+ find dist -mindepth 2 -type f -exec mv -t dist {} + || true
69
+ find dist -type d -empty -delete || true
70
+
71
+ - name: Display collected files
72
+ run: |
73
+ echo "Collected files:"
74
+ find dist -type f -print
75
+
76
+ - name: Publish package to PyPI
77
+ uses: pypa/gh-action-pypi-publish@release/v1
78
+ with:
79
+ user: __token__
80
+ password: ${{ secrets.PYPI_API_TOKEN }}
81
+ packages-dir: dist
82
+ skip-existing: true
83
+
84
+ - name: Verify dist contents
85
+ run: |
86
+ echo "Checking dist/ files before publish"
87
+ if [ -z "$(ls -A dist 2>/dev/null)" ]; then
88
+ echo "No files in dist/ to publish - aborting"
89
+ ls -la dist || true
90
+ exit 1
91
+ fi
@@ -0,0 +1,164 @@
1
+ name: Release
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ inputs:
6
+ tag:
7
+ description: "Release tag (e.g. v0.1.0)"
8
+ required: true
9
+ default: "v0.1.0"
10
+
11
+ jobs:
12
+ build:
13
+ name: Build with Maturin
14
+ runs-on: ${{ matrix.os }}
15
+ strategy:
16
+ fail-fast: false
17
+ matrix:
18
+ os: [ubuntu-latest, windows-latest, macos-latest]
19
+ python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
20
+
21
+ steps:
22
+ - uses: actions/checkout@v4
23
+
24
+ # Ensure Python is installed
25
+ - name: Set up Python
26
+ uses: actions/setup-python@v5
27
+ with:
28
+ python-version: ${{ matrix.python-version }}
29
+
30
+ # Ensure Rust is installed
31
+ - name: Install Rust
32
+ run: |
33
+ if ! command -v rustc &> /dev/null
34
+ then
35
+ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
36
+ source $HOME/.cargo/env
37
+ fi
38
+ rustc --version
39
+ cargo --version
40
+
41
+ # Cache cargo dependencies
42
+ - name: Cache cargo
43
+ uses: actions/cache@v3
44
+ with:
45
+ path: |
46
+ ~/.cargo/registry
47
+ ~/.cargo/git
48
+ target
49
+ key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
50
+
51
+ # Install Maturin into a venv and build wheel using the selected interpreter
52
+ - name: Create venv and install maturin (Unix)
53
+ if: runner.os != 'Windows'
54
+ run: |
55
+ python -m venv .venv
56
+ VENV_PY=./.venv/bin/python
57
+ $VENV_PY -m pip install --upgrade pip
58
+ $VENV_PY -m pip install maturin
59
+ echo "VENV_PY=$VENV_PY" >> $GITHUB_ENV
60
+
61
+ - name: Create venv and install maturin (Windows)
62
+ if: runner.os == 'Windows'
63
+ shell: pwsh
64
+ run: |
65
+ python -m venv .venv
66
+ $VENV = '.\\.venv\\Scripts\\python.exe'
67
+ & $VENV -m pip install --upgrade pip
68
+ & $VENV -m pip install maturin
69
+ Write-Output "VENV_PY=$VENV" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
70
+
71
+ # Build wheel (Unix)
72
+ - name: Build wheel
73
+ if: runner.os != 'Windows'
74
+ run: |
75
+ $VENV_PY -m maturin build --release --out dist
76
+
77
+ - name: Build wheel (Windows)
78
+ if: runner.os == 'Windows'
79
+ shell: pwsh
80
+ run: |
81
+ $VENV = $env:VENV_PY
82
+ & $VENV -m maturin build --release --out dist
83
+
84
+ # Upload artifact
85
+ - name: Upload artifact
86
+ uses: actions/upload-artifact@v4
87
+ with:
88
+ name: wheel-${{ matrix.os }}-${{ matrix.python-version }}
89
+ path: dist/*
90
+
91
+ android:
92
+ name: Android build (maturin)
93
+ runs-on: ubuntu-latest
94
+ steps:
95
+ - uses: actions/checkout@v4
96
+
97
+ # Ensure Python
98
+ - name: Set up Python
99
+ uses: actions/setup-python@v5
100
+ with:
101
+ python-version: "3.11"
102
+
103
+ # Ensure Rust
104
+ - name: Install Rust
105
+ run: |
106
+ if ! command -v rustc &> /dev/null
107
+ then
108
+ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
109
+ source $HOME/.cargo/env
110
+ fi
111
+ rustc --version
112
+ cargo --version
113
+
114
+ # Install Maturin into a venv
115
+ - name: Create venv and install maturin (Android)
116
+ run: |
117
+ python -m venv .venv
118
+ VENV_PY=./.venv/bin/python
119
+ $VENV_PY -m pip install --upgrade pip
120
+ $VENV_PY -m pip install maturin
121
+ echo "VENV_PY=$VENV_PY" >> $GITHUB_ENV
122
+
123
+ # Install Android NDK
124
+ - name: Install Android NDK
125
+ run: |
126
+ sudo apt-get update
127
+ sudo apt-get install -y unzip wget
128
+ wget https://dl.google.com/android/repository/android-ndk-r26d-linux.zip
129
+ unzip -q android-ndk-r26d-linux.zip -d $HOME
130
+ echo "ANDROID_NDK_HOME=$HOME/android-ndk-r26d" >> $GITHUB_ENV
131
+ echo "$HOME/android-ndk-r26d/toolchains/llvm/prebuilt/linux-x86_64/bin" >> $GITHUB_PATH
132
+
133
+ # Build Android wheel
134
+ - name: Build Android (aarch64)
135
+ run: |
136
+ $VENV_PY -m maturin build --release --target aarch64-linux-android --out dist
137
+
138
+ # Upload artifact
139
+ - name: Upload artifact
140
+ uses: actions/upload-artifact@v4
141
+ with:
142
+ name: wheel-android
143
+ path: dist/*
144
+
145
+ release:
146
+ name: Publish Release
147
+ needs: [build, android]
148
+ runs-on: ubuntu-latest
149
+ steps:
150
+ - name: Download all artifacts
151
+ uses: actions/download-artifact@v4
152
+ with:
153
+ path: dist
154
+
155
+ - name: Publish GitHub Release
156
+ uses: softprops/action-gh-release@v2
157
+ with:
158
+ tag_name: ${{ github.event.inputs.tag }}
159
+ name: "BustAPI Release ${{ github.event.inputs.tag }}"
160
+ draft: false
161
+ prerelease: false
162
+ files: dist/**/*
163
+ env:
164
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,154 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ build/
8
+ develop-eggs/
9
+ dist/
10
+ downloads/
11
+ eggs/
12
+ .eggs/
13
+ lib/
14
+ lib64/
15
+ parts/
16
+ sdist/
17
+ var/
18
+ wheels/
19
+ *.egg-info/
20
+ .installed.cfg
21
+ *.egg
22
+ MANIFEST
23
+ .venv*
24
+ # PyInstaller
25
+ *.manifest
26
+ *.spec
27
+
28
+ # Installer logs
29
+ pip-log.txt
30
+ pip-delete-this-directory.txt
31
+ # Unit test / coverage reports
32
+ htmlcov/
33
+ .tox/
34
+ .nox/
35
+ .coverage
36
+ .coverage.*
37
+ .cache
38
+ nosetests.xml
39
+ coverage.xml
40
+ *.cover
41
+ .hypothesis/
42
+ .pytest_cache/
43
+
44
+ # Translations
45
+ *.mo
46
+ *.pot
47
+
48
+ # Django stuff
49
+ *.log
50
+ local_settings.py
51
+ db.sqlite3
52
+
53
+ # Flask stuff
54
+ instance/
55
+ .webassets-cache
56
+
57
+ # Scrapy stuff
58
+ .scrapy
59
+
60
+ # Sphinx documentation
61
+ docs/_build/
62
+
63
+ # PyBuilder
64
+ target/
65
+
66
+ # Jupyter Notebook
67
+ .ipynb_checkpoints
68
+
69
+ # IPython
70
+ profile_default/
71
+ ipython_config.py
72
+
73
+ # pyenv
74
+ .python-version
75
+
76
+ # celery beat schedule file
77
+ celerybeat-schedule
78
+
79
+ # SageMath parsed files
80
+ *.sage.py
81
+
82
+ # Environments
83
+ .env
84
+ .venv
85
+ env/
86
+ venv/
87
+ ENV/
88
+ env.bak/
89
+ venv.bak/
90
+
91
+ # Spyder project settings
92
+ .spyderproject
93
+ .spyproject
94
+
95
+ # Rope project settings
96
+ .ropeproject
97
+
98
+ # mkdocs documentation
99
+ /site
100
+
101
+ # mypy
102
+ .mypy_cache/
103
+ .dmypy.json
104
+ dmypy.json
105
+
106
+ # Pyre type checker
107
+ .pyre/
108
+
109
+ # Rust
110
+ target/
111
+ Cargo.lock
112
+ **/*.rs.bk
113
+
114
+ # IDE
115
+ .vscode/
116
+ .idea/
117
+ *.swp
118
+ *.swo
119
+ *~
120
+
121
+ # OS
122
+ .DS_Store
123
+ .DS_Store?
124
+ ._*
125
+ .Spotlight-V100
126
+ .Trashes
127
+ ehthumbs.db
128
+ Thumbs.db
129
+
130
+ # Maturin
131
+ *.whl
132
+
133
+ # Temp files
134
+ *.tmp
135
+ *.temp
136
+
137
+ # UV
138
+ .uv/
139
+ uv.lock
140
+
141
+ ex.yml
142
+ ex.toml
143
+ ex.py.toml
144
+
145
+ .zen*
146
+ .mypy_*
147
+ .ruff_*
148
+ wheel/
149
+ venv/
150
+
151
+ # Benchmarks
152
+ benchmarks/temp_*.py
153
+ stdout_*.txt
154
+ stderr_*.txt
@@ -0,0 +1,29 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented here.
4
+
5
+ ## [0.2.0] - 2024-12-05
6
+
7
+ ### Changed
8
+
9
+ - **BREAKING**: Migrated from Hyper to Actix-web for 50x+ performance improvement
10
+ - Updated PyO3 from 0.20 to 0.23 with free-threading support
11
+ - Added `gil_used = false` annotation for Python 3.13 free-threaded mode
12
+ - Removed `spawn_blocking` - direct Python handler calls for parallel execution
13
+ - Server now uses Actix-web's built-in worker pool (auto-scales to CPU cores)
14
+
15
+ ### Added
16
+
17
+ - Python 3.13 free-threaded mode support (no GIL bottleneck!)
18
+ - Expected 30k-100k+ RPS with dynamic Python handlers
19
+
20
+ ## [0.1.5]
21
+
22
+ - Added Jinja2 templating helper and `render_template` API
23
+ - Added minimal OpenAPI JSON generator and `/openapi.json` endpoint
24
+ - CI: Make workflows platform-aware for virtualenv and maturin invocations
25
+ - CI: Flatten downloaded artifacts before PyPI publish
26
+
27
+ ## [0.1.0]
28
+
29
+ - Initial release