|
| 1 | +!yamlscript/v0 |
| 2 | + |
| 3 | +python-preamble-job =:: |
| 4 | + runs-on: ${{matrix.config.os}} |
| 5 | + strategy: |
| 6 | + fail-fast: false |
| 7 | + matrix: |
| 8 | + config: |
| 9 | + - {pythonv: '3.13', os: ubuntu-latest} |
| 10 | + - {pythonv: '3.13', os: macos-latest} |
| 11 | + - {pythonv: '3.13', os: windows-latest} |
| 12 | + |
| 13 | + |
| 14 | +python-preamble-steps =:: |
| 15 | + - name: install python ${{matrix.config.pythonv}} |
| 16 | + uses: actions/setup-python@v5 |
| 17 | + with: |
| 18 | + python-version: ${{matrix.config.pythonv}} |
| 19 | + - name: deps |
| 20 | + run: | |
| 21 | + if [[ "${{matrix.config.os}}" == macos* ]] ; then |
| 22 | + brew install swig |
| 23 | + elif [[ "${{matrix.config.os}}" == windows* ]] ; then |
| 24 | + choco install swig |
| 25 | + fi |
| 26 | + pip install build deprecation pytest |
| 27 | + pip install -r requirements.txt |
| 28 | + |
| 29 | + |
| 30 | +defn python-wheel-steps(name create-wheel-cmd):: |
| 31 | + - name:: "------------------- $name" |
| 32 | + run: rm -rf build/ dist/ |
| 33 | + - name:: "create wheel with $create-wheel-cmd" |
| 34 | + run:: | |
| 35 | + $create-wheel-cmd |
| 36 | + - name: install wheel |
| 37 | + run: pip install dist/*.whl |
| 38 | + - name: test with pytest |
| 39 | + run: python -m pytest -vvv api/python/tests |
| 40 | + |
| 41 | +--- |
| 42 | +!yamlscript/v0: |
| 43 | + |
| 44 | +:use common: :all |
| 45 | +:: workflow-setup() |
| 46 | + |
| 47 | +jobs: |
| 48 | + |
| 49 | + # verify that we can explicitly run the python API |
| 50 | + # without creating or installing a wheel |
| 51 | + pybare: |
| 52 | + :: setup-job('api' 'pybare') |
| 53 | + name: pybare/${{matrix.config.pythonv}}/${{matrix.config.os}} |
| 54 | + :: python-preamble-job |
| 55 | + steps: |
| 56 | + - :: checkout-action |
| 57 | + - :: python-preamble-steps |
| 58 | + - name: configure |
| 59 | + run: | |
| 60 | + cmake -B build/py \ |
| 61 | + -D RYML_DEFAULT_CALLBACK_USES_EXCEPTIONS=ON \ |
| 62 | + -D RYML_BUILD_API=ON \ |
| 63 | + -D RYML_API_TESTS=ON \ |
| 64 | + -D BUILD_SHARED_LIBS=ON \ |
| 65 | + -D RYML_BUILD_TESTS=ON |
| 66 | + - name: build |
| 67 | + run: | |
| 68 | + cmake --build build/py -j -v --target ryml-api-python3 |
| 69 | + cp -fv api/python/ryml/__init__.py build/py/api/python3/. |
| 70 | + ls -lFpAR build/py/api/python3/* |
| 71 | + - name: test with ctest |
| 72 | + run: | |
| 73 | + set -xe |
| 74 | + pydir=`pwd`/build/py/api/python3 |
| 75 | + export PYTHONPATH=$pydir:$PYTHONPATH |
| 76 | + cmake --build build/py -j -v --target ryml-api-test-python3 |
| 77 | + - name: test with pytest |
| 78 | + run: | |
| 79 | + set -xe |
| 80 | + pydir=`pwd`/build/py/api/python3 |
| 81 | + export PYTHONPATH=$pydir:$PYTHONPATH |
| 82 | + python -m pytest -vvv api/python/tests |
| 83 | + |
| 84 | + # run tests with built+installed wheels |
| 85 | + pywheel: |
| 86 | + :: setup-job('api' 'pywheel') |
| 87 | + name: pywheel/${{matrix.config.pythonv}}/${{matrix.config.os}} |
| 88 | + :: python-preamble-job |
| 89 | + steps: |
| 90 | + - :: checkout-action |
| 91 | + - :: python-preamble-steps |
| 92 | + - :: python-wheel-steps('using setup.py' 'python setup.py bdist_wheel -v') |
| 93 | + - :: python-wheel-steps('using pip' 'pip wheel -w dist') |
| 94 | + - :: python-wheel-steps('using pypa/build' 'python -m build --wheel') |
0 commit comments