Skip to content

Commit eadb584

Browse files
committed
Merge pull request #44 from LeanderCS/31
Finalize version 0.4.0 and update docs
2 parents f4dbd0a + 9a30488 commit eadb584

File tree

13 files changed

+146
-22
lines changed

13 files changed

+146
-22
lines changed

.github/workflows/deploy-docs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
python-version: '3.x'
2424

2525
- name: Install Dependencies
26-
run: pip install sphinx sphinx_rtd_theme
26+
run: pip install sphinx sphinx_rtd_theme sphinx_design
2727

2828
- name: Build Documentation
2929
run: sphinx-build -b html docs/source/ _build

.github/workflows/test-lib-building.yaml

Lines changed: 49 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
name: Build and Test Library
22

3-
on:
4-
push:
5-
branches:
6-
- main
7-
pull_request:
3+
on: [push]
84

95
jobs:
106
build-and-test-pure:
@@ -28,16 +24,29 @@ jobs:
2824
id: build
2925

3026
- name: Install built library
31-
run: pip install "$(ls dist/*.tar.gz | head -n 1)[optional]"
27+
run: |
28+
pip install "$(ls dist/*.tar.gz | head -n 1)[optional]"
29+
rm -rf flask_inputfilter
3230
33-
- name: Verify library usage - Part I
31+
- name: Verify library usage - Part I - installation
3432
run: |
3533
python -c "import flask_inputfilter.InputFilter"
3634
python -c "from flask_inputfilter import InputFilter"
3735
38-
- name: Verify library usage - Part II
36+
- name: Verify library usage - Part II - functional test
3937
run: pytest tests/
4038

39+
- name: Verify library usage - Part III - correct version
40+
run: |
41+
output=$(python -c "from flask_inputfilter import InputFilter; print(InputFilter)")
42+
43+
if [ "$output" = "<class 'flask_inputfilter.InputFilter.InputFilter'>" ]; then
44+
echo "Test passed: Correct class returned"
45+
else
46+
echo "Test failed: Unexpected output - $output"
47+
exit 1
48+
fi
49+
4150
build-and-test-cython:
4251
runs-on: ubuntu-latest
4352

@@ -59,12 +68,40 @@ jobs:
5968
id: build
6069

6170
- name: Install built library
62-
run: pip install "$(ls dist/*.tar.gz | head -n 1)[optional]"
71+
run: |
72+
pip install "$(ls dist/*.tar.gz | head -n 1)[optional]"
73+
rm -rf flask_inputfilter
6374
64-
- name: Verify library usage - Part I
75+
- name: Verify library usage - Part I - installation
6576
run: |
6677
python -c "import flask_inputfilter.InputFilter"
6778
python -c "from flask_inputfilter import InputFilter"
6879
69-
#- name: Verify library usage - Part II
70-
# run: pytest tests/
80+
- name: Verify library usage - Part II - functional test
81+
run: pytest tests/
82+
83+
- name: Verify library usage - Part III - correct version
84+
run: |
85+
output=$(python -c "from flask_inputfilter import InputFilter; print(InputFilter)")
86+
87+
if [ "$output" = "<class 'flask_inputfilter._InputFilter.InputFilter'>" ]; then
88+
echo "Test passed: Correct class returned"
89+
else
90+
echo "Test failed: Unexpected output - $output"
91+
exit 1
92+
fi
93+
94+
# Creates and uses compiled file instead of pyximport
95+
96+
module_path=$(python -c "import flask_inputfilter; print(flask_inputfilter.__file__)")
97+
98+
module_dir=$(dirname "$module_path")
99+
100+
so_files=$(find "$module_dir" -maxdepth 1 -name "*.so")
101+
102+
if [ -n "$so_files" ]; then
103+
echo ".so-files found:"
104+
echo "$so_files"
105+
else
106+
echo "No .so-files found."
107+
fi

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ include LICENSE
33
include docs/source/changelog.rst
44
recursive-include flask_inputfilter *.py *.pyx *.c *.cpp
55
prune tests
6+
recursive-prune __pycache__

README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ Definition
6767
6868
class UpdateZipcodeInputFilter(InputFilter):
6969
def __init__(self):
70+
super().__init__()
7071
7172
self.add(
7273
'id',

docs/source/changelog.rst

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

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

6+
[0.4.0] - 2025-04-20
7+
--------------------
8+
9+
Added
10+
^^^^^
11+
- Added possibility to use ``cython`` for performance improvements.
12+
View :doc:`the guide <guides/compile>` for more information.
13+
14+
615
[0.4.0a2] - 2025-04-17
716
----------------------
817

docs/source/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
project = "flask-inputfilter"
22
copyright = "2025, Leander Cain Slotosch"
33
author = "Leander Cain Slotosch"
4-
release = "0.4.0a2"
4+
release = "0.4.0"
55

6-
extensions = ["sphinx_rtd_theme"]
6+
extensions = ["sphinx_rtd_theme", "sphinx_design"]
77

88
templates_path = []
99
exclude_patterns = []

docs/source/guides/compile.rst

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
Use compiled version
2+
====================
3+
4+
By default the pure python version of the lib is used as a fallback.
5+
Using the compiled version is not mandatory but highly advised and
6+
will give you a performance boost.
7+
8+
Getting started
9+
---------------
10+
11+
To use the compiled version you will first need the cython module,
12+
you can install the corresponding version by also installing the
13+
``[compile]`` dependencies of the library.
14+
15+
.. code-block:: bash
16+
17+
pip install flask-inputfilter[compile]
18+
19+
Secondly, you will need the c++ compiler.
20+
21+
Normally this is already installed on your system, but if not,
22+
depending on your os, you can use:
23+
24+
.. grid:: 1
25+
:gutter: 2
26+
27+
.. grid-item::
28+
.. card:: Linux
29+
30+
Install the gcc compiler using apt.
31+
32+
.. code-block:: bash
33+
34+
sudo apt install g++
35+
36+
.. grid-item::
37+
.. card:: MacOS
38+
39+
Either install the Xcode command line tools or use homebrew:
40+
41+
.. code-block:: bash
42+
43+
xcode-select --install g++
44+
45+
.. code-block:: bash
46+
47+
brew install g++
48+
49+
.. grid-item::
50+
.. card:: Windows
51+
52+
1. Download MinGW:
53+
https://www.mingw-w64.org
54+
2. Install and add ``g++.exe`` to PATH.
55+
56+
If you have the c++ compiler installed and reinstall the library,
57+
with or without the ``[compile]`` flag, depending if you already installed it,
58+
it will automatically compile the files, that offer an optimized version.
59+
60+
After these steps you can use the library normally and should not get the warning in the console.
61+
62+
Verify Installation
63+
-------------------
64+
65+
If you followed the steps above, you should not see the warning message in the console.
66+
67+
Additionally, you can verify if the compiled versions are
68+
being used by running the following commands:
69+
70+
.. code-block:: bash
71+
72+
python -c "import flask_inputfilter"
73+
python -c "InputFilter"
74+
75+
If the result is ``<class 'flask_inputfilter._InputFilter.InputFilter'>``,
76+
the compiled version is being used.

docs/source/guides/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ Guides
77

88
create_own_components
99
frontend_validation
10+
compile

docs/source/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Available functions:
3333

3434
.. note::
3535

36-
If you like the project, please consider giving it a star on GitHub.
36+
If you like the project, please consider giving it a star on `GitHub <https://github.com/LeanderCS/flask-inputfilter>`_.
3737

3838
Installation
3939
------------

env_configs/cython.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM python:3.7-slim
22

33
WORKDIR /app
44

5-
RUN apt-get update && apt-get install -y g++ python3-dev git
5+
RUN apt-get update && apt-get install -y g++ git
66

77
COPY pyproject.toml /app
88

0 commit comments

Comments
 (0)