@@ -3,66 +3,63 @@ name: Build and upload to PyPI
33on : [push, pull_request]
44
55jobs :
6- build_wheels :
7- name : Build wheels on ${{ matrix.os }}
8- runs-on : ${{ matrix.os }}
9- strategy :
10- matrix :
11- os : [windows-latest]
12- python-version : ['3.10']
13-
6+ build :
7+ name : Build sdist + wheel (pure Python)
8+ runs-on : ubuntu-latest
149 steps :
15- - uses : actions/checkout@v2
16- - name : Set up Python
17- uses : actions/setup-python@v4
18- with :
19- python-version : ${{ matrix.python-version }}
10+ - uses : actions/checkout@v4
2011
21- - name : Run test in develop mode
12+ - name : Set up Python 3.x
13+ uses : actions/setup-python@v5
14+ with :
15+ python-version : ' 3.12'
16+ cache : pip
17+
18+ - name : Run test.py
2219 run : |
23- python -m pip install opencv-python pytest
24- python setup.py develop
25- python --version
26- pytest
20+ python -m pip install opencv-python dynamsoft-capture-vision-bundle
21+ python test_api.py
2722
28- - name : Build wheels for Linux
29- if : matrix.os == 'ubuntu-latest'
23+ - name : Install build tooling
3024 run : |
31- docker run --rm -v $(pwd):/io quay.io/pypa/manylinux_2_24_x86_64 \
32- /bin/bash -c "python3 -m pip install -U setuptools wheel && cd /io && python3 setup.py bdist_wheel -d dist && auditwheel repair dist/*.whl -w /io/wheelhouse"
25+ python -m pip install -U pip build twine
3326
34- - name : Build wheels for Windows
35- if : matrix.os == 'windows-latest'
27+ - name : Build distributions
3628 run : |
37- pip install -U wheel setuptools
38- python setup.py bdist_wheel -d wheelhouse
39-
40- - uses : actions/upload-artifact@v4
41- with :
42- name : wheels-${{ matrix.os }}-python${{ matrix.python-version }}
43- path : wheelhouse/*.whl
29+ python -m build # creates dist/*.whl and dist/*.tar.gz
4430
45- build_sdist :
46- name : Build source distribution
47- runs-on : ubuntu-latest
48- steps :
49- - uses : actions/checkout@v2
31+ - name : Check metadata
32+ run : |
33+ python -m twine check dist/*
5034
51- - name : Build sdist
52- run : python setup.py sdist -d dist
35+ - name : Ensure universal wheel for pure Python
36+ shell : bash
37+ run : |
38+ set -e
39+ WHEEL="$(ls dist/*.whl | head -n1)"
40+ echo "Built wheel: $WHEEL"
41+ # Expect *-py3-none-any.whl for pure-Python universal wheels
42+ if [[ "$WHEEL" != *"-py3-none-any.whl" ]]; then
43+ echo "::warning::Wheel is not tagged 'py3-none-any'. Verify package is pure Python or build config."
44+ fi
5345
54- - uses : actions/upload-artifact@v4
46+ - name : Upload build artifacts
47+ uses : actions/upload-artifact@v4
5548 with :
56- path : dist/*.tar.gz
57-
49+ name : dist
50+ path : dist/*
51+
5852 upload_pypi :
59- needs : [build_wheels, build_sdist]
53+ needs : build
6054 runs-on : ubuntu-latest
55+ # upload to PyPI on every tag starting with 'v'
6156 if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
57+ # alternatively, to publish when a GitHub Release is created, use the following rule:
58+ # if: github.event_name == 'release' && github.event.action == 'published'
6259 steps :
6360 - uses : actions/download-artifact@v4
6461 with :
65- name : artifact
62+ name : dist
6663 path : dist
6764
6865
0 commit comments