Skip to content

Commit d7338af

Browse files
authored
Merge pull request #33 from LeanderCS/31
31 | Use compiled version of InputFilter class in lib to increase speed
2 parents 1f2dbda + ce24a58 commit d7338af

30 files changed

+208
-90
lines changed

.github/workflows/publish-to-pypi.yaml

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ on:
55
types: [published]
66

77
jobs:
8-
publish:
9-
runs-on: ubuntu-latest
8+
build:
9+
runs-on: ${{ matrix.os }}
10+
strategy:
11+
matrix:
12+
os: [ubuntu-latest, windows-latest, macos-latest]
1013

1114
steps:
1215
- name: Checkout code
@@ -15,13 +18,42 @@ jobs:
1518
- name: Set up Python
1619
uses: actions/setup-python@v4
1720
with:
18-
python-version: 3.9
21+
python-version: 3.11
1922

2023
- name: Install build tools
21-
run: pip install build twine wheel
24+
run: pip install build twine wheel cibuildwheel
25+
26+
- name: Build wheel with cibuildwheel
27+
env:
28+
CIBW_BUILD: cp37-*,cp38-*,cp39-*,cp310-*,cp311-*,cp312-*,cp313-*,cp314-*
29+
run: cibuildwheel --output-dir wheelhouse
30+
31+
- name: Upload wheels
32+
uses: actions/upload-artifact@v3
33+
with:
34+
name: wheels-${{ matrix.os }}
35+
path: wheelhouse/
36+
37+
publish:
38+
needs: build
39+
runs-on: ubuntu-latest
40+
41+
steps:
42+
- name: Download wheels
43+
uses: actions/download-artifact@v3
44+
with:
45+
name: wheels-ubuntu-latest
46+
- name: Download wheels
47+
uses: actions/download-artifact@v3
48+
with:
49+
name: wheels-windows-latest
50+
- name: Download wheels
51+
uses: actions/download-artifact@v3
52+
with:
53+
name: wheels-macos-latest
2254

23-
- name: Build package
24-
run: python setup.py sdist bdist_wheel
55+
- name: Combine wheels
56+
run: mkdir dist && mv wheelhouse/* dist/
2557

2658
- name: Publish to PyPI
2759
env:
Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build and Test Library
1+
name: Run Tests on all environments
22

33
on:
44
push:
@@ -8,7 +8,10 @@ on:
88

99
jobs:
1010
build-and-test:
11-
runs-on: ubuntu-latest
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
matrix:
14+
os: [ubuntu-latest, windows-latest, macos-latest]
1215

1316
steps:
1417
- name: Checkout code
@@ -17,26 +20,28 @@ jobs:
1720
- name: Set up Python
1821
uses: actions/setup-python@v4
1922
with:
20-
python-version: 3.9
23+
python-version: 3.11
2124

2225
- name: Install build tools and test dependencies
23-
run: |
24-
pip install build pytest
26+
run: pip install build pytest cython cibuildwheel
2527

26-
- name: Build the library
27-
run: |
28-
python -m build
29-
id: build
28+
- name: Build wheel with cibuildwheel
29+
env:
30+
CIBW_BUILD: cp311-*
31+
run: cibuildwheel --output-dir wheelhouse
3032

3133
- name: Install built library
32-
run: |
33-
pip install dist/*.whl
34+
run: pip install flask_inputfilter --find-links=wheelhouse/ --force-reinstall
3435

3536
- name: Verify library usage - Part I
3637
run: |
37-
echo "import flask_inputfilter" > test_script.py
38+
python -c "import shutil; shutil.rmtree('flask_inputfilter', ignore_errors=True)"
39+
40+
echo "import flask_inputfilter.InputFilter" > test_script.py
3841
python test_script.py
3942
4043
- name: Verify library usage - Part II
4144
run: |
42-
PYTHONPATH="" pytest test/
45+
python -c "import shutil; shutil.rmtree('flask_inputfilter', ignore_errors=True)"
46+
47+
pytest test/
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
build:
9+
runs-on: ${{ matrix.os }}
10+
strategy:
11+
matrix:
12+
os: [ubuntu-latest, windows-latest, macos-latest]
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v3
17+
18+
- name: Set up Python
19+
uses: actions/setup-python@v4
20+
with:
21+
python-version: 3.11
22+
23+
- name: Install build tools
24+
run: pip install build twine wheel cibuildwheel
25+
26+
- name: Build wheel with cibuildwheel
27+
env:
28+
CIBW_BUILD: cp37-*,cp38-*,cp39-*,cp310-*,cp311-*,cp312-*,cp313-*,cp314-*
29+
run: cibuildwheel --output-dir wheelhouse
30+
31+
- name: Upload wheels
32+
uses: actions/upload-artifact@v3
33+
with:
34+
name: wheels-${{ matrix.os }}
35+
path: wheelhouse/
36+
37+
publish:
38+
needs: build
39+
runs-on: ubuntu-latest
40+
41+
steps:
42+
- name: Download wheels
43+
uses: actions/download-artifact@v3
44+
with:
45+
name: wheels-ubuntu-latest
46+
- name: Download wheels
47+
uses: actions/download-artifact@v3
48+
with:
49+
name: wheels-windows-latest
50+
- name: Download wheels
51+
uses: actions/download-artifact@v3
52+
with:
53+
name: wheels-macos-latest
54+
55+
- name: Combine wheels
56+
run: mkdir dist && mv wheelhouse/* dist/
57+
58+
- name: Publish to PyPI
59+
run: ls -la dist

.github/workflows/test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Run Tests
1+
name: Run Tests and Lint
22

33
on: [push]
44

.github/workflows/test_env.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Run Tests on all environments
1+
name: Run Tests on all python versions
22

33
on: [push]
44

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,5 @@ cython_debug/
158158
.vscode/
159159
.DS_Store
160160
_build
161+
162+
*.c

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ COPY . /app
1414

1515
COPY scripts /usr/local/bin
1616
RUN find /usr/local/bin -type f -name "*" -exec chmod +x {} \;
17+
18+
ENV flask_inputfilter_dev=true

MANIFEST.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
include README.rst
22
include LICENSE
33
include docs/changelog.rst
4+
include flask_inputfilter/*.py
5+
include flask_inputfilter/*.pyx
6+
include flask_inputfilter/*.pxd
7+
include flask_inputfilter/*.so
8+
9+
exclude test/*

Makefile

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
1-
# Minimal makefile for Sphinx documentation
2-
#
3-
4-
# You can set these variables from the command line, and also
5-
# from the environment for the first two.
61
SPHINXOPTS ?=
72
SPHINXBUILD ?= sphinx-build
83
SOURCEDIR = source
94
BUILDDIR = build
105

11-
# Put it first so that "make" without argument is like "make help".
126
help:
137
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
148

159
.PHONY: help Makefile
1610

17-
# Catch-all target: route all unknown targets to Sphinx using the new
18-
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
1911
%: Makefile
2012
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/changelog.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ Changelog
33

44
All notable changes to this project will be documented in this file.
55

6+
[0.2.0] - 2025-03-26
7+
--------------------
8+
9+
Changed
10+
^^^^^^^
11+
- Uses compiled version of InputFilter class to increase speed drastically.
12+
13+
614
[0.1.0] - 2025-03-26
715
--------------------
816

0 commit comments

Comments
 (0)