Skip to content

Commit 6823dc2

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

File tree

2 files changed

+114
-18
lines changed

2 files changed

+114
-18
lines changed
Lines changed: 101 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,80 @@
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: macos-latest
21+
python: "3.9"
22+
- os: macos-latest
23+
python: "3.8"
24+
- os: macos-latest
25+
python: "3.7"
26+
- os: ubuntu-latest
27+
python: "3.7"
28+
29+
steps:
30+
- uses: actions/checkout@v4
31+
32+
#- uses: actions/setup-python@v5
33+
# with:
34+
# python-version: ${{ matrix.python }}
35+
36+
- name: Install Python 3.14 with pyenv (if needed)
37+
if: ${{ matrix.python == '3.14' }}
38+
run: |
39+
echo "Installing Python 3.14 using pyenv"
40+
curl https://pyenv.run | bash
41+
if [[ "$OSTYPE" == "linux-gnu"* || "$OSTYPE" == "darwin"* ]]; then
42+
export PATH="$HOME/.pyenv/bin:$PATH"
43+
eval "$(pyenv init --path)"
44+
eval "$(pyenv init -)"
45+
elif ($env:OSTYPE -eq "msys") {
46+
$env:PYENV_ROOT="$HOME/.pyenv"
47+
$env:PATH="$env:PYENV_ROOT/bin;$env:PATH"
48+
pyenv init --path | Invoke-Expression
49+
pyenv init - | Invoke-Expression
50+
}
51+
pyenv install 3.14-dev
52+
pyenv global 3.14-dev
53+
54+
- name: Setup Python
55+
if: ${{ matrix.python != '3.14' }}
56+
uses: actions/setup-python@v5
57+
with:
58+
python-version: ${{ matrix.python }}
59+
60+
- name: Install build tools
61+
run: pip install build twine wheel
62+
63+
- name: Build wheel
64+
run: python -m build --wheel
65+
66+
- name: Upload built packages
67+
uses: actions/upload-artifact@v4
68+
with:
69+
name: pkg-${{ matrix.os }}-${{ matrix.python }}-${{ strategy.job-index }}
70+
path: |
71+
./dist/*.whl
72+
73+
build-sdist:
974
runs-on: ubuntu-latest
1075

1176
steps:
12-
- name: Checkout code
13-
uses: actions/checkout@v4
77+
- uses: actions/checkout@v4
1478

1579
- uses: actions/setup-python@v5
1680
with:
@@ -19,11 +83,35 @@ jobs:
1983
- name: Install build tools
2084
run: pip install build twine wheel
2185

22-
- name: Build package
23-
run: python -m build
86+
- name: Build source distribution
87+
run: python -m build --sdist
88+
89+
- name: Upload built packages
90+
uses: actions/upload-artifact@v4
91+
with:
92+
name: pkg-sdist
93+
path: |
94+
./dist/*.tar.gz
95+
96+
publish:
97+
needs: [build-whl, build-sdist]
98+
runs-on: ubuntu-latest
99+
100+
environment:
101+
name: release
102+
url: https://pypi.org/project/flask-inputfilter
103+
104+
permissions:
105+
id-token: write
106+
107+
steps:
108+
- name: Download built packages
109+
uses: actions/download-artifact@v4
110+
with:
111+
path: dist
112+
merge-multiple: true
24113

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
114+
- name: Publish package to PyPI
115+
#uses: pypa/gh-action-pypi-publish@release/v1
116+
run: |
117+
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)