Skip to content

Commit fd18610

Browse files
committed
47 | Update publish workflow to include .whl
1 parent 281ac4c commit fd18610

File tree

2 files changed

+100
-18
lines changed

2 files changed

+100
-18
lines changed
Lines changed: 87 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,66 @@
11
name: Publish to PyPI
22

3-
on:
4-
release:
5-
types: [published]
3+
on: [push]
4+
# release:
5+
# types: [published]
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
9+
#cancel-in-progress: true
610

711
jobs:
8-
publish:
12+
13+
build-whl:
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
matrix:
17+
os: [ ubuntu-latest, windows-latest, macos-latest ]
18+
python: [ "3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14" ]
19+
exclude:
20+
- os: windows-latest
21+
python: "3.14"
22+
- os: macos-latest
23+
python: "3.7"
24+
- os: ubuntu-latest
25+
python: "3.7"
26+
27+
steps:
28+
- uses: actions/checkout@v4
29+
30+
- name: Install Python 3.14 with pyenv (if needed)
31+
if: ${{ matrix.python == '3.14' }}
32+
run: |
33+
curl https://pyenv.run | bash
34+
export PATH="$HOME/.pyenv/bin:$PATH"
35+
eval "$(pyenv init --path)"
36+
eval "$(pyenv init -)"
37+
pyenv install 3.14-dev
38+
pyenv global 3.14-dev
39+
40+
- name: Setup Python
41+
if: ${{ matrix.python != '3.14' }}
42+
uses: actions/setup-python@v5
43+
with:
44+
python-version: ${{ matrix.python }}
45+
46+
- name: Install build tools
47+
run: pip install build twine wheel
48+
49+
- name: Build wheel
50+
run: python -m build --wheel
51+
52+
- name: Upload built packages
53+
uses: actions/upload-artifact@v4
54+
with:
55+
name: pkg-${{ matrix.os }}-${{ matrix.python }}-${{ strategy.job-index }}
56+
path: |
57+
./dist/*.whl
58+
59+
build-sdist:
960
runs-on: ubuntu-latest
1061

1162
steps:
12-
- name: Checkout code
13-
uses: actions/checkout@v4
63+
- uses: actions/checkout@v4
1464

1565
- uses: actions/setup-python@v5
1666
with:
@@ -19,11 +69,35 @@ jobs:
1969
- name: Install build tools
2070
run: pip install build twine wheel
2171

22-
- name: Build package
23-
run: python -m build
72+
- name: Build source distribution
73+
run: python -m build --sdist
74+
75+
- name: Upload built packages
76+
uses: actions/upload-artifact@v4
77+
with:
78+
name: pkg-sdist
79+
path: |
80+
./dist/*.tar.gz
81+
82+
publish:
83+
needs: [build-whl, build-sdist]
84+
runs-on: ubuntu-latest
85+
86+
environment:
87+
name: release
88+
url: https://pypi.org/project/flask-inputfilter
89+
90+
permissions:
91+
id-token: write
92+
93+
steps:
94+
- name: Download built packages
95+
uses: actions/download-artifact@v4
96+
with:
97+
path: dist
98+
merge-multiple: true
2499

25-
- name: Publish to PyPI
26-
env:
27-
TWINE_USERNAME: __token__
28-
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
29-
run: twine upload dist/*.tar.gz
100+
- name: Publish package to PyPI
101+
#uses: pypa/gh-action-pypi-publish@release/v1
102+
run: |
103+
ls -la dist

setup.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,21 @@
44

55
if shutil.which("g++") is not None:
66
from Cython.Build import cythonize
7+
from setuptools.extension import Extension
8+
9+
pyx_modules = [
10+
"flask_inputfilter.Mixin._ExternalApiMixin",
11+
"flask_inputfilter.Model._FieldModel",
12+
"flask_inputfilter._InputFilter",
13+
]
714

815
ext_modules = cythonize(
9-
[
10-
"flask_inputfilter/Mixin/_ExternalApiMixin.pyx",
11-
"flask_inputfilter/Model/_FieldModel.pyx",
12-
"flask_inputfilter/_InputFilter.pyx",
13-
],
16+
module_list=[Extension(
17+
name=module,
18+
sources=[module.replace('.', '/') + ".pyx"],
19+
extra_compile_args=["-std=c++11"],
20+
language="c++"
21+
) for module in pyx_modules],
1422
language_level=3,
1523
)
1624
options = {

0 commit comments

Comments
 (0)